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 DataAuthDetailTypeEnum implements KeyedNamed {
    HOSPITAL(1, "医院"),
    DEPT(2, "科室"),
    DOCTOR(3, "医生");

    @Setter
    private int key;

    @Setter
    private String name;

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

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

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

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

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