From 74a62f8f58c3521d3c9b63434760f73974fdb989 Mon Sep 17 00:00:00 2001 From: SpaceChae <13278955+enaenen@users.noreply.github.com> Date: Fri, 8 Mar 2024 15:26:30 +0900 Subject: [PATCH] =?UTF-8?q?[BE]=20=EB=8F=99=EC=95=84=EB=A6=AC=20=EC=82=AC?= =?UTF-8?q?=EB=AC=BC=ED=95=A8=20=EC=97=AC=EB=9F=AC=EA=B0=9C=20=EB=B0=B0?= =?UTF-8?q?=EC=A0=95=20=EC=98=A4=EB=A5=98=20#1560=20(#1561)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [BE] FIX: ADMIN 동아리 대여(할당) 전 이미 대여중인 사물함이 있는지 확인 * [BE]FIX: config change --- .../cabinet/admin/lent/service/AdminLentFacadeService.java | 2 +- .../ftclub/cabinet/lent/repository/ClubLentRepository.java | 2 ++ .../ftclub/cabinet/lent/service/ClubLentQueryService.java | 6 ++++++ .../org/ftclub/cabinet/lent/service/LentFacadeService.java | 1 + config | 2 +- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/org/ftclub/cabinet/admin/lent/service/AdminLentFacadeService.java b/backend/src/main/java/org/ftclub/cabinet/admin/lent/service/AdminLentFacadeService.java index c79fd6d4d..dbaf15cc5 100644 --- a/backend/src/main/java/org/ftclub/cabinet/admin/lent/service/AdminLentFacadeService.java +++ b/backend/src/main/java/org/ftclub/cabinet/admin/lent/service/AdminLentFacadeService.java @@ -118,7 +118,7 @@ public void endCabinetLent(List cabinetIds) { lentQueryService.findCabinetsActiveLentHistories(cabinetIds); Map> lentHistoriesByCabinetId = lentHistories.stream() .collect(Collectors.groupingBy(LentHistory::getCabinetId)); - + // is club cabinet if (lentHistories.isEmpty()) { endClubCabinetLent(cabinetIds, cabinets); diff --git a/backend/src/main/java/org/ftclub/cabinet/lent/repository/ClubLentRepository.java b/backend/src/main/java/org/ftclub/cabinet/lent/repository/ClubLentRepository.java index 761b71e79..dfe98ac9b 100644 --- a/backend/src/main/java/org/ftclub/cabinet/lent/repository/ClubLentRepository.java +++ b/backend/src/main/java/org/ftclub/cabinet/lent/repository/ClubLentRepository.java @@ -39,4 +39,6 @@ public interface ClubLentRepository extends JpaRepository + "WHERE clh.cabinetId IN :cabinetIds " + "AND clh.endedAt IS NULL ") Optional> findByEndedAtIsNullJoinCabinets(List cabinetIds); + + Optional findByClubIdAndEndedAtIsNull(Long clubId); } diff --git a/backend/src/main/java/org/ftclub/cabinet/lent/service/ClubLentQueryService.java b/backend/src/main/java/org/ftclub/cabinet/lent/service/ClubLentQueryService.java index 231d02a94..75de20ce5 100644 --- a/backend/src/main/java/org/ftclub/cabinet/lent/service/ClubLentQueryService.java +++ b/backend/src/main/java/org/ftclub/cabinet/lent/service/ClubLentQueryService.java @@ -16,6 +16,12 @@ public class ClubLentQueryService { private final ClubLentRepository clubLentRepository; + public void findAlreadyExistsClubLentHistory(Long clubId) { + clubLentRepository.findByClubIdAndEndedAtIsNull(clubId).ifPresent(clubLentHistory -> { + throw ExceptionStatus.LENT_ALREADY_EXISTED.asServiceException(); + }); + } + public ClubLentHistory findActiveLentHistoryWithClub(Long cabinetId) { return clubLentRepository.findByCabinetIdAndEndedAtIsNullJoinClub(cabinetId) .orElse(null); diff --git a/backend/src/main/java/org/ftclub/cabinet/lent/service/LentFacadeService.java b/backend/src/main/java/org/ftclub/cabinet/lent/service/LentFacadeService.java index 11796f6df..9050ea7a7 100644 --- a/backend/src/main/java/org/ftclub/cabinet/lent/service/LentFacadeService.java +++ b/backend/src/main/java/org/ftclub/cabinet/lent/service/LentFacadeService.java @@ -250,6 +250,7 @@ public void startLentClubCabinet(Long clubId, Long cabinetId) { LocalDateTime expiredAt = lentPolicyService.generateExpirationDate(now, cabinet.getLentType(), 1); + clubLentQueryService.findAlreadyExistsClubLentHistory(clubId); clubLentCommandService.startLent(clubId, cabinetId, expiredAt); cabinetCommandService.updateTitle(cabinet, club.getName()); cabinetCommandService.changeUserCount(cabinet, userCount + 1); diff --git a/config b/config index 71add80f8..d1eba89e0 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit 71add80f85a59a4f395c8813507bdbcbffe6ce23 +Subproject commit d1eba89e00f99a59d4a11d503dce83b59ec666e8