package com.lantone.common.enums;

import com.lantone.common.constant.KeyedNamed;
import lombok.Setter;

/**
 * @ClassName: DataAuthDataTypeEnum
 * @Description: 数据权限数据范围类型注解
 * @Author songxl
 * @Date 2021/7/21
 * @Version 1.0
 */
public enum DataAuthDataTypeEnum implements KeyedNamed {
    ALL_HOSPITAL(1, "全部组织"),
    ALL_DEPT(2, "全部科室"),
    ALL_DEPT_NOT_SELF(3, "全部科室除本科室外"),
    ALL_SELF_DEPT(4, "本科室"),
    SELF_MEDOUP(5, "本医疗组"),
    SELF(6, "本人"),
    CUSTOMIZE(7, "自定义");

    @Setter
    private int key;

    @Setter
    private String name;

    DataAuthDataTypeEnum(int key, String name) {
        this.key = key;
        this.name = name;
    }

    public static DataAuthDataTypeEnum getEnum(int key) {
        for (DataAuthDataTypeEnum item : DataAuthDataTypeEnum.values()) {
            if (item.key == key) {
                return item;
            }
        }
        return null;
    }

    public static String getName(int key) {
        DataAuthDataTypeEnum item = getEnum(key);
        return item != null ? item.name : null;
    }

    @Override
    public int getKey() {
        return key;
    }

    @Override
    public String getName() {
        return name;
    }
}
