From 2c315ab9d072df02483504af74e87d02c6c61067 Mon Sep 17 00:00:00 2001 From: eckrin Date: Wed, 14 Aug 2024 16:20:05 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=8B=B9=EC=B2=A8=EC=9E=90=20=EC=88=98=20=EC=8A=A4=EC=BC=80?= =?UTF-8?q?=EC=A4=84=EB=A7=81=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 이벤트 당첨정보에서 reward 개수를 모두 합하도록 수정 --- .../event/repository/EventRewardRepository.java | 3 +++ .../scheduler/ArrivalEventMaxArrivalScheduler.java | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/softeer/podoarrival/event/repository/EventRewardRepository.java b/src/main/java/com/softeer/podoarrival/event/repository/EventRewardRepository.java index 6ddf3ce..4b9673e 100644 --- a/src/main/java/com/softeer/podoarrival/event/repository/EventRewardRepository.java +++ b/src/main/java/com/softeer/podoarrival/event/repository/EventRewardRepository.java @@ -4,6 +4,9 @@ import com.softeer.podoarrival.event.model.entity.EventReward; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; + public interface EventRewardRepository extends JpaRepository { int countByEvent(Event event); + List findAllByEvent(Event event); } diff --git a/src/main/java/com/softeer/podoarrival/event/scheduler/ArrivalEventMaxArrivalScheduler.java b/src/main/java/com/softeer/podoarrival/event/scheduler/ArrivalEventMaxArrivalScheduler.java index f6154a0..b2bcfbc 100644 --- a/src/main/java/com/softeer/podoarrival/event/scheduler/ArrivalEventMaxArrivalScheduler.java +++ b/src/main/java/com/softeer/podoarrival/event/scheduler/ArrivalEventMaxArrivalScheduler.java @@ -2,6 +2,7 @@ import com.softeer.podoarrival.event.exception.EventTypeNotExistsException; import com.softeer.podoarrival.event.model.entity.Event; +import com.softeer.podoarrival.event.model.entity.EventReward; import com.softeer.podoarrival.event.model.entity.EventType; import com.softeer.podoarrival.event.repository.EventRepository; import com.softeer.podoarrival.event.repository.EventRewardRepository; @@ -14,6 +15,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.List; /** * 선착순 이벤트의 당첨자 수를 세팅하는 스케줄러 @@ -41,9 +43,13 @@ public void setEventArrivalCount() { EventType eventType = eventTypeRepository.findById(1L).orElseThrow(() -> new EventTypeNotExistsException("이벤트 타입이 존재하지 않습니다.")); Event findEvent = eventRepository.findFirstByEventTypeAndStartAtBetween(eventType, startOfDay, endOfDay); - // 찾은 이벤트에 해당하는 reword개수 조회 - int rewordCount = eventRewardRepository.countByEvent(findEvent); + // 찾은 이벤트에 해당하는 reward개수 조회 + int rewardCount = 0; + List eventRewards = eventRewardRepository.findAllByEvent(findEvent); + for (EventReward eventReward : eventRewards) { + rewardCount += eventReward.getNumWinners(); + } - ArrivalEventReleaseService.setMaxArrival(rewordCount); + ArrivalEventReleaseService.setMaxArrival(rewardCount); } } From 5d1adfa222ea920893f14ac4e5269370c5fc428c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=98=81=EB=B9=88?= <81168401+eckrin@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:25:18 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=EC=98=A4=ED=83=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/scheduler/ArrivalEventMaxArrivalScheduler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/softeer/podoarrival/event/scheduler/ArrivalEventMaxArrivalScheduler.java b/src/main/java/com/softeer/podoarrival/event/scheduler/ArrivalEventMaxArrivalScheduler.java index 454e5ab..d383e97 100644 --- a/src/main/java/com/softeer/podoarrival/event/scheduler/ArrivalEventMaxArrivalScheduler.java +++ b/src/main/java/com/softeer/podoarrival/event/scheduler/ArrivalEventMaxArrivalScheduler.java @@ -51,7 +51,7 @@ public void setEventArrivalCount() { rewardCount += eventReward.getNumWinners(); } - ArrivalEventReleaseServiceRedisImpl.setMaxArrival(rewordCount); - ArrivalEventReleaseServiceJavaImpl.setMaxArrival(rewordCount); + ArrivalEventReleaseServiceRedisImpl.setMaxArrival(rewardCount); + ArrivalEventReleaseServiceJavaImpl.setMaxArrival(rewardCount); } }