From 48eafffb8b8cd4735ecd6f228193c67e9594a7e7 Mon Sep 17 00:00:00 2001 From: dongkyeomjang Date: Sat, 23 Nov 2024 19:58:31 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20BugFix/#121=20-=20Spring=20Data?= =?UTF-8?q?=20Redis=EB=8A=94=20=EA=B8=B0=EB=B3=B8=20=ED=82=A4(@Id)=20?= =?UTF-8?q?=EA=B8=B0=EB=B0=98=20=EC=82=AD=EC=A0=9C=EB=A7=8C=20=EC=A7=80?= =?UTF-8?q?=EC=9B=90=ED=95=B4=EC=84=9C=20=EB=B0=9C=EC=83=9D=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=B2=84=EA=B7=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/repository/redis/ScheduledEventJobRepository.java | 3 ++- .../consumer/EventSchedulerConsumerV1Controller.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/daon/onjung/core/repository/redis/ScheduledEventJobRepository.java b/src/main/java/com/daon/onjung/core/repository/redis/ScheduledEventJobRepository.java index 31e4c57..eee0b51 100644 --- a/src/main/java/com/daon/onjung/core/repository/redis/ScheduledEventJobRepository.java +++ b/src/main/java/com/daon/onjung/core/repository/redis/ScheduledEventJobRepository.java @@ -6,10 +6,11 @@ import org.springframework.stereotype.Repository; import java.util.List; +import java.util.Optional; @Repository public interface ScheduledEventJobRepository extends CrudRepository { @NotNull List findAll(); - void deleteByEventId(Long eventId); + Optional findByEventId(Long eventId); } diff --git a/src/main/java/com/daon/onjung/event/application/controller/consumer/EventSchedulerConsumerV1Controller.java b/src/main/java/com/daon/onjung/event/application/controller/consumer/EventSchedulerConsumerV1Controller.java index 4efb7bf..6ba3e4c 100644 --- a/src/main/java/com/daon/onjung/event/application/controller/consumer/EventSchedulerConsumerV1Controller.java +++ b/src/main/java/com/daon/onjung/event/application/controller/consumer/EventSchedulerConsumerV1Controller.java @@ -21,7 +21,8 @@ public void execute(JobExecutionContext context) throws JobExecutionException { Long eventId = context.getJobDetail().getJobDataMap().getLong("eventId"); // eventId를 통해 ScheduledEventJob을 삭제 - scheduledEventJobRepository.deleteByEventId(eventId); + scheduledEventJobRepository.findByEventId(eventId) + .ifPresent(scheduledEventJobRepository::delete); log.info("ScheduledEventJob 삭제 완료. eventId: {}", eventId); processCompletedEventUseCase.execute(eventId);