package com.persagy.dmp.auth.service;

import com.persagy.dmp.auth.constant.AuthChannelEnum;
import com.persagy.dmp.common.helper.SpringHelper;

/**
 * 鉴权工厂
 * @author Charlie Yu
 * @date 2021-11-02
 */
public class AuthServiceFactory {

    private static AuthService authService;

    /**
     * 获取鉴权服务
     * @return
     */
    public static AuthService getAuthService() {
        if(authService == null) {
            Integer authChannel = SpringHelper.getInt("persagy.common.auth.channel", -1);
            String beanName = AuthChannelEnum.load(authChannel).getName();
            authService = SpringHelper.getBean(beanName);
        }
        return authService;
    }
}
