package com.xjrsoft.common.schedule;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@RequiredArgsConstructor
@Component
@ConditionalOnProperty(name = {"schedule.enabled","schedule.sync-xx.enabled"}, havingValue = "true")
@Slf4j
@EnableScheduling
public class DemoSysncTask {
	
//	
//    @Scheduled(cron = "${schedule.sync-xx.cron:0 0/60 * * * *}") //60分钟跑一次
//    public void sync(){
//        log.info("同步XX数据 => " + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
//        try{
//            //todo 任务具体实现
//        } catch (Exception e){
//            log.error("同步XX数据失败：" + e);
//        }
//    }
}
