package com.diagbot.enums;

import com.diagbot.core.KeyedNamed;
import lombok.Setter;

/**
 * @Description: 访问的系统类型
 *  1:user-service,2:diagbotman-service,3:uaa-service,4:log-service,
 *  5:bi-service,6:knowledge-service,7:feedback-service,8:icss-web
 * @author: gaodm
 * @time: 2018/9/14 9:15
 */
public enum SysTypeEnum implements KeyedNamed {
    USER_SERVICE(1, "user-service"),
    DIAGBOTMAN_SERVICE(2, "diagbotman-service"),
    UAA_SERVICE(3, "uaa-service"),
    LOG_SERVICE(4, "log-service"),
    BI_SERVICE(5, "bi-service"),
    KNOWLEDGE_SERVICE(6, "knowledge-service"),
    FEEDBACK_SERVICE(7, "feedback-service"),
    ICSS_WEB(8, "icss-web");

    @Setter
    private int key;

    @Setter
    private String name;

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

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

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

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

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