package com.zhangmeng.model.entity;

import com.zhangmeng.model.base.baseEntity.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @author zhengmeng
 * @version 1.0
 * @date 2021年1月7日11:38:42
 */
@NoArgsConstructor
@Data
@AllArgsConstructor
@Entity
@EqualsAndHashCode(callSuper = false)
@Table(name = "permission")
public class Permission extends BaseEntity<Long> {

    public enum Status{
        show("显示"),
        hidden("隐藏");
        private String description;//描述

        Status(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }
    }


    public enum Type{
        CATALOG("目录"),
        MENU("菜单"),
        BUTTON("按钮");
        private String description;//描述

        Type(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

        public static List<Map<String,Object>> valueListMap(){
            Type[] values = Type.values();
            List<Map<String, Object>> list = new ArrayList<>();
            for (Type value : values) {
                Map<String, Object> map = new HashMap<>();
                String description = value.getDescription();
                map.put("description",description);
                map.put("value",value);
                list.add(map);
            }
            return list;
        }

    }

    private String title;

    private Type type;

    private String href;

    private String openType;

    private Long parent_id;

    private String icon;

    private String code;

    private String checkArr = "0";

    private Integer sort;
}
