package com.boman.web.core.controller;

import com.boman.common.core.utils.DateUtils;
import com.boman.web.core.service.TaskService;
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;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * @author tjf
 * @Date: 2021/08/04/17:48
 */
@Configuration      //1.主要用于标记配置类，兼备Component的效果。
@EnableScheduling   // 2.开启定时任务
public class TaskController {
    @Resource
    private TaskService taskService;
    /**
     * 每月1号往考勤记录表根据用户插入当月的数据 每月一号00:00:05秒
     */
    @Scheduled(cron = "5 0 0 1 * ?")
    private void configureTasks() {
        System.out.println(DateUtils.getNowDate() +"开始执行定时任务");
        taskService.configureTasks();
        System.out.println(DateUtils.getNowDate() +"定时任务结束");
    }
}
