package com.persagy.dmp.auth.constant;

import lombok.Getter;

/**
 * 鉴权渠道
 * @author Charlie Yu
 * @date 2021-11-02
 */
@Getter
public enum AuthChannelEnum {

    /** 不鉴权 */
    NONE(-1, "noneAuthServiceImpl"),
    /** 运维平台2.0 */
    EMS(1, "emsAuthServiceImpl"),
    /** BOSS */
    BOSS(2, "bossAuthServiceImpl");

    private Integer index;
    private String name;

    AuthChannelEnum(Integer index, String name) {
        this.index = index;
        this.name = name;
    }

    /**
     * 获取Enum
     * @param index
     * @return
     */
    public static AuthChannelEnum load(Integer index) {
        for (AuthChannelEnum value: values()) {
            if (value.getIndex().equals(index)) {
                return value;
            }
        }
        // 没有匹配的，返回默认
        return AuthChannelEnum.NONE;
    }
}
