package ink.wgink.module.file.startup;

import ink.wgink.interfaces.manager.IFilesShowCodeService;
import ink.wgink.module.file.dao.fileclient.IFileClientDao;
import ink.wgink.module.file.manager.FileRemoteManager;
import ink.wgink.module.file.manager.FilesManager;
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: FileStartUp
 * @Description: 文件启动类
 * @Author: wanggeng
 * @Date: 2022/8/1 16:17
 * @Version: 1.0
 */
@Component
public class FilesStartUp implements ApplicationRunner {

    @Autowired
    private IFilesShowCodeService filesShowCodeService;
    @Autowired
    private IFileClientDao fileRemoteDao;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        FilesManager.getInstance().setFilesShowCodeService(filesShowCodeService);
        FileRemoteManager.getInstance().setFileRemoteDao(fileRemoteDao);
    }

    @Scheduled(cron = "0 0/1 * * * ?")
    public void clearTimeoutShowCode() {
        FilesManager.getInstance().clearTimeoutShowCode();
    }
}
