38 lines
1.4 KiB
Java
38 lines
1.4 KiB
Java
package ru.ulstu.paper.service;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@Service
|
|
public class DeadlineScheduler {
|
|
private final static boolean IS_DEADLINE_NOTIFICATION_BEFORE_WEEK = true;
|
|
|
|
private final Logger log = LoggerFactory.getLogger(DeadlineScheduler.class);
|
|
|
|
private final PaperNotificationService paperNotificationService;
|
|
private final PaperService paperService;
|
|
|
|
public DeadlineScheduler(PaperNotificationService paperNotificationService,
|
|
PaperService paperService) {
|
|
this.paperNotificationService = paperNotificationService;
|
|
this.paperService = paperService;
|
|
}
|
|
|
|
|
|
@Scheduled(cron = "0 0 8 * 1 ?")
|
|
public void checkDeadlineBeforeWeek() {
|
|
log.debug("DeadlineScheduler.checkDeadlineBeforeWeek started");
|
|
paperNotificationService.sendDeadlineNotifications(paperService.findAll(), !IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
|
|
log.debug("DeadlineScheduler.checkDeadlineBeforeWeek finished");
|
|
}
|
|
|
|
@Scheduled(cron = "0 0 8 * * ?")
|
|
public void checkDeadlineAfterWeek() {
|
|
log.debug("DeadlineScheduler.checkDeadlineAfterWeek started");
|
|
paperNotificationService.sendDeadlineNotifications(paperService.findAll(), IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
|
|
log.debug("DeadlineScheduler.checkDeadlineAfterWeek finished");
|
|
}
|
|
}
|