From 4b987f894d9cead49d4dd16ac99aad25ebfdb9b7 Mon Sep 17 00:00:00 2001 From: Tim <135014430+nagisa77@users.noreply.github.com> Date: Mon, 11 Aug 2025 11:11:11 +0800 Subject: [PATCH] Handle self-invocation in PostService --- .../src/main/java/com/openisle/service/PostService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/com/openisle/service/PostService.java b/backend/src/main/java/com/openisle/service/PostService.java index ebb34f143..6ea68f817 100644 --- a/backend/src/main/java/com/openisle/service/PostService.java +++ b/backend/src/main/java/com/openisle/service/PostService.java @@ -43,8 +43,8 @@ import java.util.HashSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ScheduledFuture; - -import jakarta.annotation.PostConstruct; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.event.EventListener; @Slf4j @Service @@ -108,8 +108,8 @@ public class PostService { this.publishMode = publishMode; } - @PostConstruct - private void rescheduleLotteries() { + @EventListener(ApplicationReadyEvent.class) + public void rescheduleLotteries() { LocalDateTime now = LocalDateTime.now(); for (LotteryPost lp : lotteryPostRepository.findByEndTimeAfterAndWinnersIsEmpty(now)) { ScheduledFuture future = taskScheduler.schedule(