package ink.wgink.app.startup;

import ink.wgink.app.AppTokenManager;
import ink.wgink.interfaces.manager.IAppTokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @ClassName: AppTokenStartup
 * @Description:
 * @Author: wanggeng
 * @Date: 2021/11/30 2:14 下午
 * @Version: 1.0
 */
@Component
public class AppTokenStartup implements ApplicationRunner {

    @Autowired
    private IAppTokenService appTokenService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        AppTokenManager.getInstance().setAppTokenService(appTokenService);
    }

    @Scheduled(cron = "0 0/1 * * * ?")
    public void clearAppTokenUser() {
        AppTokenManager.getInstance().clearTimeoutToken();
    }

}
