package com.njcn.product.event.transientes.job;

import com.njcn.product.event.transientes.service.SendMessageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * Description:
 * Date: 2026/05/29  上午 10:45【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Component
@EnableScheduling
@RequiredArgsConstructor
@Slf4j
public class SendMessageJob {
    private final SendMessageService messageService;

    @Scheduled(cron = "${business.sendMessageCronExpression}")
    public void executeJob() {
        // 获取当前时间
        LocalDateTime now = LocalDateTime.now();
        // 减去一个小时
        LocalDateTime threeHourAgo = now.minusHours(3);

        messageService.sendMessage(threeHourAgo,now);
    }
}
