From 4fd33258623add8572fd4417aac6125ce38a9202 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sat, 19 Aug 2023 23:31:31 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=A9=94=EC=9D=BC=20=EC=A0=84=EC=86=A1?= =?UTF-8?q?=20cron=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/land/leets/LeetsApplication.java | 2 ++ .../land/leets/global/cron/SendMailCron.java | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/main/java/land/leets/global/cron/SendMailCron.java diff --git a/src/main/java/land/leets/LeetsApplication.java b/src/main/java/land/leets/LeetsApplication.java index a9aee9a..818598e 100644 --- a/src/main/java/land/leets/LeetsApplication.java +++ b/src/main/java/land/leets/LeetsApplication.java @@ -3,9 +3,11 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication @EnableJpaAuditing +@EnableScheduling public class LeetsApplication { public static void main(String[] args) { diff --git a/src/main/java/land/leets/global/cron/SendMailCron.java b/src/main/java/land/leets/global/cron/SendMailCron.java new file mode 100644 index 0000000..6af7050 --- /dev/null +++ b/src/main/java/land/leets/global/cron/SendMailCron.java @@ -0,0 +1,29 @@ +package land.leets.global.cron; + +import land.leets.domain.mail.usercase.SendMail; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +@Slf4j +@RequiredArgsConstructor +@Component +public class SendMailCron { + private final SendMail sendMail; + +// @Scheduled(cron = "0 0 10 4 9 ?") + @Scheduled(cron = "10 35 23 19 8 ?") + public void sendPaperMail() { + sendMail.execute("paper"); + + log.info("Send paper result mail successfully."); + } + + @Scheduled(cron = "0 0 18 11 9 ?") + public void sendFinalMail() { + sendMail.execute("final"); + + log.info("Send final result mail successfully."); + } +}