package com.YuyeTech.HeartRate.game.food.scheduled;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FoodQuartzConfig {

    private static String DayTrigger = "0 0/5 * * * ?";

    @Bean
    public JobDetail syncFoodDayJobDetail(){
        JobDetail jobDetail = JobBuilder.newJob(FoodDayTask.class).storeDurably().build();
        return jobDetail;
    }

    @Bean
    public Trigger syncFoodDayTrigger(){
        //每隔五秒触发一次，暂时
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(DayTrigger);

        Trigger trigger = TriggerBuilder.newTrigger().forJob(syncFoodDayJobDetail()).withSchedule(cronScheduleBuilder).build();
        return trigger;
    }
}
