package cn.superdesk.uniorder.common.enums.lnss;

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

/**
 * @author kite
 * @version 1.0
 * @date 2019/8/12
 */
public enum UserTypeEnum {

    VISITOR(1, "游客"),

    CHECK_USER(2, "验证用户"),

    NO_CHECK_USER(3,"白名单用户"),

    MERCHANT_ADMIN(9,"商户管理员"),

    ;

    private Integer key;
    private String desc;

    UserTypeEnum(int key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    public int getKey() {
        return key;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDesc(int key) {
        for (UserTypeEnum c : UserTypeEnum.values()) {
            if (c.key == key) {
                return c.getDesc();
            }
        }
        return null;
    }

    private static final Map<Integer, UserTypeEnum> LOOKUP = new HashMap<>();

    static {
        for(UserTypeEnum s : EnumSet.allOf(UserTypeEnum.class)) {
            LOOKUP.put(s.getKey(), s);
        }
    }

    /**
     * 方向查找枚举类
     * @param key
     * @return
     */
    public static UserTypeEnum get(Integer key) {
        return LOOKUP.get(key);
    }
}
