package org.jeecg.modules.oauth2_server.util;

import cn.dev33.satoken.oauth2.SaOAuth2Manager;
import cn.dev33.satoken.oauth2.config.SaOAuth2Config;
import cn.dev33.satoken.spring.oauth2.SaOAuth2BeanInject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Configuration;

/**
 * @author liushuai
 * @create 2022-02-08 10:06
 */
@Configuration
@ConditionalOnClass(SaOAuth2Manager.class)
public class SaOAuth2Bean extends SaOAuth2BeanInject {

    /**
     * 注入OAuth2配置Bean
     *
     * @param saOAuth2Config 配置对象
     */
    @Autowired(required = false)
    public void setSaOAuth2Config(SaOAuth2Config saOAuth2Config) {
        SaOAuth2Manager.setConfig(saOAuth2Config);
    }

    /**
     * 注入代码模板Bean
     *
     * @param saOAuth2Template 代码模板Bean
     */
    @Autowired(required = false)
    public void setSaOAuth2Interface(SaOAuth2Templates saOAuth2Templates) {
        SaOAuth2Utils.saOAuth2Template = saOAuth2Templates;
    }

}

