package com.tuoheng.admin.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 *  用户类型
 *
 * @author wanjing
 * @team tuoheng
 * @date 2022-11-25
 */
public enum DataPermissionEnum {

    ALL(1,"查看所有部门数据"),
    DEPT_AND_SUB_DEPT(2,"查看本部门及子部门数据"),
    DEPT(3,"查看本部门数据");

    DataPermissionEnum(int code, String description){
        this.code = code;
        this.description = description;
    }

    @Getter
    private int code;

    @Getter
    private String description;

    private static Map<Integer, DataPermissionEnum> data = new HashMap<>();

    static {
        for (DataPermissionEnum type : DataPermissionEnum.values()) {
            data.put(type.code, type);
        }
    }

    public static DataPermissionEnum parse(int code) {
        if (data.containsKey(code)) {
            return data.get(code);
        }
        return null;
    }
}
