package com.lantone.security.enums;

import lombok.Getter;
import lombok.Setter;

/**
 * @Description: 字典返回值returnType
 * @author: gaodm
 * @time: 2018/9/3 16:01
 */
public enum ReturnTypeEnum {

    ALL("0", "全部"),
    CONSOLE("1", "后台"),
    INTERFACE("2", "界面");

    @Getter
    @Setter
    private String key;

    @Getter
    @Setter
    private String name;

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

    public static ReturnTypeEnum getEnum(String key) {
        for (ReturnTypeEnum item : ReturnTypeEnum.values()) {
            if (item.key.equals(key)) {
                return item;
            }
        }
        return null;
    }

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