From 1b21be107b1476258e987559282c7d06f2ffe95e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?toni=20=28=EC=9D=B4=EC=86=8C=EC=9D=80=29?= <144209738+saokiritoni@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:12:28 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=EC=8A=A4=ED=83=AC=ED=94=84=20=EC=A6=9D?= =?UTF-8?q?=EA=B0=80=20=EC=A0=9C=EC=96=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../osori/domain/quest/service/QuestService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/dongguk/osori/domain/quest/service/QuestService.java b/src/main/java/dongguk/osori/domain/quest/service/QuestService.java index 1a56cd0..3b9bb65 100644 --- a/src/main/java/dongguk/osori/domain/quest/service/QuestService.java +++ b/src/main/java/dongguk/osori/domain/quest/service/QuestService.java @@ -30,7 +30,7 @@ public void completeMission(Long userId, LocalDate date) { // 모든 미션이 완료되었는지 확인 if (!quest.isAllMissionsCompleted()) { - throw new IllegalStateException("모든 미션이 완료되지 않았습니다."); + return; // 미션이 완료되지 않았으면 아무 동작도 하지 않음 } // 스탬프 증가 @@ -47,6 +47,14 @@ private void incrementStamp(Long userId, LocalDate date) { Stamp stamp = stampRepository.findByUser_UserIdAndWeekNumberAndYear(userId, weekNumber, year) .orElseGet(() -> new Stamp(user, weekNumber, year)); + // 오늘 날짜에 해당하는 스탬프가 이미 채워졌는지 확인 + int todayDayOfWeek = date.getDayOfWeek().getValue(); // 월요일(1) ~ 일요일(7) + if (stamp.getCount() >= todayDayOfWeek) { + // 이미 채워져 있는 경우 메서드 종료 + return; + } + + // 스탬프를 증가시킴 stamp.incrementStamp(); stampRepository.save(stamp); }