package com.cm.common.plugin.startup;

import com.cm.common.config.properties.ApiPathProperties;
import com.cm.common.config.properties.OauthClientProperties;
import com.cm.common.config.properties.OauthProperties;
import com.cm.common.plugin.oauth.token.ClientTokenManager;
import com.cm.common.plugin.utils.RestTemplateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: OAuthStartUp
 * @Description:
 * @Author: WangGeng
 * @Date: 2020/3/4 9:14 下午
 * @Version: 1.0
 **/
@Configuration
public class OAuthStartUp implements ApplicationRunner {

    @Autowired
    private OauthClientProperties oauthClientProperties;
    @Autowired
    private OauthProperties oauthProperties;
    @Autowired
    private ApiPathProperties apiPathProperties;
    @Autowired
    private RestTemplateUtil restTemplateUtil;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        ClientTokenManager clientTokenManager = ClientTokenManager.getInstance();
        clientTokenManager.setRestTemplateUtil(restTemplateUtil);
        clientTokenManager.setOauthProperties(oauthProperties);
        clientTokenManager.setOauthClientProperties(oauthClientProperties);
        clientTokenManager.setApiPathProperties(apiPathProperties);
    }
}
