package com.keyware.shandan.system.task;

import com.keyware.shandan.system.service.SysSettingService;
import com.keyware.shandan.system.utils.DictUtil;
import com.keyware.shandan.system.utils.SysSettingUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * @author Administrator
 */
@Configuration
@EnableScheduling
public class TaskHandler {

    @Autowired
    private DictUtil dictUtil;

    @Autowired
    private SysSettingService settingService;

    @Scheduled(cron = "0 0/1 * * * ?")
    public void task(){
        dictUtil.initDictCache();
        settingTask();
    }

    private void settingTask(){
        settingService.list().forEach(SysSettingUtil::setSysSettingMap);
    }
}
