From 88c664275ef605b9bbc121286241ac86f7717a8d Mon Sep 17 00:00:00 2001 From: kjungw1025 Date: Fri, 5 Jan 2024 22:02:49 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20BearEats=EC=97=90=20=EB=8C=80=ED=95=9C?= =?UTF-8?q?=20=EB=A6=AC=EB=B7=B0=20=EC=9E=91=EC=84=B1=20=EA=B0=80=EB=8A=A5?= =?UTF-8?q?=20=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EC=9E=91=EC=84=B1=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../with_dankook/WithDankookRepository.java | 7 +++- .../service/WithDankookService.java | 34 ++++++++++++------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/dku/council/domain/with_dankook/repository/with_dankook/WithDankookRepository.java b/src/main/java/com/dku/council/domain/with_dankook/repository/with_dankook/WithDankookRepository.java index 49d7faa7..350f2490 100644 --- a/src/main/java/com/dku/council/domain/with_dankook/repository/with_dankook/WithDankookRepository.java +++ b/src/main/java/com/dku/council/domain/with_dankook/repository/with_dankook/WithDankookRepository.java @@ -61,5 +61,10 @@ public interface WithDankookRepository extends JpaReposit @Query(value = "select COUNT(*) from with_dankook w " + "where w.with_dankook_id = :withDankookId and " + "((w.with_dankook_status in ('FULL', 'CLOSED')) or (w.with_dankook_status = 'ACTIVE' and w.end_time <= CURRENT_TIMESTAMP())) ", nativeQuery = true) - int findWithClosedOrFullOrActiveByIdToCreateReview(@Param("withDankookId") Long withDankookId); + int findWithClosedOrFullOrActiveEndTimeByIdToCreateReview(@Param("withDankookId") Long withDankookId); + + @Query(value = "select COUNT(*) from with_dankook w " + + "where w.with_dankook_id = :withDankookId and " + + "((w.with_dankook_status in ('FULL', 'CLOSED')) or (w.with_dankook_status = 'ACTIVE' and w.delivery_time <= CURRENT_TIMESTAMP())) ", nativeQuery = true) + int findWithClosedOrFullOrActiveDeliveryTimeByIdToCreateReview(@Param("withDankookId") Long withDankookId); } diff --git a/src/main/java/com/dku/council/domain/with_dankook/service/WithDankookService.java b/src/main/java/com/dku/council/domain/with_dankook/service/WithDankookService.java index 2d3e00ed..d7b64004 100644 --- a/src/main/java/com/dku/council/domain/with_dankook/service/WithDankookService.java +++ b/src/main/java/com/dku/council/domain/with_dankook/service/WithDankookService.java @@ -213,18 +213,28 @@ public interface PostResultMapper { public void isPossibleCreateReview(Long withDankookId) { String withDankookType = withDankookRepository.findWithDankookType(withDankookId); - if (withDankookType.equals("Trade")) { - if (withDankookRepository.findWithClosedByIdToCreateReview(withDankookId) != 1) { - throw new InvalidStatusException(); - } -// } else if (withDankookType.equals("Study") || withDankookType.equals("Dormitory")) { -// if (withDankookRepository.findWithClosedOrFullOrActiveByIdToCreateReview(withDankookId) != 1) { -// throw new InvalidStatusException(); -// } - } else if (withDankookType.equals("BearEats") || withDankookType.equals("EatingAlong")) { - if (withDankookRepository.findWithClosedOrFullByIdToCreateReview(withDankookId) != 1) { - throw new InvalidStatusException(); - } + switch (withDankookType) { + case "Trade": + case "Roommate": + if (withDankookRepository.findWithClosedByIdToCreateReview(withDankookId) != 1) { + throw new InvalidStatusException(); + } + break; + case "Study": + if (withDankookRepository.findWithClosedOrFullOrActiveEndTimeByIdToCreateReview(withDankookId) != 1) { + throw new InvalidStatusException(); + } + break; + case "EatingAlong": + if (withDankookRepository.findWithClosedOrFullByIdToCreateReview(withDankookId) != 1) { + throw new InvalidStatusException(); + } + break; + case "BearEats": + if (withDankookRepository.findWithClosedOrFullOrActiveDeliveryTimeByIdToCreateReview(withDankookId) != 1) { + throw new InvalidStatusException(); + } + break; } } }