From 20b7f7450a9b1e6301da294b9960aa382ad0bd9b Mon Sep 17 00:00:00 2001 From: ldw Date: Mon, 20 Nov 2023 16:03:10 +0900 Subject: [PATCH 01/24] =?UTF-8?q?[BE]=20FEAT:=20pending=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=EC=9D=B8=20=EC=82=AC=EB=AC=BC=ED=95=A8=EB=93=A4?= =?UTF-8?q?=EC=9D=98=20CabinetInfoResponseDto=EB=A5=BC=20=EA=B0=80?= =?UTF-8?q?=EC=A0=B8=EC=98=A4=EB=8A=94=20API=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cabinet/cabinet/controller/CabinetController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java index 71a79d9e6..544943333 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java @@ -8,6 +8,7 @@ import org.ftclub.cabinet.cabinet.service.CabinetFacadeService; import org.ftclub.cabinet.dto.BuildingFloorsDto; import org.ftclub.cabinet.dto.CabinetInfoResponseDto; +import org.ftclub.cabinet.dto.CabinetPendingResponseDto; import org.ftclub.cabinet.dto.CabinetsPerSectionResponseDto; import org.ftclub.cabinet.exception.ControllerException; import org.springframework.web.bind.annotation.GetMapping; @@ -68,4 +69,11 @@ public CabinetInfoResponseDto getCabinetInfo( log.info("Called getCabinetInfo {}", cabinetId); return cabinetFacadeService.getCabinetInfo(cabinetId); } + + @GetMapping("/pending") + @AuthGuard(level = AuthLevel.USER_OR_ADMIN) + public CabinetPendingResponseDto getPendingCabinets() { + log.info("Called getPendingCabinets"); + return cabinetFacadeService.getPendingCabinets(); + } } From a19f32e249b566744f5e7a0a13c8c0cf61440b70 Mon Sep 17 00:00:00 2001 From: ldw Date: Mon, 20 Nov 2023 16:04:36 +0900 Subject: [PATCH 02/24] =?UTF-8?q?[BE]=20FEAT:=20pending=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=EC=9D=B8=20=EC=82=AC=EB=AC=BC=ED=95=A8=EB=93=A4?= =?UTF-8?q?=EC=9D=98=20CabinetInfoResponseDto=EB=A5=BC=20=EA=B0=80?= =?UTF-8?q?=EC=A0=B8=EC=98=A4=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/CabinetOptionalFetcher.java | 331 +++++++++--------- .../cabinet/repository/CabinetRepository.java | 5 + .../cabinet/service/CabinetFacadeService.java | 25 +- .../service/CabinetFacadeServiceImpl.java | 15 + .../cabinet/service/CabinetService.java | 6 + .../cabinet/service/CabinetServiceImpl.java | 5 + config | 2 +- 7 files changed, 216 insertions(+), 173 deletions(-) diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java index 2c92e416b..17e9238cd 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java @@ -29,166 +29,173 @@ @Transactional public class CabinetOptionalFetcher { - private final CabinetRepository cabinetRepository; - private final CabinetMapper cabinetMapper; - - /*-------------------------------------------FIND-------------------------------------------*/ - - public Cabinet findCabinet(Long cabinetId) { - log.debug("Called findCabinet: {}", cabinetId); - return cabinetRepository.findById(cabinetId).orElse(null); - } - - public List findCabinetsActiveLentHistoriesByBuildingAndFloor( - String building, Integer floor) { - log.debug("Called findCabinetsActiveLentHistoriesByBuildingAndFloor: {}, {}", building, - floor); - return cabinetRepository.findCabinetActiveLentHistoryUserListByBuildingAndFloor(building, - floor).stream() - .map(result -> { - Cabinet cabinet = (Cabinet) result[0]; - LentHistory lentHistory = (LentHistory) result[1]; - User user = (User) result[2]; - return cabinetMapper.toActiveCabinetInfoEntitiesDto(cabinet, lentHistory, user); - }).collect(Collectors.toList()); - } - - public List findCabinetsActiveLentHistoriesByBuildingAndFloor2( - String building, Integer floor) { - return cabinetRepository.findCabinetsActiveLentHistoriesByBuildingAndFloor(building, floor); - } - - public List findCabinetsByBuildingAndFloor2(String building, Integer floor) { - return cabinetRepository.findAllCabinetsByBuildingAndFloor(building, floor); - } - - /** - * 유저 ID로 사물함을 찾습니다. - * - * @param userId 유저ID - * @return 사물함 엔티티 - * @throws ServiceException 사물함을 찾을 수 없는 경우 - */ - public Cabinet findLentCabinetByUserId(Long userId) { - log.debug("Called findLentCabinetByUserId: {}", userId); - return cabinetRepository.findLentCabinetByUserId(userId).orElse(null); - } - - public List findAllBuildings() { - log.debug("Called findAllBuildings"); - return cabinetRepository.findAllBuildings(); - } - - public List findAllFloorsByBuilding(String building) { - log.debug("Called findAllFloorsByBuilding: {}", building); - return cabinetRepository.findAllFloorsByBuilding(building); - } - - // deprecated - public List findAllSectionsByBuildingAndFloor(String building, Integer floor) { - log.debug("Called findAllSectionsByBuildingAndFloor: {}, {}", building, floor); - return cabinetRepository.findAllSectionsByBuildingAndFloor(building, floor); - } - - public List findAllPendingCabinetsByCabinetStatusAndBeforeEndedAt(CabinetStatus cabinetStatus, - LocalDateTime currentDate) { - log.debug("Called findAllCabinetsByCabinetStatusAndBeforeEndedAt: {}", cabinetStatus); - return cabinetRepository.findAllCabinetsByCabinetStatusAndBeforeEndedAt(cabinetStatus, currentDate); - } - - public Page findPaginationByLentType(LentType lentType, PageRequest pageable) { - log.debug("Called findPaginationByLentType: {}", lentType); - return cabinetRepository.findPaginationByLentType(lentType, pageable); - } - - public Page findPaginationByStatus(CabinetStatus status, PageRequest pageable) { - log.debug("Called findPaginationByStatus: {}", status); - return cabinetRepository.findPaginationByStatus(status, pageable); - } - - public Page findPaginationByVisibleNum(Integer visibleNum, PageRequest pageable) { - log.debug("Called findPaginationByVisibleNum: {}", visibleNum); - return cabinetRepository.findPaginationByVisibleNum(visibleNum, pageable); - } - - public List findAllCabinetsByLocation(Location location) { - log.debug("Called findAllCabinetsByLocation: {}", location); - return cabinetRepository.findAllCabinetsByLocation(location); - } - - public List findAllCabinetsByBuildingAndFloor(String building, Integer floor) { - return cabinetRepository.findAllByBuildingAndFloor(building, floor); - } - /*-------------------------------------------GET--------------------------------------------*/ - - - /** - * 사물함 ID로 변경 사항이 예정된 사물함을 찾습니다. - *

- * X Lock을 획득한 상태로 가져옵니다. - * - * @param cabinetId 사물함 ID - * @return 사물함 엔티티 - * @throws ServiceException 사물함을 찾을 수 없는 경우 - */ - public Cabinet getCabinetForUpdate(Long cabinetId) { - log.debug("Called getCabinetForUpdate: {}", cabinetId); - return cabinetRepository.findByIdForUpdate(cabinetId) - .orElseThrow(() -> new ServiceException(ExceptionStatus.NOT_FOUND_CABINET)); - } - - /** - * 사물함 ID로 사물함을 찾습니다. - * - * @param cabinetId 사물함 ID - * @return 사물함 엔티티 - * @throws ServiceException 사물함을 찾을 수 없는 경우 - */ - public Cabinet getCabinet(Long cabinetId) { - log.debug("Called getCabinet: {}", cabinetId); - return cabinetRepository.findById(cabinetId) - .orElseThrow(() -> new ServiceException(ExceptionStatus.NOT_FOUND_CABINET)); - } - - /** - * 유저 ID로 사물함을 찾습니다. - * - * @param userId 유저ID - * @return 사물함 엔티티 - * @throws ServiceException 사물함을 찾을 수 없는 경우 - */ - public Cabinet getLentCabinetByUserId(Long userId) { - log.debug("Called getLentCabinetByUserId: {}", userId); - return cabinetRepository.findLentCabinetByUserId(userId) - .orElseThrow(() -> new ServiceException(ExceptionStatus.NOT_FOUND_CABINET)); - } - - /** - * 사물함 ID로 동아리 사물함을 찾습니다. - * - * @param cabinetId 사물함 ID - * @return 동아리 사물함 엔티티 - * @throws ServiceException 사물함을 찾을 수 없는 경우 - */ - public Cabinet getClubCabinet(Long cabinetId) { - log.debug("Called getClubCabinet: {}", cabinetId); - Cabinet cabinet = getCabinet(cabinetId); - if (!cabinet.isLentType(LentType.CLUB)) { - throw new ServiceException(ExceptionStatus.NOT_FOUND_CABINET); - } - return cabinet; - } - - /** - * 사물함 ID로 위치(빌딩, 층, 섹션) 정보를 찾습니다. - * - * @param cabinetId 사물함 ID - * @return 위치 엔티티 - * @throws ServiceException 사물함을 찾을 수 없는 경우 - */ - public Location getLocation(Long cabinetId) { - log.debug("Called getLocation: {}", cabinetId); - return cabinetRepository.findLocationById(cabinetId) - .orElseThrow(() -> new ServiceException(ExceptionStatus.NOT_FOUND_CABINET)); - } + private final CabinetRepository cabinetRepository; + private final CabinetMapper cabinetMapper; + + /*-------------------------------------------FIND-------------------------------------------*/ + + public Cabinet findCabinet(Long cabinetId) { + log.debug("Called findCabinet: {}", cabinetId); + return cabinetRepository.findById(cabinetId).orElse(null); + } + + public List findCabinetsActiveLentHistoriesByBuildingAndFloor( + String building, Integer floor) { + log.debug("Called findCabinetsActiveLentHistoriesByBuildingAndFloor: {}, {}", building, + floor); + return cabinetRepository.findCabinetActiveLentHistoryUserListByBuildingAndFloor(building, + floor).stream() + .map(result -> { + Cabinet cabinet = (Cabinet) result[0]; + LentHistory lentHistory = (LentHistory) result[1]; + User user = (User) result[2]; + return cabinetMapper.toActiveCabinetInfoEntitiesDto(cabinet, lentHistory, user); + }).collect(Collectors.toList()); + } + + public List findCabinetsActiveLentHistoriesByBuildingAndFloor2( + String building, Integer floor) { + return cabinetRepository.findCabinetsActiveLentHistoriesByBuildingAndFloor(building, floor); + } + + public List findCabinetsByBuildingAndFloor2(String building, Integer floor) { + return cabinetRepository.findAllCabinetsByBuildingAndFloor(building, floor); + } + + /** + * 유저 ID로 사물함을 찾습니다. + * + * @param userId 유저ID + * @return 사물함 엔티티 + * @throws ServiceException 사물함을 찾을 수 없는 경우 + */ + public Cabinet findLentCabinetByUserId(Long userId) { + log.debug("Called findLentCabinetByUserId: {}", userId); + return cabinetRepository.findLentCabinetByUserId(userId).orElse(null); + } + + public List findAllBuildings() { + log.debug("Called findAllBuildings"); + return cabinetRepository.findAllBuildings(); + } + + public List findAllFloorsByBuilding(String building) { + log.debug("Called findAllFloorsByBuilding: {}", building); + return cabinetRepository.findAllFloorsByBuilding(building); + } + + // deprecated + public List findAllSectionsByBuildingAndFloor(String building, Integer floor) { + log.debug("Called findAllSectionsByBuildingAndFloor: {}, {}", building, floor); + return cabinetRepository.findAllSectionsByBuildingAndFloor(building, floor); + } + + public List findAllPendingCabinetsByCabinetStatusAndBeforeEndedAt( + CabinetStatus cabinetStatus, + LocalDateTime currentDate) { + log.debug("Called findAllCabinetsByCabinetStatusAndBeforeEndedAt: {}", cabinetStatus); + return cabinetRepository.findAllCabinetsByCabinetStatusAndBeforeEndedAt(cabinetStatus, + currentDate); + } + + public Page findPaginationByLentType(LentType lentType, PageRequest pageable) { + log.debug("Called findPaginationByLentType: {}", lentType); + return cabinetRepository.findPaginationByLentType(lentType, pageable); + } + + public Page findPaginationByStatus(CabinetStatus status, PageRequest pageable) { + log.debug("Called findPaginationByStatus: {}", status); + return cabinetRepository.findPaginationByStatus(status, pageable); + } + + public Page findPaginationByVisibleNum(Integer visibleNum, PageRequest pageable) { + log.debug("Called findPaginationByVisibleNum: {}", visibleNum); + return cabinetRepository.findPaginationByVisibleNum(visibleNum, pageable); + } + + public List findAllCabinetsByLocation(Location location) { + log.debug("Called findAllCabinetsByLocation: {}", location); + return cabinetRepository.findAllCabinetsByLocation(location); + } + + public List findAllCabinetsByBuildingAndFloor(String building, Integer floor) { + return cabinetRepository.findAllByBuildingAndFloor(building, floor); + } + /*-------------------------------------------GET--------------------------------------------*/ + + + /** + * 사물함 ID로 변경 사항이 예정된 사물함을 찾습니다. + *

+ * X Lock을 획득한 상태로 가져옵니다. + * + * @param cabinetId 사물함 ID + * @return 사물함 엔티티 + * @throws ServiceException 사물함을 찾을 수 없는 경우 + */ + public Cabinet getCabinetForUpdate(Long cabinetId) { + log.debug("Called getCabinetForUpdate: {}", cabinetId); + return cabinetRepository.findByIdForUpdate(cabinetId) + .orElseThrow(() -> new ServiceException(ExceptionStatus.NOT_FOUND_CABINET)); + } + + /** + * 사물함 ID로 사물함을 찾습니다. + * + * @param cabinetId 사물함 ID + * @return 사물함 엔티티 + * @throws ServiceException 사물함을 찾을 수 없는 경우 + */ + public Cabinet getCabinet(Long cabinetId) { + log.debug("Called getCabinet: {}", cabinetId); + return cabinetRepository.findById(cabinetId) + .orElseThrow(() -> new ServiceException(ExceptionStatus.NOT_FOUND_CABINET)); + } + + /** + * 유저 ID로 사물함을 찾습니다. + * + * @param userId 유저ID + * @return 사물함 엔티티 + * @throws ServiceException 사물함을 찾을 수 없는 경우 + */ + public Cabinet getLentCabinetByUserId(Long userId) { + log.debug("Called getLentCabinetByUserId: {}", userId); + return cabinetRepository.findLentCabinetByUserId(userId) + .orElseThrow(() -> new ServiceException(ExceptionStatus.NOT_FOUND_CABINET)); + } + + /** + * 사물함 ID로 동아리 사물함을 찾습니다. + * + * @param cabinetId 사물함 ID + * @return 동아리 사물함 엔티티 + * @throws ServiceException 사물함을 찾을 수 없는 경우 + */ + public Cabinet getClubCabinet(Long cabinetId) { + log.debug("Called getClubCabinet: {}", cabinetId); + Cabinet cabinet = getCabinet(cabinetId); + if (!cabinet.isLentType(LentType.CLUB)) { + throw new ServiceException(ExceptionStatus.NOT_FOUND_CABINET); + } + return cabinet; + } + + /** + * 사물함 ID로 위치(빌딩, 층, 섹션) 정보를 찾습니다. + * + * @param cabinetId 사물함 ID + * @return 위치 엔티티 + * @throws ServiceException 사물함을 찾을 수 없는 경우 + */ + public Location getLocation(Long cabinetId) { + log.debug("Called getLocation: {}", cabinetId); + return cabinetRepository.findLocationById(cabinetId) + .orElseThrow(() -> new ServiceException(ExceptionStatus.NOT_FOUND_CABINET)); + } + + public List findPendingCabinets() { + log.debug("Called findPendingCabinets"); + return cabinetRepository.findPendingCabinets().orElse(null); + } } diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetRepository.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetRepository.java index 4a6c13fa7..96b45e737 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetRepository.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetRepository.java @@ -104,4 +104,9 @@ List findCabinetActiveLentHistoryUserListByBuildingAndFloor( "WHERE c.cabinetPlace.location.building = :building AND c.cabinetPlace.location.floor = :floor") List findAllByBuildingAndFloor(@Param("building") String building, @Param("floor") Integer floor); + + @Query("SELECT c.cabinetId " + + "FROM Cabinet c " + + "WHERE c.status = org.ftclub.cabinet.cabinet.domain.CabinetStatus.PENDING") + Optional> findPendingCabinets(); } diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeService.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeService.java index 0e7138ab6..81a105929 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeService.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeService.java @@ -8,6 +8,7 @@ import org.ftclub.cabinet.dto.CabinetInfoPaginationDto; import org.ftclub.cabinet.dto.CabinetInfoResponseDto; import org.ftclub.cabinet.dto.CabinetPaginationDto; +import org.ftclub.cabinet.dto.CabinetPendingResponseDto; import org.ftclub.cabinet.dto.CabinetSimplePaginationDto; import org.ftclub.cabinet.dto.CabinetStatusRequestDto; import org.ftclub.cabinet.dto.CabinetsPerSectionResponseDto; @@ -53,6 +54,7 @@ List getCabinetsPerSectionRefactor(String buildin Integer floor); List getCabinetsPerSectionDSL(String building, Integer floor); + /** * 사물함의 상태 메모를 업데이트합니다. * @@ -106,8 +108,8 @@ List getCabinetsPerSectionRefactor(String buildin * 대여 타입에 따른 사물함 페이지네이션을 가져옵니다. * * @param lentType 대여 타입 - * @param page 페이지 번호 - * @param size 페이지 당 보여줄 개수 + * @param page 페이지 번호 + * @param size 페이지 당 보여줄 개수 * @return 사물함 페이지네이션 */ CabinetPaginationDto getCabinetPaginationByLentType(LentType lentType, Integer page, @@ -116,9 +118,9 @@ CabinetPaginationDto getCabinetPaginationByLentType(LentType lentType, Integer p /** * 사물함 상태에 따른 사물함 페이지네이션을 가져옵니다. * - * @param status 사물함 상태 - * @param page 페이지 번호 - * @param size 페이지 당 보여줄 개수 + * @param status 사물함 상태 + * @param page 페이지 번호 + * @param size 페이지 당 보여줄 개수 * @return 사물함 페이지네이션 */ CabinetPaginationDto getCabinetPaginationByStatus(CabinetStatus status, Integer page, @@ -128,8 +130,8 @@ CabinetPaginationDto getCabinetPaginationByStatus(CabinetStatus status, Integer * 사물함 표시 번호에 따른 사물함 페이지네이션을 가져옵니다. * * @param visibleNum 사물함 표시 번호 - * @param page 페이지 번호 - * @param size 페이지 당 보여줄 개수 + * @param page 페이지 번호 + * @param size 페이지 당 보여줄 개수 * @return 사물함 페이지네이션 */ CabinetPaginationDto getCabinetPaginationByVisibleNum(Integer visibleNum, Integer page, @@ -139,7 +141,7 @@ CabinetPaginationDto getCabinetPaginationByVisibleNum(Integer visibleNum, Intege * 사물함 Id에 따른 대여 기록 페이지네이션을 가져옵니다. * * @param cabinetId 사물함 Id - * @param page 페이지네이션(page, size) + * @param page 페이지네이션(page, size) * @return 대여 기록 페이지네이션 */ LentHistoryPaginationDto getCabinetLentHistoriesPagination(Long cabinetId, @@ -147,10 +149,13 @@ LentHistoryPaginationDto getCabinetLentHistoriesPagination(Long cabinetId, Integer size); /** - * 사물함에 동아 - * * @param clubStatusRequestDto */ void updateCabinetClubStatus(CabinetClubStatusRequestDto clubStatusRequestDto); + /** + * @return 오픈 예정인 사물함 정보 + */ + CabinetPendingResponseDto getPendingCabinets(); + } diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java index 4c1142076..51c0156ec 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java @@ -21,6 +21,7 @@ import org.ftclub.cabinet.dto.CabinetInfoPaginationDto; import org.ftclub.cabinet.dto.CabinetInfoResponseDto; import org.ftclub.cabinet.dto.CabinetPaginationDto; +import org.ftclub.cabinet.dto.CabinetPendingResponseDto; import org.ftclub.cabinet.dto.CabinetPreviewDto; import org.ftclub.cabinet.dto.CabinetSimpleDto; import org.ftclub.cabinet.dto.CabinetSimplePaginationDto; @@ -468,6 +469,20 @@ public void updateCabinetClubStatus(CabinetClubStatusRequestDto cabinetClubStatu cabinetClubStatusRequestDto.getStatusNote()); } + @Override + @Transactional + public CabinetPendingResponseDto getPendingCabinets() { + log.debug("getPendingCabinets"); + List cabinetInfoResponseDtos = new ArrayList<>(); + // pending 상태인 사물함들의 cabinetId를 가져온다. + List pendingCabinetsId = cabinetOptionalFetcher.findPendingCabinets(); + // 해당 cabinetId들을 이용해 순회를 돌면서 cabinetInfoResponseDto를 가져온다. + for (Long pendingCabinetId : pendingCabinetsId) { + cabinetInfoResponseDtos.add(getCabinetInfo(pendingCabinetId)); + } + return new CabinetPendingResponseDto(cabinetInfoResponseDtos); + } + // /** // * {@inheritDoc} // */ diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetService.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetService.java index 6e291387b..f7041c260 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetService.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetService.java @@ -98,4 +98,10 @@ public interface CabinetService { void updateStatusNote(Long cabinetId, String statusNote); void updateClub(Long cabinetId, Long userId, String statusNote); + +// /** +// * +// * @return pending 상태인 사물함들의 cabinetId 리스트 +// */ +// List getPendingCabinets(); } diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetServiceImpl.java index dafc83f52..e9e7fd168 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetServiceImpl.java @@ -165,4 +165,9 @@ public void updateClub(Long cabinetId, Long userId, String statusNote) { cabinet.writeStatusNote(statusNote); cabinet.specifyLentType(LentType.CLUB); } + +// @Override +// public List getPendingCabinets() { +// return cabinetOptionalFetcher.findPendingCabinets(); +// } } diff --git a/config b/config index f069d1c59..a067cf29d 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit f069d1c5934a96ed3c78121b365c10965bb1fc20 +Subproject commit a067cf29d4d5860db60e1ef8ef5141b4e0ab0682 From f73ddae10f7b2b6d21fb7905dd7b3dabb49c5979 Mon Sep 17 00:00:00 2001 From: ldw Date: Mon, 20 Nov 2023 16:05:06 +0900 Subject: [PATCH 03/24] =?UTF-8?q?[BE]=20FEAT:=20pending=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=EC=9D=B8=20=EC=82=AC=EB=AC=BC=ED=95=A8=EB=93=A4?= =?UTF-8?q?=EC=9D=98=20CabinetInfoResponseDto=EB=A5=BC=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=ED=95=98=EB=8A=94=20Dto=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cabinet/dto/CabinetPendingResponseDto.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 backend/src/main/java/org/ftclub/cabinet/dto/CabinetPendingResponseDto.java diff --git a/backend/src/main/java/org/ftclub/cabinet/dto/CabinetPendingResponseDto.java b/backend/src/main/java/org/ftclub/cabinet/dto/CabinetPendingResponseDto.java new file mode 100644 index 000000000..601c8227d --- /dev/null +++ b/backend/src/main/java/org/ftclub/cabinet/dto/CabinetPendingResponseDto.java @@ -0,0 +1,14 @@ +package org.ftclub.cabinet.dto; + +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.ToString; + +@AllArgsConstructor +@Getter +@ToString +public class CabinetPendingResponseDto { + + private final List cabinetInfoResponseDtos; +} From 5ae78389981d291249ba958635c5378324e0058d Mon Sep 17 00:00:00 2001 From: ldw Date: Mon, 20 Nov 2023 17:16:47 +0900 Subject: [PATCH 04/24] =?UTF-8?q?[BE]=20FEAT:=20=EC=B8=B5=20=EB=B3=84?= =?UTF-8?q?=EB=A1=9C=20pending=20=EC=83=81=ED=83=9C=EC=9D=B8=20=EC=82=AC?= =?UTF-8?q?=EB=AC=BC=ED=95=A8=EB=93=A4=EC=9D=98=20CabinetPreviewDto?= =?UTF-8?q?=EB=A5=BC=20=EC=A0=80=EC=9E=A5=ED=95=98=EB=8A=94=20Dto=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cabinet/controller/CabinetController.java | 2 +- .../repository/CabinetOptionalFetcher.java | 4 ++-- .../cabinet/repository/CabinetRepository.java | 4 ++-- .../service/CabinetFacadeServiceImpl.java | 20 ++++++++++++------- .../cabinet/service/CabinetService.java | 9 +++------ .../cabinet/service/CabinetServiceImpl.java | 9 ++++----- .../dto/CabinetPendingResponseDto.java | 2 +- 7 files changed, 26 insertions(+), 24 deletions(-) diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java index 544943333..19d98ba7e 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java @@ -71,7 +71,7 @@ public CabinetInfoResponseDto getCabinetInfo( } @GetMapping("/pending") - @AuthGuard(level = AuthLevel.USER_OR_ADMIN) +// @AuthGuard(level = AuthLevel.USER_OR_ADMIN) public CabinetPendingResponseDto getPendingCabinets() { log.info("Called getPendingCabinets"); return cabinetFacadeService.getPendingCabinets(); diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java index 17e9238cd..273e12b53 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java @@ -194,8 +194,8 @@ public Location getLocation(Long cabinetId) { .orElseThrow(() -> new ServiceException(ExceptionStatus.NOT_FOUND_CABINET)); } - public List findPendingCabinets() { + public List findPendingCabinets(Integer floor) { log.debug("Called findPendingCabinets"); - return cabinetRepository.findPendingCabinets().orElse(null); + return cabinetRepository.findPendingCabinets(floor).orElse(null); } } diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetRepository.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetRepository.java index 96b45e737..107d10880 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetRepository.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetRepository.java @@ -107,6 +107,6 @@ List findAllByBuildingAndFloor(@Param("building") String building, @Query("SELECT c.cabinetId " + "FROM Cabinet c " + - "WHERE c.status = org.ftclub.cabinet.cabinet.domain.CabinetStatus.PENDING") - Optional> findPendingCabinets(); + "WHERE c.status = org.ftclub.cabinet.cabinet.domain.CabinetStatus.PENDING AND c.cabinetPlace.location.floor = :floor") + Optional> findPendingCabinets(@Param("floor") Integer floor); } diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java index 51c0156ec..7302fc642 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java @@ -473,14 +473,20 @@ public void updateCabinetClubStatus(CabinetClubStatusRequestDto cabinetClubStatu @Transactional public CabinetPendingResponseDto getPendingCabinets() { log.debug("getPendingCabinets"); - List cabinetInfoResponseDtos = new ArrayList<>(); - // pending 상태인 사물함들의 cabinetId를 가져온다. - List pendingCabinetsId = cabinetOptionalFetcher.findPendingCabinets(); - // 해당 cabinetId들을 이용해 순회를 돌면서 cabinetInfoResponseDto를 가져온다. - for (Long pendingCabinetId : pendingCabinetsId) { - cabinetInfoResponseDtos.add(getCabinetInfo(pendingCabinetId)); + List> cabinetPreviewDtos = new ArrayList<>(); + for (int i = 2; i <= 5; i++) { + List cabinetPreviewDtoList = new ArrayList<>(); + // pending 상태인 사물함들의 cabinetId를 가져온다. + List pendingCabinetsIdByFloor = cabinetOptionalFetcher.findPendingCabinets(i); + // 해당 cabinetId들을 이용해 순회를 돌면서 cabinetInfoResponseDto를 가져온다. + for (Long pendingCabinetId : pendingCabinetsIdByFloor) { + cabinetPreviewDtoList.add(cabinetMapper.toCabinetPreviewDto(cabinetOptionalFetcher.findCabinet(pendingCabinetId), + 0, "")); + } + cabinetPreviewDtos.add(cabinetPreviewDtoList); } - return new CabinetPendingResponseDto(cabinetInfoResponseDtos); + + return new CabinetPendingResponseDto(cabinetPreviewDtos); } // /** diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetService.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetService.java index f7041c260..247688aac 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetService.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetService.java @@ -4,6 +4,9 @@ import org.ftclub.cabinet.cabinet.domain.CabinetStatus; import org.ftclub.cabinet.cabinet.domain.Grid; import org.ftclub.cabinet.cabinet.domain.LentType; +import org.ftclub.cabinet.dto.CabinetInfoResponseDto; + +import java.util.List; public interface CabinetService { @@ -98,10 +101,4 @@ public interface CabinetService { void updateStatusNote(Long cabinetId, String statusNote); void updateClub(Long cabinetId, Long userId, String statusNote); - -// /** -// * -// * @return pending 상태인 사물함들의 cabinetId 리스트 -// */ -// List getPendingCabinets(); } diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetServiceImpl.java index e9e7fd168..280c78405 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetServiceImpl.java @@ -9,6 +9,7 @@ import org.ftclub.cabinet.cabinet.domain.LentType; import org.ftclub.cabinet.cabinet.repository.CabinetOptionalFetcher; import org.ftclub.cabinet.config.CabinetProperties; +import org.ftclub.cabinet.dto.CabinetInfoResponseDto; import org.ftclub.cabinet.exception.ExceptionStatus; import org.ftclub.cabinet.exception.ServiceException; import org.ftclub.cabinet.lent.repository.LentOptionalFetcher; @@ -16,6 +17,9 @@ import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; +import java.util.ArrayList; +import java.util.List; + @Service @RequiredArgsConstructor @Transactional @@ -165,9 +169,4 @@ public void updateClub(Long cabinetId, Long userId, String statusNote) { cabinet.writeStatusNote(statusNote); cabinet.specifyLentType(LentType.CLUB); } - -// @Override -// public List getPendingCabinets() { -// return cabinetOptionalFetcher.findPendingCabinets(); -// } } diff --git a/backend/src/main/java/org/ftclub/cabinet/dto/CabinetPendingResponseDto.java b/backend/src/main/java/org/ftclub/cabinet/dto/CabinetPendingResponseDto.java index 601c8227d..cc2a0f18e 100644 --- a/backend/src/main/java/org/ftclub/cabinet/dto/CabinetPendingResponseDto.java +++ b/backend/src/main/java/org/ftclub/cabinet/dto/CabinetPendingResponseDto.java @@ -10,5 +10,5 @@ @ToString public class CabinetPendingResponseDto { - private final List cabinetInfoResponseDtos; + private final List> cabinetInfoResponseDtos; } From 287e22b6208f9020a9dfa393ad03dd82a3d13ff1 Mon Sep 17 00:00:00 2001 From: ldw Date: Tue, 21 Nov 2023 22:12:23 +0900 Subject: [PATCH 05/24] =?UTF-8?q?[BE]=20DOCS:=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cabinet/cabinet/controller/CabinetController.java | 6 ++++++ .../cabinet/cabinet/repository/CabinetOptionalFetcher.java | 6 ++++++ .../cabinet/cabinet/service/CabinetFacadeService.java | 2 ++ .../cabinet/cabinet/service/CabinetFacadeServiceImpl.java | 6 +++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java index 19d98ba7e..8a68830f3 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java @@ -70,6 +70,12 @@ public CabinetInfoResponseDto getCabinetInfo( return cabinetFacadeService.getCabinetInfo(cabinetId); } + /** + * 오픈 예정인 사물함들의 정보를 가져옵니다. + * + * @return 오픈 예정인 사물함들의 정보를 반환합니다. + */ + @GetMapping("/pending") // @AuthGuard(level = AuthLevel.USER_OR_ADMIN) public CabinetPendingResponseDto getPendingCabinets() { diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java index 273e12b53..c99a7e71b 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java @@ -194,6 +194,12 @@ public Location getLocation(Long cabinetId) { .orElseThrow(() -> new ServiceException(ExceptionStatus.NOT_FOUND_CABINET)); } + /** + * 충별로 오픈 예정인 사물함들을 찾습니다. + * @param floor 층 + * @return 오픈 예정인 사물함들의 ID 리스트 + */ + public List findPendingCabinets(Integer floor) { log.debug("Called findPendingCabinets"); return cabinetRepository.findPendingCabinets(floor).orElse(null); diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeService.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeService.java index 81a105929..1c1c19a89 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeService.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeService.java @@ -154,6 +154,8 @@ LentHistoryPaginationDto getCabinetLentHistoriesPagination(Long cabinetId, void updateCabinetClubStatus(CabinetClubStatusRequestDto clubStatusRequestDto); /** + * 오픈 예정인 사물함 정보를 층별로 가져옵니다. + * * @return 오픈 예정인 사물함 정보 */ CabinetPendingResponseDto getPendingCabinets(); diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java index 7302fc642..04e39c376 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java @@ -469,6 +469,10 @@ public void updateCabinetClubStatus(CabinetClubStatusRequestDto cabinetClubStatu cabinetClubStatusRequestDto.getStatusNote()); } + /** + * {@inheritDoc} + */ + @Override @Transactional public CabinetPendingResponseDto getPendingCabinets() { @@ -478,7 +482,7 @@ public CabinetPendingResponseDto getPendingCabinets() { List cabinetPreviewDtoList = new ArrayList<>(); // pending 상태인 사물함들의 cabinetId를 가져온다. List pendingCabinetsIdByFloor = cabinetOptionalFetcher.findPendingCabinets(i); - // 해당 cabinetId들을 이용해 순회를 돌면서 cabinetInfoResponseDto를 가져온다. + // 순회를 돌면서 cabinetPreviewDto를 가져온다. for (Long pendingCabinetId : pendingCabinetsIdByFloor) { cabinetPreviewDtoList.add(cabinetMapper.toCabinetPreviewDto(cabinetOptionalFetcher.findCabinet(pendingCabinetId), 0, "")); From 8fecbddb9405ba09592d01f31d364b0eab6f8aea Mon Sep 17 00:00:00 2001 From: ldw Date: Wed, 22 Nov 2023 01:34:44 +0900 Subject: [PATCH 06/24] =?UTF-8?q?[BE]=20REFACTOR:=20auth=20guard=20?= =?UTF-8?q?=EC=9E=AC=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cabinet/controller/CabinetController.java | 3 +- .../service/CabinetFacadeServiceImpl.java | 47 +++++++++---------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java index 8a68830f3..4bed18d30 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/controller/CabinetController.java @@ -75,9 +75,8 @@ public CabinetInfoResponseDto getCabinetInfo( * * @return 오픈 예정인 사물함들의 정보를 반환합니다. */ - @GetMapping("/pending") -// @AuthGuard(level = AuthLevel.USER_OR_ADMIN) + @AuthGuard(level = AuthLevel.USER_OR_ADMIN) public CabinetPendingResponseDto getPendingCabinets() { log.info("Called getPendingCabinets"); return cabinetFacadeService.getPendingCabinets(); diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java index 04e39c376..9046b31e1 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java @@ -399,6 +399,29 @@ private List generateLentHistoryDtoList( .collect(Collectors.toList()); } + /** + * {@inheritDoc} + */ + @Override + @Transactional + public CabinetPendingResponseDto getPendingCabinets() { + log.debug("getPendingCabinets"); + List> cabinetPreviewDtos = new ArrayList<>(); + for (int i = 2; i <= 5; i++) { + List cabinetPreviewDtoList = new ArrayList<>(); + // pending 상태인 사물함들의 cabinetId를 가져온다. + List pendingCabinetsIdByFloor = cabinetOptionalFetcher.findPendingCabinets(i); + // 순회를 돌면서 cabinetPreviewDto를 가져온다. + for (Long pendingCabinetId : pendingCabinetsIdByFloor) { + cabinetPreviewDtoList.add(cabinetMapper.toCabinetPreviewDto(cabinetOptionalFetcher.findCabinet(pendingCabinetId), + 0, "")); + } + cabinetPreviewDtos.add(cabinetPreviewDtoList); + } + + return new CabinetPendingResponseDto(cabinetPreviewDtos); + } + /*--------------------------------------------CUD--------------------------------------------*/ /** @@ -469,30 +492,6 @@ public void updateCabinetClubStatus(CabinetClubStatusRequestDto cabinetClubStatu cabinetClubStatusRequestDto.getStatusNote()); } - /** - * {@inheritDoc} - */ - - @Override - @Transactional - public CabinetPendingResponseDto getPendingCabinets() { - log.debug("getPendingCabinets"); - List> cabinetPreviewDtos = new ArrayList<>(); - for (int i = 2; i <= 5; i++) { - List cabinetPreviewDtoList = new ArrayList<>(); - // pending 상태인 사물함들의 cabinetId를 가져온다. - List pendingCabinetsIdByFloor = cabinetOptionalFetcher.findPendingCabinets(i); - // 순회를 돌면서 cabinetPreviewDto를 가져온다. - for (Long pendingCabinetId : pendingCabinetsIdByFloor) { - cabinetPreviewDtoList.add(cabinetMapper.toCabinetPreviewDto(cabinetOptionalFetcher.findCabinet(pendingCabinetId), - 0, "")); - } - cabinetPreviewDtos.add(cabinetPreviewDtoList); - } - - return new CabinetPendingResponseDto(cabinetPreviewDtos); - } - // /** // * {@inheritDoc} // */ From 61085e7d5f244b544689fe9363767b0248075c97 Mon Sep 17 00:00:00 2001 From: ldw Date: Wed, 22 Nov 2023 16:27:18 +0900 Subject: [PATCH 07/24] =?UTF-8?q?[BE]=20FIX:=20=EC=B8=B5=20=EB=B3=84?= =?UTF-8?q?=EB=A1=9C=20=EB=B9=84=EC=96=B4=EC=9E=88=EB=8A=94=20=EC=82=AC?= =?UTF-8?q?=EB=AC=BC=ED=95=A8=EC=97=90=20=EB=8C=80=ED=95=9C=20cabinetPrevi?= =?UTF-8?q?ewDto=EB=8F=84=20=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cabinet/cabinet/repository/CabinetOptionalFetcher.java | 5 +++++ .../cabinet/cabinet/repository/CabinetRepository.java | 5 +++++ .../cabinet/cabinet/service/CabinetFacadeServiceImpl.java | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java index c99a7e71b..db75da8ef 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetOptionalFetcher.java @@ -204,4 +204,9 @@ public List findPendingCabinets(Integer floor) { log.debug("Called findPendingCabinets"); return cabinetRepository.findPendingCabinets(floor).orElse(null); } + + public List findAvailableCabinets(Integer floor) { + log.debug("Called findAvailableCabinets"); + return cabinetRepository.findAvailableCabinets(floor).orElse(null); + } } diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetRepository.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetRepository.java index 107d10880..dfd7a2d29 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetRepository.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/repository/CabinetRepository.java @@ -109,4 +109,9 @@ List findAllByBuildingAndFloor(@Param("building") String building, "FROM Cabinet c " + "WHERE c.status = org.ftclub.cabinet.cabinet.domain.CabinetStatus.PENDING AND c.cabinetPlace.location.floor = :floor") Optional> findPendingCabinets(@Param("floor") Integer floor); + + @Query("SELECT c.cabinetId " + + "FROM Cabinet c " + + "WHERE c.status = org.ftclub.cabinet.cabinet.domain.CabinetStatus.AVAILABLE AND c.cabinetPlace.location.floor = :floor") + Optional> findAvailableCabinets(@Param("floor") Integer floor); } diff --git a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java index 9046b31e1..7b573f70c 100644 --- a/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/cabinet/service/CabinetFacadeServiceImpl.java @@ -416,6 +416,12 @@ public CabinetPendingResponseDto getPendingCabinets() { cabinetPreviewDtoList.add(cabinetMapper.toCabinetPreviewDto(cabinetOptionalFetcher.findCabinet(pendingCabinetId), 0, "")); } + // available 상태인 사물함들의 cabinetId를 가져온다. + List availableCabinetsIdByFloor = cabinetOptionalFetcher.findAvailableCabinets(i); + for (Long availableCabinetId : availableCabinetsIdByFloor) { + cabinetPreviewDtoList.add(cabinetMapper.toCabinetPreviewDto(cabinetOptionalFetcher.findCabinet(availableCabinetId), + 0, "")); + } cabinetPreviewDtos.add(cabinetPreviewDtoList); } From b95ff8ee30dc1f82015a019879ce7a4b3572e5a8 Mon Sep 17 00:00:00 2001 From: ldw Date: Fri, 24 Nov 2023 16:48:06 +0900 Subject: [PATCH 08/24] =?UTF-8?q?[BE]=20FIX=20:=20v4/users/me=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=B0=98=ED=99=98=ED=95=98=EB=8A=94=20MyProfileRes?= =?UTF-8?q?ponseDto=EC=97=90=20LentExtension=20=ED=95=84=EB=93=9C=EB=A5=BC?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=ED=95=98=EB=8F=84=EB=A1=9D=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 --- .../ftclub/cabinet/dto/MyProfileResponseDto.java | 3 ++- .../org/ftclub/cabinet/mapper/UserMapper.java | 3 ++- .../user/service/UserFacadeServiceImpl.java | 16 +++++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/org/ftclub/cabinet/dto/MyProfileResponseDto.java b/backend/src/main/java/org/ftclub/cabinet/dto/MyProfileResponseDto.java index 141197781..f59017242 100644 --- a/backend/src/main/java/org/ftclub/cabinet/dto/MyProfileResponseDto.java +++ b/backend/src/main/java/org/ftclub/cabinet/dto/MyProfileResponseDto.java @@ -3,6 +3,7 @@ import java.time.LocalDateTime; import lombok.AllArgsConstructor; import lombok.Getter; +import org.ftclub.cabinet.user.domain.LentExtension; /** * 내 프로필 정보와 대여 중인 사물함의 ID를 반환하는 DTO입니다. @@ -15,5 +16,5 @@ public class MyProfileResponseDto { private final String name; private final Long cabinetId; private final LocalDateTime unbannedAt; - private final boolean extensible; + private final LentExtension lentExtension; } diff --git a/backend/src/main/java/org/ftclub/cabinet/mapper/UserMapper.java b/backend/src/main/java/org/ftclub/cabinet/mapper/UserMapper.java index 8d9bcca88..d32998328 100644 --- a/backend/src/main/java/org/ftclub/cabinet/mapper/UserMapper.java +++ b/backend/src/main/java/org/ftclub/cabinet/mapper/UserMapper.java @@ -36,9 +36,10 @@ public interface UserMapper { UserProfileDto toUserProfileDto(User user); @Mapping(target = "userId", source = "user.userId") + @Mapping(target = "name", source = "user.name") @Mapping(target = "cabinetId", source = "cabinet.cabinetId") MyProfileResponseDto toMyProfileResponseDto(UserSessionDto user, Cabinet cabinet, - BanHistory banHistory, boolean extensible); + BanHistory banHistory, LentExtension lentExtension); BlockedUserPaginationDto toBlockedUserPaginationDto(List result, Long totalLength); diff --git a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java index edddbb782..5daccdf7f 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java @@ -60,13 +60,15 @@ public MyProfileResponseDto getMyProfile(UserSessionDto user) { Cabinet cabinet = lentOptionalFetcher.findActiveLentCabinetByUserId(user.getUserId()); BanHistory banHistory = userOptionalFetcher.findRecentActiveBanHistory(user.getUserId(), LocalDateTime.now()); - List lentExtensionNotExpiredByUserId = - lentExtensionOptionalFetcher.findLentExtensionByUserId(user.getUserId()) - .stream().filter(lentExtension -> lentExtension.getUsedAt() == null - && lentExtension.getExpiredAt().isAfter(LocalDateTime.now())) - .collect(Collectors.toList()); - boolean isLentExtensionAvailable = !lentExtensionNotExpiredByUserId.isEmpty(); - return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, isLentExtensionAvailable); + LentExtension lentExtension = lentExtensionOptionalFetcher.findLentExtensionByUserId( + user.getUserId()).get(0); +// List lentExtensionNotExpiredByUserId = +// lentExtensionOptionalFetcher.findLentExtensionByUserId(user.getUserId()) +// .stream().filter(lentExtension -> lentExtension.getUsedAt() == null +// && lentExtension.getExpiredAt().isAfter(LocalDateTime.now())) +// .collect(Collectors.toList()); +// boolean isLentExtensionAvailable = !lentExtensionNotExpiredByUserId.isEmpty(); + return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, lentExtension); } @Override From 2ce80051699709b5a570e1582684044e898847bf Mon Sep 17 00:00:00 2001 From: ldw Date: Fri, 24 Nov 2023 16:51:02 +0900 Subject: [PATCH 09/24] =?UTF-8?q?[BE]=20TEST=20:=20getMyProfile=20?= =?UTF-8?q?=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=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 --- .../user/service/UserFacadeServiceTest.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/backend/src/test/java/org/ftclub/cabinet/user/service/UserFacadeServiceTest.java b/backend/src/test/java/org/ftclub/cabinet/user/service/UserFacadeServiceTest.java index ce39e04b7..98bdf641c 100644 --- a/backend/src/test/java/org/ftclub/cabinet/user/service/UserFacadeServiceTest.java +++ b/backend/src/test/java/org/ftclub/cabinet/user/service/UserFacadeServiceTest.java @@ -12,8 +12,10 @@ import org.ftclub.cabinet.mapper.UserMapper; import org.ftclub.cabinet.user.domain.AdminRole; import org.ftclub.cabinet.user.domain.BanHistory; +import org.ftclub.cabinet.user.domain.LentExtension; import org.ftclub.cabinet.user.domain.User; import org.ftclub.cabinet.user.domain.UserRole; +import org.ftclub.cabinet.user.repository.LentExtensionOptionalFetcher; import org.ftclub.cabinet.user.repository.UserOptionalFetcher; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; @@ -76,6 +78,8 @@ public class UserFacadeServiceTest { private UserOptionalFetcher userOptionalFetcher; @Mock private CabinetOptionalFetcher cabinetOptionalFetcher; + @Mock + private LentExtensionOptionalFetcher lentExtensionOptionalFetcher; @Mock(lenient = true) private LentOptionalFetcher lentOptionalFetcher; @@ -98,10 +102,15 @@ public class UserFacadeServiceTest { given(lentOptionalFetcher.findActiveLentCabinetByUserId(1L)).willReturn(cabinet1); given(userOptionalFetcher.findRecentActiveBanHistory(1L, LocalDateTime.now())) .willReturn(null); + given(lentExtensionOptionalFetcher.findLentExtensionByUserId(userSessionDto.getUserId())) + .willReturn(null); + + LentExtension lentExtension = lentExtensionOptionalFetcher.findLentExtensionByUserId( + userSessionDto.getUserId()).get(0); MyProfileResponseDto myProfileResponseDto = new MyProfileResponseDto( userSessionDto.getUserId(), userSessionDto.getName(), - cabinet1.getCabinetId(), null, true); - given(userMapper.toMyProfileResponseDto(userSessionDto, cabinet1, null, true)) + cabinet1.getCabinetId(), null, lentExtension); + given(userMapper.toMyProfileResponseDto(userSessionDto, cabinet1, null, lentExtension)) .willReturn(myProfileResponseDto); // when @@ -126,8 +135,14 @@ public class UserFacadeServiceTest { given(lentOptionalFetcher.findActiveLentCabinetByUserId(2L)).willReturn(null); given(userOptionalFetcher.findRecentActiveBanHistory(eq(2L), any())).willReturn( banHistory1); - given(userMapper.toMyProfileResponseDto(userSessionDto, null, banHistory1, true)).willReturn( - new MyProfileResponseDto(2L, "testUser2", null, testDate.plusDays(1), true)); + given(lentExtensionOptionalFetcher.findLentExtensionByUserId(userSessionDto.getUserId())) + .willReturn(null); + + LentExtension lentExtension = lentExtensionOptionalFetcher.findLentExtensionByUserId( + userSessionDto.getUserId()).get(0); + + given(userMapper.toMyProfileResponseDto(userSessionDto, null, banHistory1, lentExtension)).willReturn( + new MyProfileResponseDto(2L, "testUser2", null, testDate.plusDays(1), lentExtension)); // when MyProfileResponseDto myProfile = userFacadeService.getMyProfile(userSessionDto); From d6d6954b292670fd76e92879640583a94d1360bf Mon Sep 17 00:00:00 2001 From: ldw Date: Fri, 24 Nov 2023 17:05:56 +0900 Subject: [PATCH 10/24] =?UTF-8?q?[BE]=20REFACTOR=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ftclub/cabinet/user/service/UserFacadeServiceImpl.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java index 5daccdf7f..e539b476a 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java @@ -62,12 +62,6 @@ public MyProfileResponseDto getMyProfile(UserSessionDto user) { LocalDateTime.now()); LentExtension lentExtension = lentExtensionOptionalFetcher.findLentExtensionByUserId( user.getUserId()).get(0); -// List lentExtensionNotExpiredByUserId = -// lentExtensionOptionalFetcher.findLentExtensionByUserId(user.getUserId()) -// .stream().filter(lentExtension -> lentExtension.getUsedAt() == null -// && lentExtension.getExpiredAt().isAfter(LocalDateTime.now())) -// .collect(Collectors.toList()); -// boolean isLentExtensionAvailable = !lentExtensionNotExpiredByUserId.isEmpty(); return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, lentExtension); } From cb7a4b01c15a6defa5f7c99349203d43587e43e1 Mon Sep 17 00:00:00 2001 From: ldw Date: Fri, 24 Nov 2023 18:33:21 +0900 Subject: [PATCH 11/24] =?UTF-8?q?[BE]=20FIX=20:=20=EC=97=B0=EC=9E=A5?= =?UTF-8?q?=EA=B6=8C=EC=9D=B4=20=EC=97=86=EC=9D=84=20=EB=95=8C=20=EB=B0=9C?= =?UTF-8?q?=EC=83=9D=ED=95=98=EB=8A=94=20indexOutOfBound=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ftclub/cabinet/user/service/UserFacadeServiceImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java index e539b476a..72e32af9f 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java @@ -60,9 +60,10 @@ public MyProfileResponseDto getMyProfile(UserSessionDto user) { Cabinet cabinet = lentOptionalFetcher.findActiveLentCabinetByUserId(user.getUserId()); BanHistory banHistory = userOptionalFetcher.findRecentActiveBanHistory(user.getUserId(), LocalDateTime.now()); - LentExtension lentExtension = lentExtensionOptionalFetcher.findLentExtensionByUserId( - user.getUserId()).get(0); - return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, lentExtension); + List lentExtension = lentExtensionOptionalFetcher.findLentExtensionByUserId(user.getUserId()); + if (lentExtension.isEmpty()) + return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, null); + return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, lentExtension.get(0)); } @Override From 6b4fcee78343077777aa99545b511bc7ecfca26f Mon Sep 17 00:00:00 2001 From: jusohn Date: Fri, 24 Nov 2023 19:08:28 +0900 Subject: [PATCH 12/24] =?UTF-8?q?[FE]=20FEAT:=20/users/me=20=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=B0=9B=EC=95=84=EC=98=A4=EB=8A=94=20lentHistory?= =?UTF-8?q?=20=EB=A5=BC=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95=20#1424?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CabinetInfoArea/CabinetInfoArea.container.tsx | 2 +- .../ExtensionCard/ExtensionCard.container.tsx | 13 +++++++++---- .../Card/ExtensionCard/ExtensionCard.tsx | 15 ++++++++------- .../components/Modals/ExtendModal/ExtendModal.tsx | 2 +- frontend/src/pages/ProfilePage.tsx | 2 +- frontend/src/recoil/atoms.ts | 2 +- frontend/src/types/dto/lent.dto.ts | 8 ++++++++ frontend/src/types/dto/user.dto.ts | 5 +++-- 8 files changed, 32 insertions(+), 17 deletions(-) diff --git a/frontend/src/components/CabinetInfoArea/CabinetInfoArea.container.tsx b/frontend/src/components/CabinetInfoArea/CabinetInfoArea.container.tsx index 4434d1b6f..17cbb4a76 100644 --- a/frontend/src/components/CabinetInfoArea/CabinetInfoArea.container.tsx +++ b/frontend/src/components/CabinetInfoArea/CabinetInfoArea.container.tsx @@ -331,7 +331,7 @@ const CabinetInfoAreaContainer = (): JSX.Element => { cabinetViewData?.status === "IN_SESSION") && !myCabinetInfo.cabinetId } - isExtensible={myInfo.extensible} + isExtensible={!!myInfo.extensionInfo} userModal={userModal} openModal={openModal} closeModal={closeModal} diff --git a/frontend/src/components/Card/ExtensionCard/ExtensionCard.container.tsx b/frontend/src/components/Card/ExtensionCard/ExtensionCard.container.tsx index 4eea4b1dd..640976c33 100644 --- a/frontend/src/components/Card/ExtensionCard/ExtensionCard.container.tsx +++ b/frontend/src/components/Card/ExtensionCard/ExtensionCard.container.tsx @@ -1,14 +1,19 @@ import ExtensionCard from "@/components/Card/ExtensionCard/ExtensionCard"; +import { LentExtensionDto } from "@/types/dto/lent.dto"; -const ExtensionCardContainer = ({ extensible }: { extensible: boolean }) => { +const ExtensionCardContainer = ({ + extensionInfo, +}: { + extensionInfo: LentExtensionDto | null; +}) => { return ( {}, isClickable: false, - isExtensible: extensible, + isExtensible: !!extensionInfo, }} /> ); diff --git a/frontend/src/components/Card/ExtensionCard/ExtensionCard.tsx b/frontend/src/components/Card/ExtensionCard/ExtensionCard.tsx index 592f0c9d6..737c918f8 100644 --- a/frontend/src/components/Card/ExtensionCard/ExtensionCard.tsx +++ b/frontend/src/components/Card/ExtensionCard/ExtensionCard.tsx @@ -5,14 +5,15 @@ import { ContentDeatilStyled, ContentInfoStyled, } from "@/components/Card/CardStyles"; -import { getLastDayofMonthString } from "@/utils/dateUtils"; +import { LentExtensionDto } from "@/types/dto/lent.dto"; +import { formatDate, getLastDayofMonthString } from "@/utils/dateUtils"; interface ExtensionProps { - extensible: boolean; + extensionInfo: LentExtensionDto | null; button: IButtonProps; } -const ExtensionCard = ({ extensible, button }: ExtensionProps) => { +const ExtensionCard = ({ extensionInfo, button }: ExtensionProps) => { return ( { 사용 기한 - {extensible ? getLastDayofMonthString(null, ".") : "-"} + {!!extensionInfo + ? formatDate(new Date(extensionInfo.expiredAt), ".") + : "-"} 연장 기간 - {extensible - ? parseInt(import.meta.env.VITE_EXTENDED_LENT_PERIOD) + "일" - : "-"} + {!!extensionInfo ? extensionInfo.extensionPeriod + "일" : "-"} diff --git a/frontend/src/components/Modals/ExtendModal/ExtendModal.tsx b/frontend/src/components/Modals/ExtendModal/ExtendModal.tsx index 06f9cba64..334aa1f24 100644 --- a/frontend/src/components/Modals/ExtendModal/ExtendModal.tsx +++ b/frontend/src/components/Modals/ExtendModal/ExtendModal.tsx @@ -79,7 +79,7 @@ const ExtendModal: React.FC<{ setMyInfo({ ...myInfo, cabinetId: currentCabinetId, - extensible: false, + lentExtension: null, }); setIsCurrentSectionRender(true); setModalTitle("연장되었습니다"); diff --git a/frontend/src/pages/ProfilePage.tsx b/frontend/src/pages/ProfilePage.tsx index d1b48d68f..405edc0e8 100644 --- a/frontend/src/pages/ProfilePage.tsx +++ b/frontend/src/pages/ProfilePage.tsx @@ -36,7 +36,7 @@ const ProfilePage = () => { ) : ( - + diff --git a/frontend/src/recoil/atoms.ts b/frontend/src/recoil/atoms.ts index dc1fa709b..f966ad803 100644 --- a/frontend/src/recoil/atoms.ts +++ b/frontend/src/recoil/atoms.ts @@ -21,7 +21,7 @@ export const userState = atom({ cabinetId: null, userId: null, name: "default", - extensible: false, + lentExtension: null, }, }); diff --git a/frontend/src/types/dto/lent.dto.ts b/frontend/src/types/dto/lent.dto.ts index efbaba67c..7deea8f7d 100644 --- a/frontend/src/types/dto/lent.dto.ts +++ b/frontend/src/types/dto/lent.dto.ts @@ -66,3 +66,11 @@ export interface CabinetClubStatusRequestDto { cabinetId: number; statusNote: string | null; } + +export interface LentExtensionDto { + lentExtensionId: number; + name: string; + extensionPeriod: number; + expiredAt: Date; + extensionType: string; +} diff --git a/frontend/src/types/dto/user.dto.ts b/frontend/src/types/dto/user.dto.ts index 281dde5b9..41259ea1f 100644 --- a/frontend/src/types/dto/user.dto.ts +++ b/frontend/src/types/dto/user.dto.ts @@ -1,4 +1,5 @@ -import { CabinetInfo } from "./cabinet.dto"; +import { CabinetInfo } from "@/types/dto/cabinet.dto"; +import { LentExtensionDto } from "@/types/dto/lent.dto"; export interface UserDto { userId: number | null; // 42 고유 ID @@ -6,7 +7,7 @@ export interface UserDto { // TODO: // mock 데이터와 충돌 생겨서 옵셔널 필드로 바꿨습니다. 추후 수정 필요합니다. cabinetId: number | null; // 캐비닛 고유 ID - extensible: boolean; + lentExtension: LentExtensionDto | null; } export interface UserInfo { From 53f777ea79ef5c93208f3551e03578072e1b6f40 Mon Sep 17 00:00:00 2001 From: jusohn Date: Fri, 24 Nov 2023 19:14:01 +0900 Subject: [PATCH 13/24] =?UTF-8?q?[FE]=20FIX:=20UserDto=20=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=B0=9B=EC=95=84=EC=98=A4=EB=8A=94=20=EC=97=B0?= =?UTF-8?q?=EC=9E=A5=EA=B6=8C=20=EC=A0=95=EB=B3=B4=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?backend=20=EC=99=80=20=EB=8F=99=EC=9D=BC=ED=95=98=EA=B2=8C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#1424?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/CabinetInfoArea/CabinetInfoArea.container.tsx | 2 +- frontend/src/pages/ProfilePage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/CabinetInfoArea/CabinetInfoArea.container.tsx b/frontend/src/components/CabinetInfoArea/CabinetInfoArea.container.tsx index 17cbb4a76..36bf3d654 100644 --- a/frontend/src/components/CabinetInfoArea/CabinetInfoArea.container.tsx +++ b/frontend/src/components/CabinetInfoArea/CabinetInfoArea.container.tsx @@ -331,7 +331,7 @@ const CabinetInfoAreaContainer = (): JSX.Element => { cabinetViewData?.status === "IN_SESSION") && !myCabinetInfo.cabinetId } - isExtensible={!!myInfo.extensionInfo} + isExtensible={!!myInfo.lentExtension} userModal={userModal} openModal={openModal} closeModal={closeModal} diff --git a/frontend/src/pages/ProfilePage.tsx b/frontend/src/pages/ProfilePage.tsx index 405edc0e8..cd24ffc23 100644 --- a/frontend/src/pages/ProfilePage.tsx +++ b/frontend/src/pages/ProfilePage.tsx @@ -36,7 +36,7 @@ const ProfilePage = () => { ) : ( - + From 6ba0e5a4c5011d353bd983f4ea0ab848d6d1411c Mon Sep 17 00:00:00 2001 From: jusohn Date: Fri, 24 Nov 2023 19:35:20 +0900 Subject: [PATCH 14/24] =?UTF-8?q?[FE]=20FIX:=20=EC=97=B0=EC=9E=A5=EA=B6=8C?= =?UTF-8?q?=EC=9D=84=20CabinetInfoArea=20=EC=97=90=EC=84=9C=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20=EC=8B=9C=20=EC=A0=95=ED=99=95=ED=95=9C=20=EC=97=B0?= =?UTF-8?q?=EC=9E=A5=EA=B6=8C=20=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EC=B6=9C?= =?UTF-8?q?=EB=A0=A5=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95=20#14?= =?UTF-8?q?24?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Card/ExtensionCard/ExtensionCard.tsx | 2 +- .../Modals/ExtendModal/ExtendModal.tsx | 19 +++++++------------ frontend/src/utils/dateUtils.ts | 18 +++++++----------- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/frontend/src/components/Card/ExtensionCard/ExtensionCard.tsx b/frontend/src/components/Card/ExtensionCard/ExtensionCard.tsx index 737c918f8..51e694207 100644 --- a/frontend/src/components/Card/ExtensionCard/ExtensionCard.tsx +++ b/frontend/src/components/Card/ExtensionCard/ExtensionCard.tsx @@ -6,7 +6,7 @@ import { ContentInfoStyled, } from "@/components/Card/CardStyles"; import { LentExtensionDto } from "@/types/dto/lent.dto"; -import { formatDate, getLastDayofMonthString } from "@/utils/dateUtils"; +import { formatDate } from "@/utils/dateUtils"; interface ExtensionProps { extensionInfo: LentExtensionDto | null; diff --git a/frontend/src/components/Modals/ExtendModal/ExtendModal.tsx b/frontend/src/components/Modals/ExtendModal/ExtendModal.tsx index 334aa1f24..7bf3d3c68 100644 --- a/frontend/src/components/Modals/ExtendModal/ExtendModal.tsx +++ b/frontend/src/components/Modals/ExtendModal/ExtendModal.tsx @@ -18,13 +18,10 @@ import { MyCabinetInfoResponseDto } from "@/types/dto/cabinet.dto"; import IconType from "@/types/enum/icon.type.enum"; import { axiosCabinetById, - axiosExtendLentPeriod, - axiosMyLentInfo, // axiosExtend, // TODO: 연장권 api 생성 후 연결해야 함 + axiosMyLentInfo, + axiosUseExtension, // axiosExtend, // TODO: 연장권 api 생성 후 연결해야 함 } from "@/api/axios/axios.custom"; -import { - getExtendedDateString, - getLastDayofMonthString, -} from "@/utils/dateUtils"; +import { getExtendedDateString } from "@/utils/dateUtils"; const ExtendModal: React.FC<{ onClose: () => void; @@ -42,7 +39,8 @@ const ExtendModal: React.FC<{ isCurrentSectionRenderState ); const formattedExtendedDate = getExtendedDateString( - myLentInfo.lents.length ? myLentInfo.lents[0].expiredAt : undefined + myLentInfo.lents[0].expiredAt, + myInfo.lentExtension?.extensionPeriod ); const extendDetail = `사물함 연장권 사용 시, 대여 기간이 ${formattedExtendedDate} 23:59으로 @@ -50,10 +48,7 @@ const ExtendModal: React.FC<{ 연장권 사용은 취소할 수 없습니다. 연장권을 사용하시겠습니까?`; const extendInfoDetail = `사물함을 대여하시면 연장권 사용이 가능합니다. -연장권은 ${getLastDayofMonthString( - null, - "/" - )} 23:59 이후 만료됩니다.`; +연장권은 ${myInfo.lentExtension?.expiredAt} 23:59 이후 만료됩니다.`; const getModalTitle = (cabinetId: number | null) => { return cabinetId === null ? modalPropsMap[additionalModalType.MODAL_OWN_EXTENSION].title @@ -75,7 +70,7 @@ const ExtendModal: React.FC<{ return; } try { - await axiosExtendLentPeriod(); + await axiosUseExtension(); setMyInfo({ ...myInfo, cabinetId: currentCabinetId, diff --git a/frontend/src/utils/dateUtils.ts b/frontend/src/utils/dateUtils.ts index bc832a54e..865ed2459 100644 --- a/frontend/src/utils/dateUtils.ts +++ b/frontend/src/utils/dateUtils.ts @@ -43,20 +43,16 @@ export const getShortenedExpireDateString = ( return formatDate(new Date(newExpireDate), "/"); }; -export const getExtendedDateString = (existExpireDate?: Date) => { - let expireDate = existExpireDate ? new Date(existExpireDate) : new Date(); - expireDate.setDate( - expireDate.getDate() + parseInt(import.meta.env.VITE_EXTENDED_LENT_PERIOD) - ); +export const getExtendedDateString = ( + existExpireDate: Date | undefined, + dateToExtend: number | undefined +) => { + if (existExpireDate === undefined || dateToExtend === undefined) return; + let expireDate = new Date(existExpireDate); + expireDate.setDate(expireDate.getDate() + dateToExtend); return formatDate(expireDate, "/"); }; -export const getLastDayofMonthString = (date: Date | null, divider: string) => { - if (date === null) date = new Date(); - let lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0); - return formatDate(lastDay, divider); -}; - export const getTotalPage = (totalLength: number, size: number) => { return Math.ceil(totalLength / size); }; From 4c35759596d8ab0f6c82d15101a60c7273af9f13 Mon Sep 17 00:00:00 2001 From: jusohn Date: Fri, 24 Nov 2023 19:43:46 +0900 Subject: [PATCH 15/24] =?UTF-8?q?[FE]=20FIX:=20Card=20=EB=82=B4=EB=B6=80?= =?UTF-8?q?=20=ED=81=B4=EB=A6=AD=20=EA=B0=80=EB=8A=A5=ED=95=9C=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20hover=20=EC=8B=9C=20=EA=B2=80=EC=9D=80=EC=83=89=20?= =?UTF-8?q?=EA=B8=80=EC=94=A8=EB=A1=9C=20=EB=B0=94=EA=BE=B8=EB=8A=94=20?= =?UTF-8?q?=ED=9A=A8=EA=B3=BC=20=EC=B6=94=EA=B0=80,=20=EB=B0=91=EC=A4=84?= =?UTF-8?q?=20=EC=A0=9C=EA=B1=B0=20#1424?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Card/Card.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Card/Card.tsx b/frontend/src/components/Card/Card.tsx index 0a57c755a..c91b179c2 100644 --- a/frontend/src/components/Card/Card.tsx +++ b/frontend/src/components/Card/Card.tsx @@ -104,7 +104,8 @@ export const CardButtonStyled = styled.div<{ cursor: ${(props) => (props.isClickable ? "pointer" : "default")}; margin-left: 10px; &:hover { - text-decoration: ${(props) => (props.isClickable ? "underline" : "none")}; + color: var(--black); + font-weight: 400; } `; From e04b6cc01f4969d8eb8b1ae5801cbdd223aebfb4 Mon Sep 17 00:00:00 2001 From: ldw Date: Fri, 24 Nov 2023 19:49:39 +0900 Subject: [PATCH 16/24] =?UTF-8?q?[BE]=20FIX=20:=20MyProfileResponseDto?= =?UTF-8?q?=EC=97=90=20LentExtensionResponseDto=EB=A5=BC=20=EB=84=A3?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/ftclub/cabinet/dto/MyProfileResponseDto.java | 3 ++- .../java/org/ftclub/cabinet/mapper/UserMapper.java | 2 +- .../user/service/LentExtensionServiceImpl.java | 2 +- .../cabinet/user/service/UserFacadeServiceImpl.java | 12 +++++++++--- config | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/org/ftclub/cabinet/dto/MyProfileResponseDto.java b/backend/src/main/java/org/ftclub/cabinet/dto/MyProfileResponseDto.java index f59017242..32bcdbe83 100644 --- a/backend/src/main/java/org/ftclub/cabinet/dto/MyProfileResponseDto.java +++ b/backend/src/main/java/org/ftclub/cabinet/dto/MyProfileResponseDto.java @@ -16,5 +16,6 @@ public class MyProfileResponseDto { private final String name; private final Long cabinetId; private final LocalDateTime unbannedAt; - private final LentExtension lentExtension; +// private final LentExtension lentExtension; + private final LentExtensionResponseDto lentExtensionResponseDto; } diff --git a/backend/src/main/java/org/ftclub/cabinet/mapper/UserMapper.java b/backend/src/main/java/org/ftclub/cabinet/mapper/UserMapper.java index d32998328..da11e80e6 100644 --- a/backend/src/main/java/org/ftclub/cabinet/mapper/UserMapper.java +++ b/backend/src/main/java/org/ftclub/cabinet/mapper/UserMapper.java @@ -39,7 +39,7 @@ public interface UserMapper { @Mapping(target = "name", source = "user.name") @Mapping(target = "cabinetId", source = "cabinet.cabinetId") MyProfileResponseDto toMyProfileResponseDto(UserSessionDto user, Cabinet cabinet, - BanHistory banHistory, LentExtension lentExtension); + BanHistory banHistory, LentExtensionResponseDto lentExtensionResponseDto); BlockedUserPaginationDto toBlockedUserPaginationDto(List result, Long totalLength); diff --git a/backend/src/main/java/org/ftclub/cabinet/user/service/LentExtensionServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/user/service/LentExtensionServiceImpl.java index 70f8e35af..1e76dde59 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/service/LentExtensionServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/service/LentExtensionServiceImpl.java @@ -82,7 +82,7 @@ public void useLentExtension(Long userId, String username) { lentExtensionOptionalFetcher.findLentExtensionByUserId(userId) .stream() .filter(lentExtension -> - lentExtension.getExpiredAt().isBefore(LocalDateTime.now()) + lentExtension.getExpiredAt().isAfter(LocalDateTime.now()) && lentExtension.getUsedAt() == null) .collect(Collectors.toList()); if (findLentExtension.isEmpty()) { diff --git a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java index 72e32af9f..2803a2450 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java @@ -60,10 +60,16 @@ public MyProfileResponseDto getMyProfile(UserSessionDto user) { Cabinet cabinet = lentOptionalFetcher.findActiveLentCabinetByUserId(user.getUserId()); BanHistory banHistory = userOptionalFetcher.findRecentActiveBanHistory(user.getUserId(), LocalDateTime.now()); - List lentExtension = lentExtensionOptionalFetcher.findLentExtensionByUserId(user.getUserId()); - if (lentExtension.isEmpty()) + + List lentExtensionResponseDtos = getMyActiveLentExtension(user).getResult(); + if (lentExtensionResponseDtos.isEmpty()) return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, null); - return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, lentExtension.get(0)); + return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, lentExtensionResponseDtos.get(0)); + +// List lentExtension = lentExtensionOptionalFetcher.findLentExtensionByUserId(user.getUserId()); +// if (lentExtension.isEmpty()) +// return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, null); +// return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, lentExtension.get(0)); } @Override diff --git a/config b/config index c1d53791a..a067cf29d 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit c1d53791a15fcaf68dae0a2ec500dc8b11c07548 +Subproject commit a067cf29d4d5860db60e1ef8ef5141b4e0ab0682 From 73de9af968dfc146a156e7850584d4e251cbb812 Mon Sep 17 00:00:00 2001 From: jusohn Date: Fri, 24 Nov 2023 19:56:05 +0900 Subject: [PATCH 17/24] =?UTF-8?q?[FE]=20FIX:=20lentExtension=20=EC=9D=84?= =?UTF-8?q?=20lentExtensionResponseDto=20=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?#1424?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CabinetInfoArea/CabinetInfoArea.container.tsx | 2 +- frontend/src/components/Modals/ExtendModal/ExtendModal.tsx | 6 +++--- frontend/src/pages/ProfilePage.tsx | 4 +++- frontend/src/recoil/atoms.ts | 2 +- frontend/src/types/dto/user.dto.ts | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/CabinetInfoArea/CabinetInfoArea.container.tsx b/frontend/src/components/CabinetInfoArea/CabinetInfoArea.container.tsx index 36bf3d654..51c933ffe 100644 --- a/frontend/src/components/CabinetInfoArea/CabinetInfoArea.container.tsx +++ b/frontend/src/components/CabinetInfoArea/CabinetInfoArea.container.tsx @@ -331,7 +331,7 @@ const CabinetInfoAreaContainer = (): JSX.Element => { cabinetViewData?.status === "IN_SESSION") && !myCabinetInfo.cabinetId } - isExtensible={!!myInfo.lentExtension} + isExtensible={!!myInfo.lentExtensionResponseDto} userModal={userModal} openModal={openModal} closeModal={closeModal} diff --git a/frontend/src/components/Modals/ExtendModal/ExtendModal.tsx b/frontend/src/components/Modals/ExtendModal/ExtendModal.tsx index 7bf3d3c68..bcb7b11a6 100644 --- a/frontend/src/components/Modals/ExtendModal/ExtendModal.tsx +++ b/frontend/src/components/Modals/ExtendModal/ExtendModal.tsx @@ -40,7 +40,7 @@ const ExtendModal: React.FC<{ ); const formattedExtendedDate = getExtendedDateString( myLentInfo.lents[0].expiredAt, - myInfo.lentExtension?.extensionPeriod + myInfo.lentExtensionResponseDto?.extensionPeriod ); const extendDetail = `사물함 연장권 사용 시, 대여 기간이 ${formattedExtendedDate} 23:59으로 @@ -48,7 +48,7 @@ const ExtendModal: React.FC<{ 연장권 사용은 취소할 수 없습니다. 연장권을 사용하시겠습니까?`; const extendInfoDetail = `사물함을 대여하시면 연장권 사용이 가능합니다. -연장권은 ${myInfo.lentExtension?.expiredAt} 23:59 이후 만료됩니다.`; +연장권은 ${myInfo.lentExtensionResponseDto?.expiredAt} 23:59 이후 만료됩니다.`; const getModalTitle = (cabinetId: number | null) => { return cabinetId === null ? modalPropsMap[additionalModalType.MODAL_OWN_EXTENSION].title @@ -74,7 +74,7 @@ const ExtendModal: React.FC<{ setMyInfo({ ...myInfo, cabinetId: currentCabinetId, - lentExtension: null, + lentExtensionResponseDto: null, }); setIsCurrentSectionRender(true); setModalTitle("연장되었습니다"); diff --git a/frontend/src/pages/ProfilePage.tsx b/frontend/src/pages/ProfilePage.tsx index cd24ffc23..caf001527 100644 --- a/frontend/src/pages/ProfilePage.tsx +++ b/frontend/src/pages/ProfilePage.tsx @@ -36,7 +36,9 @@ const ProfilePage = () => { ) : ( - + diff --git a/frontend/src/recoil/atoms.ts b/frontend/src/recoil/atoms.ts index f966ad803..2565b9cb1 100644 --- a/frontend/src/recoil/atoms.ts +++ b/frontend/src/recoil/atoms.ts @@ -21,7 +21,7 @@ export const userState = atom({ cabinetId: null, userId: null, name: "default", - lentExtension: null, + lentExtensionResponseDto: null, }, }); diff --git a/frontend/src/types/dto/user.dto.ts b/frontend/src/types/dto/user.dto.ts index 41259ea1f..01c00166c 100644 --- a/frontend/src/types/dto/user.dto.ts +++ b/frontend/src/types/dto/user.dto.ts @@ -7,7 +7,7 @@ export interface UserDto { // TODO: // mock 데이터와 충돌 생겨서 옵셔널 필드로 바꿨습니다. 추후 수정 필요합니다. cabinetId: number | null; // 캐비닛 고유 ID - lentExtension: LentExtensionDto | null; + lentExtensionResponseDto: LentExtensionDto | null; } export interface UserInfo { From def9e808e37e962ef754fdf6b9bc560615a5ad9d Mon Sep 17 00:00:00 2001 From: jusohn Date: Fri, 24 Nov 2023 19:59:07 +0900 Subject: [PATCH 18/24] =?UTF-8?q?[FE]=20FIX:=20=EB=8C=80=EC=97=AC=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=9D=B4=EC=A0=84=20=EB=8C=80=EC=97=AC=EC=9E=90=20?= =?UTF-8?q?margin=20=EC=88=98=EC=A0=95=20#1424?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Card/CardStyles.ts | 2 +- .../src/components/Card/LentInfoCard/LentInfoCard.tsx | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/Card/CardStyles.ts b/frontend/src/components/Card/CardStyles.ts index f98aaa31a..b355cd7e9 100644 --- a/frontend/src/components/Card/CardStyles.ts +++ b/frontend/src/components/Card/CardStyles.ts @@ -4,7 +4,7 @@ export const CardContentWrapper = styled.div` background-color: var(--white); border-radius: 10px; padding: 15px 0; - margin: 5px 5px 10px 5px; + margin: 5px 5px 5px 5px; width: 90%; display: flex; flex-direction: column; diff --git a/frontend/src/components/Card/LentInfoCard/LentInfoCard.tsx b/frontend/src/components/Card/LentInfoCard/LentInfoCard.tsx index 7a1545a10..4d5cfec3c 100644 --- a/frontend/src/components/Card/LentInfoCard/LentInfoCard.tsx +++ b/frontend/src/components/Card/LentInfoCard/LentInfoCard.tsx @@ -115,7 +115,7 @@ const LentInfoCard = ({ const CabinetInfoWrapper = styled.div` display: flex; width: 85%; - margin: 10px 0 15px 0; + margin: 9px 0 9px 0; align-items: center; `; @@ -137,7 +137,12 @@ const CabinetRectangleStyled = styled.div<{ : props.isLented && props.status !== "IN_SESSION" ? "var(--mine)" : "var(--full)"}; - color: ${(props) => (props.banned ? "var(--white)" : "var(--black)")}; + color: ${(props) => + props.banned + ? "var(--white)" + : props.status === "IN_SESSION" + ? "var(--main-color)" + : "var(--black)"}; font-size: 2rem; text-align: center; `; From 5ec8fc282a709c41d63585d9e0082a3618177846 Mon Sep 17 00:00:00 2001 From: ldw Date: Fri, 24 Nov 2023 20:00:54 +0900 Subject: [PATCH 19/24] =?UTF-8?q?[BE]=20REFACTOR=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/ftclub/cabinet/dto/MyProfileResponseDto.java | 1 - .../ftclub/cabinet/user/service/UserFacadeServiceImpl.java | 6 ------ 2 files changed, 7 deletions(-) diff --git a/backend/src/main/java/org/ftclub/cabinet/dto/MyProfileResponseDto.java b/backend/src/main/java/org/ftclub/cabinet/dto/MyProfileResponseDto.java index 32bcdbe83..08ada145b 100644 --- a/backend/src/main/java/org/ftclub/cabinet/dto/MyProfileResponseDto.java +++ b/backend/src/main/java/org/ftclub/cabinet/dto/MyProfileResponseDto.java @@ -16,6 +16,5 @@ public class MyProfileResponseDto { private final String name; private final Long cabinetId; private final LocalDateTime unbannedAt; -// private final LentExtension lentExtension; private final LentExtensionResponseDto lentExtensionResponseDto; } diff --git a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java index 2803a2450..f94b7e6a0 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java @@ -60,16 +60,10 @@ public MyProfileResponseDto getMyProfile(UserSessionDto user) { Cabinet cabinet = lentOptionalFetcher.findActiveLentCabinetByUserId(user.getUserId()); BanHistory banHistory = userOptionalFetcher.findRecentActiveBanHistory(user.getUserId(), LocalDateTime.now()); - List lentExtensionResponseDtos = getMyActiveLentExtension(user).getResult(); if (lentExtensionResponseDtos.isEmpty()) return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, null); return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, lentExtensionResponseDtos.get(0)); - -// List lentExtension = lentExtensionOptionalFetcher.findLentExtensionByUserId(user.getUserId()); -// if (lentExtension.isEmpty()) -// return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, null); -// return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, lentExtension.get(0)); } @Override From ffd1ec90b40bf4bc39f753abdad51e81b02cae32 Mon Sep 17 00:00:00 2001 From: jusohn Date: Fri, 24 Nov 2023 20:03:20 +0900 Subject: [PATCH 20/24] =?UTF-8?q?[FE]=20FIX:=20Card=20=EB=82=B4=EB=B6=80?= =?UTF-8?q?=20=EB=B2=84=ED=8A=BC=EC=9D=B4=20=ED=81=B4=EB=A6=AD=20=EA=B0=80?= =?UTF-8?q?=EB=8A=A5=ED=95=A0=20=EB=95=8C=EB=A7=8C=20=EA=B2=80=EC=9D=80?= =?UTF-8?q?=EC=83=89=EC=9C=BC=EB=A1=9C=20=EB=B0=94=EB=80=8C=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95=20#1424?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Card/Card.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Card/Card.tsx b/frontend/src/components/Card/Card.tsx index c91b179c2..68cdd6c4e 100644 --- a/frontend/src/components/Card/Card.tsx +++ b/frontend/src/components/Card/Card.tsx @@ -104,8 +104,8 @@ export const CardButtonStyled = styled.div<{ cursor: ${(props) => (props.isClickable ? "pointer" : "default")}; margin-left: 10px; &:hover { - color: var(--black); - font-weight: 400; + color: ${(props) => props.isClickable && "var(--black)"}; + font-weight: ${(props) => props.isClickable && 400}; } `; From 1cac9910b59a4a712b3414863c767de1a6282105 Mon Sep 17 00:00:00 2001 From: Woo Joo Chae Date: Sat, 25 Nov 2023 20:36:43 +0900 Subject: [PATCH 21/24] =?UTF-8?q?[BE]=20REFACTOR:=20ActiveLentExtension=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EB=A1=9C=EC=A7=81=EC=88=98=EC=A0=95=20-?= =?UTF-8?q?=20=ED=94=BC=EB=93=9C=EB=B0=B1=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/controller/UserController.java | 2 +- .../user/service/UserFacadeService.java | 362 +++++++++--------- .../user/service/UserFacadeServiceImpl.java | 32 +- 3 files changed, 203 insertions(+), 193 deletions(-) diff --git a/backend/src/main/java/org/ftclub/cabinet/user/controller/UserController.java b/backend/src/main/java/org/ftclub/cabinet/user/controller/UserController.java index c5487b537..ea9eecc90 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/controller/UserController.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/controller/UserController.java @@ -62,7 +62,7 @@ public LentExtensionPaginationDto getMyLentExtension( public LentExtensionPaginationDto getMyActiveLentExtension( @UserSession UserSessionDto userSessionDto) { log.info("Called getMyActiveLentExtension: {}", userSessionDto.getName()); - return userFacadeService.getMyActiveLentExtension(userSessionDto); + return userFacadeService.getMyActiveLentExtensionPage(userSessionDto); } /** diff --git a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeService.java b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeService.java index 67f9c0b9e..55bad8521 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeService.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeService.java @@ -17,185 +17,185 @@ public interface UserFacadeService { - /** - * 현재 로그인한 유저의 프로필을 반환합니다. 대여한 사물함 아이디 정보가 포합됩니다. - * - * @param user 로그인한 유저의 정보 - * @return {@link MyProfileResponseDto} 현재 로그인한 유저의 정보 - */ - MyProfileResponseDto getMyProfile(UserSessionDto user); - - /** - * 모든 정지 유저를 반환합니다. - * - * @param page 페이지 번호 - * @param size 페이지 당 길이 - * @param now 현재 시간 - * @return {@link BlockedUserPaginationDto} 모든 정지 유저 - */ - /* 기존 searchByBanUser와 동일한 역할을 합니다. */ - BlockedUserPaginationDto getAllBanUsers(Integer page, Integer size, LocalDateTime now); - - /** - * 유저 이름의 일부를 입력받아 해당하는 유저들의 프로필을 받아옵니다. - * - * @param name 유저 이름의 일부 - * @param page 페이지 번호 - * @param size 페이지 당 길이 - * @return {@link UserProfilePaginationDto} 해당하는 유저들의 프로필 - */ - /*기존 searchByIntraId 메서드와 동일한 역할을 합니다.*/ - UserProfilePaginationDto getUserProfileListByPartialName(String name, Integer page, - Integer size); - - /** - * 유저 이름의 일부를 입력받아 해당 유저들의 캐비넷 정보를 반환합니다. - * - * @param name 유저 이름의 일부 - * @param page 페이지 번호 - * @param size 페이지 당 길이 - * @return {@link UserCabinetPaginationDto} 해당하는 유저들의 캐비넷 정보 - */ - UserCabinetPaginationDto findUserCabinetListByPartialName(String name, Integer page, - Integer size); - - /** - * 모든 유저의 정보를 가져옵니다. - * - * @return 모든 유저의 정보를 가져옵니다. - */ - List getAllUsers(); - - /** - * 유저가 존재하는지 확인합니다. - * - * @param name 유저 이름 - * @return 유저가 존재하면 true, 아니면 false - */ - boolean checkUserExists(String name); - - /** - * 유저를 생성합니다. - * - * @param name 유저 이름 - * @param email 유저 이메일 - * @param blackholedAt 유저 블랙홀 날짜 - * @param role 유저 역할 - */ - void createUser(String name, String email, LocalDateTime blackholedAt, UserRole role); - - /** - * @param clubName 동아리 유저 이름 - */ - void createClubUser(String clubName); - - /** - * 관리자가 존재하는지 확인합니다. - * - * @param email 관리자 이메일 - * @return 관리자가 존재하면 true, 아니면 false - */ - boolean checkAdminUserExists(String email); - - /** - * 관리자를 생성합니다. - * - * @param email 관리자 이메일 - */ - void createAdminUser(String email); - - /** - * 유저를 삭제합니다. - * - * @param userId 유저 고유 아이디 - * @param deletedAt 유저 삭제 날짜 - */ - void deleteUser(Long userId, LocalDateTime deletedAt); - - /** - * 관리자를 삭제합니다. - * - * @param adminUserId 관리자 고유 아이디 - */ - void deleteAdminUser(Long adminUserId); - - /** - * 유저의 권한을 변경합니다. - * - * @param adminUserId 관리자 고유 아이디 - * @param role 관리자 권한 - */ - void updateAdminUserRole(Long adminUserId, AdminRole role); - - /** - * 유저를 어드민으로 승격시킵니다. - * - * @param email 유저 이메일 - */ - void promoteUserToAdmin(String email); - - /** - * 유저의 블랙홀 시간을 변경합니다. - * - * @param userId 유저 고유 아이디 - * @param newBlackholedAt 새로운 유저 블랙홀 시간 - */ - void updateUserBlackholedAt(Long userId, LocalDateTime newBlackholedAt); - - /** - * 유저를 정지시킵니다. - * - * @param userId 유저 고유 아이디 - * @param lentType 현재 대여 타입 - * @param startedAt 대여 시작 날짜 - * @param endedAt 대여 종료 날짜 - * @param expiredAt 대여 만료 날짜 - */ - void banUser(Long userId, LentType lentType, LocalDateTime startedAt, LocalDateTime endedAt, - LocalDateTime expiredAt); - - /** - * 유저의 정지를 해제합니다. - * - * @param userId 유저 고유 아이디 - * @param today 현재 날짜 - */ - void deleteRecentBanHistory(Long userId, LocalDateTime today); - - /** - * 연체 중인 유저 리스트를 반환합니다. - * - * @param page 페이지 번호 - * @param size 페이지 당 길이 - */ - OverdueUserCabinetPaginationDto getOverdueUserList(Integer page, Integer size); - - /** - * 동아리 유저 리스트DTO를 반환합니다. - * - * @param page 페이지 번호 - * @param size 페이지 당 길이 - * @return - */ - ClubUserListDto findAllClubUser(Integer page, Integer size); - - - /** - * 동아리 유저를 삭제합니다. - * - * @param clubId 동아리 고유 아이디 - */ - void deleteClubUser(Long clubId); - - void updateClubUser(Long clubId, String clubName); - - LentExtensionPaginationDto getAllLentExtension(Integer page, Integer size); - - LentExtensionPaginationDto getAllActiveLentExtension(Integer page, Integer size); - - LentExtensionPaginationDto getMyLentExtension(UserSessionDto userSessionDto); - - LentExtensionPaginationDto getMyActiveLentExtension(UserSessionDto userSessionDto); - - void useLentExtension(UserSessionDto userSessionDto); + /** + * 현재 로그인한 유저의 프로필을 반환합니다. 대여한 사물함 아이디 정보가 포합됩니다. + * + * @param user 로그인한 유저의 정보 + * @return {@link MyProfileResponseDto} 현재 로그인한 유저의 정보 + */ + MyProfileResponseDto getMyProfile(UserSessionDto user); + + /** + * 모든 정지 유저를 반환합니다. + * + * @param page 페이지 번호 + * @param size 페이지 당 길이 + * @param now 현재 시간 + * @return {@link BlockedUserPaginationDto} 모든 정지 유저 + */ + /* 기존 searchByBanUser와 동일한 역할을 합니다. */ + BlockedUserPaginationDto getAllBanUsers(Integer page, Integer size, LocalDateTime now); + + /** + * 유저 이름의 일부를 입력받아 해당하는 유저들의 프로필을 받아옵니다. + * + * @param name 유저 이름의 일부 + * @param page 페이지 번호 + * @param size 페이지 당 길이 + * @return {@link UserProfilePaginationDto} 해당하는 유저들의 프로필 + */ + /*기존 searchByIntraId 메서드와 동일한 역할을 합니다.*/ + UserProfilePaginationDto getUserProfileListByPartialName(String name, Integer page, + Integer size); + + /** + * 유저 이름의 일부를 입력받아 해당 유저들의 캐비넷 정보를 반환합니다. + * + * @param name 유저 이름의 일부 + * @param page 페이지 번호 + * @param size 페이지 당 길이 + * @return {@link UserCabinetPaginationDto} 해당하는 유저들의 캐비넷 정보 + */ + UserCabinetPaginationDto findUserCabinetListByPartialName(String name, Integer page, + Integer size); + + /** + * 모든 유저의 정보를 가져옵니다. + * + * @return 모든 유저의 정보를 가져옵니다. + */ + List getAllUsers(); + + /** + * 유저가 존재하는지 확인합니다. + * + * @param name 유저 이름 + * @return 유저가 존재하면 true, 아니면 false + */ + boolean checkUserExists(String name); + + /** + * 유저를 생성합니다. + * + * @param name 유저 이름 + * @param email 유저 이메일 + * @param blackholedAt 유저 블랙홀 날짜 + * @param role 유저 역할 + */ + void createUser(String name, String email, LocalDateTime blackholedAt, UserRole role); + + /** + * @param clubName 동아리 유저 이름 + */ + void createClubUser(String clubName); + + /** + * 관리자가 존재하는지 확인합니다. + * + * @param email 관리자 이메일 + * @return 관리자가 존재하면 true, 아니면 false + */ + boolean checkAdminUserExists(String email); + + /** + * 관리자를 생성합니다. + * + * @param email 관리자 이메일 + */ + void createAdminUser(String email); + + /** + * 유저를 삭제합니다. + * + * @param userId 유저 고유 아이디 + * @param deletedAt 유저 삭제 날짜 + */ + void deleteUser(Long userId, LocalDateTime deletedAt); + + /** + * 관리자를 삭제합니다. + * + * @param adminUserId 관리자 고유 아이디 + */ + void deleteAdminUser(Long adminUserId); + + /** + * 유저의 권한을 변경합니다. + * + * @param adminUserId 관리자 고유 아이디 + * @param role 관리자 권한 + */ + void updateAdminUserRole(Long adminUserId, AdminRole role); + + /** + * 유저를 어드민으로 승격시킵니다. + * + * @param email 유저 이메일 + */ + void promoteUserToAdmin(String email); + + /** + * 유저의 블랙홀 시간을 변경합니다. + * + * @param userId 유저 고유 아이디 + * @param newBlackholedAt 새로운 유저 블랙홀 시간 + */ + void updateUserBlackholedAt(Long userId, LocalDateTime newBlackholedAt); + + /** + * 유저를 정지시킵니다. + * + * @param userId 유저 고유 아이디 + * @param lentType 현재 대여 타입 + * @param startedAt 대여 시작 날짜 + * @param endedAt 대여 종료 날짜 + * @param expiredAt 대여 만료 날짜 + */ + void banUser(Long userId, LentType lentType, LocalDateTime startedAt, LocalDateTime endedAt, + LocalDateTime expiredAt); + + /** + * 유저의 정지를 해제합니다. + * + * @param userId 유저 고유 아이디 + * @param today 현재 날짜 + */ + void deleteRecentBanHistory(Long userId, LocalDateTime today); + + /** + * 연체 중인 유저 리스트를 반환합니다. + * + * @param page 페이지 번호 + * @param size 페이지 당 길이 + */ + OverdueUserCabinetPaginationDto getOverdueUserList(Integer page, Integer size); + + /** + * 동아리 유저 리스트DTO를 반환합니다. + * + * @param page 페이지 번호 + * @param size 페이지 당 길이 + * @return + */ + ClubUserListDto findAllClubUser(Integer page, Integer size); + + + /** + * 동아리 유저를 삭제합니다. + * + * @param clubId 동아리 고유 아이디 + */ + void deleteClubUser(Long clubId); + + void updateClubUser(Long clubId, String clubName); + + LentExtensionPaginationDto getAllLentExtension(Integer page, Integer size); + + LentExtensionPaginationDto getAllActiveLentExtension(Integer page, Integer size); + + LentExtensionPaginationDto getMyLentExtension(UserSessionDto userSessionDto); + + LentExtensionPaginationDto getMyActiveLentExtensionPage(UserSessionDto userSessionDto); + + void useLentExtension(UserSessionDto userSessionDto); } diff --git a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java index f94b7e6a0..a086eb579 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java @@ -54,16 +54,32 @@ public class UserFacadeServiceImpl implements UserFacadeService { private final LentExtensionService lentExtensionService; private final LentExtensionOptionalFetcher lentExtensionOptionalFetcher; + private List getMyActiveLentExtension(UserSessionDto userSessionDto) { + log.debug("Called getMyActiveLentExtension"); + return lentExtensionOptionalFetcher.findLentExtensionByUserId(userSessionDto.getUserId()) + .parallelStream() + .filter(lentExtension -> lentExtension.getUsedAt() == null && + lentExtension.getExpiredAt().isAfter(LocalDateTime.now())) + .map(userMapper::toLentExtensionResponseDto) + .collect(Collectors.toList()); + } + @Override public MyProfileResponseDto getMyProfile(UserSessionDto user) { log.debug("Called getMyProfile: {}", user.getName()); + Cabinet cabinet = lentOptionalFetcher.findActiveLentCabinetByUserId(user.getUserId()); BanHistory banHistory = userOptionalFetcher.findRecentActiveBanHistory(user.getUserId(), LocalDateTime.now()); - List lentExtensionResponseDtos = getMyActiveLentExtension(user).getResult(); - if (lentExtensionResponseDtos.isEmpty()) + + List lentExtensionResponseDtos = getMyActiveLentExtension(user); + + if (lentExtensionResponseDtos.isEmpty()) { return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, null); - return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, lentExtensionResponseDtos.get(0)); + } + + return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, + lentExtensionResponseDtos.get(0)); } @Override @@ -283,15 +299,9 @@ public LentExtensionPaginationDto getMyLentExtension(UserSessionDto userSessionD } @Override - public LentExtensionPaginationDto getMyActiveLentExtension(UserSessionDto userSessionDto) { + public LentExtensionPaginationDto getMyActiveLentExtensionPage(UserSessionDto userSessionDto) { log.debug("Called getMyActiveLentExtension"); - List result = - lentExtensionOptionalFetcher.findLentExtensionByUserId(userSessionDto.getUserId()) - .parallelStream() - .filter(lentExtension -> lentExtension.getUsedAt() == null && - lentExtension.getExpiredAt().isAfter(LocalDateTime.now())) - .map(userMapper::toLentExtensionResponseDto) - .collect(Collectors.toList()); + List result = getMyActiveLentExtension(userSessionDto); return userMapper.toLentExtensionPaginationDto(result, (long) result.size()); } From f44d8db06e619d700f93ab7d8d878c9e9a5071fd Mon Sep 17 00:00:00 2001 From: Woo Joo Chae Date: Sat, 25 Nov 2023 20:45:20 +0900 Subject: [PATCH 22/24] =?UTF-8?q?[BE]=20REFACTOR:=20getActiveLentExtension?= =?UTF-8?q?List=20=EB=A9=94=EC=86=8C=EB=93=9C,=20LentExtensionService=20?= =?UTF-8?q?=EC=AA=BD=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/service/LentExtensionService.java | 4 +++ .../service/LentExtensionServiceImpl.java | 29 +++++++++++++++---- .../user/service/UserFacadeServiceImpl.java | 18 ++++-------- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/backend/src/main/java/org/ftclub/cabinet/user/service/LentExtensionService.java b/backend/src/main/java/org/ftclub/cabinet/user/service/LentExtensionService.java index f0a900bcb..03ea19898 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/service/LentExtensionService.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/service/LentExtensionService.java @@ -1,5 +1,7 @@ package org.ftclub.cabinet.user.service; +import java.util.List; +import org.ftclub.cabinet.dto.LentExtensionResponseDto; import org.ftclub.cabinet.dto.UserSessionDto; public interface LentExtensionService { @@ -12,4 +14,6 @@ public interface LentExtensionService { void assignLentExtension(String username); + List getActiveLentExtensionList(UserSessionDto userSessionDto); + } diff --git a/backend/src/main/java/org/ftclub/cabinet/user/service/LentExtensionServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/user/service/LentExtensionServiceImpl.java index 1e76dde59..a7f2794c3 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/service/LentExtensionServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/service/LentExtensionServiceImpl.java @@ -7,11 +7,14 @@ import lombok.RequiredArgsConstructor; import lombok.extern.log4j.Log4j2; import org.ftclub.cabinet.config.CabinetProperties; +import org.ftclub.cabinet.dto.LentExtensionResponseDto; import org.ftclub.cabinet.dto.UserMonthDataDto; +import org.ftclub.cabinet.dto.UserSessionDto; import org.ftclub.cabinet.exception.ExceptionStatus; import org.ftclub.cabinet.exception.ServiceException; import org.ftclub.cabinet.lent.domain.LentHistory; import org.ftclub.cabinet.lent.repository.LentOptionalFetcher; +import org.ftclub.cabinet.mapper.UserMapper; import org.ftclub.cabinet.occupiedtime.OccupiedTimeManager; import org.ftclub.cabinet.user.domain.LentExtension; import org.ftclub.cabinet.user.domain.LentExtensionType; @@ -33,6 +36,7 @@ public class LentExtensionServiceImpl implements LentExtensionService { private final UserOptionalFetcher userOptionalFetcher; private final CabinetProperties cabinetProperties; private final OccupiedTimeManager occupiedTimeManager; + private final UserMapper userMapper; @Override @Scheduled(cron = "${spring.schedule.cron.extension-issue-time}") @@ -67,6 +71,18 @@ public void assignLentExtension(String username) { lentExtensionRepository.save(lentExtension); } + @Override + public List getActiveLentExtensionList( + UserSessionDto userSessionDto) { + log.debug("Called getLentExtensionList {}", userSessionDto.getName()); + return lentExtensionOptionalFetcher.findLentExtensionByUserId(userSessionDto.getUserId()) + .parallelStream() + .filter(lentExtension -> lentExtension.getUsedAt() == null && + lentExtension.getExpiredAt().isAfter(LocalDateTime.now())) + .map(userMapper::toLentExtensionResponseDto) + .collect(Collectors.toList()); + } + @Override @Scheduled(cron = "${spring.schedule.cron.extension-delete-time}") public void deleteLentExtension() { @@ -80,18 +96,19 @@ public void useLentExtension(Long userId, String username) { List findLentExtension = lentExtensionOptionalFetcher.findLentExtensionByUserId(userId) - .stream() - .filter(lentExtension -> - lentExtension.getExpiredAt().isAfter(LocalDateTime.now()) - && lentExtension.getUsedAt() == null) - .collect(Collectors.toList()); + .stream() + .filter(lentExtension -> + lentExtension.getExpiredAt().isAfter(LocalDateTime.now()) + && lentExtension.getUsedAt() == null) + .collect(Collectors.toList()); if (findLentExtension.isEmpty()) { throw new ServiceException(ExceptionStatus.EXTENSION_NOT_FOUND); } LentExtension lentExtension = findLentExtension.get(0); LentHistory lentHistory = lentOptionalFetcher.getActiveLentHistoryWithUserId(userId); lentExtension.use(); - lentHistory.setExpiredAt(lentHistory.getExpiredAt().plusDays(lentExtension.getExtensionPeriod())); + lentHistory.setExpiredAt( + lentHistory.getExpiredAt().plusDays(lentExtension.getExtensionPeriod())); } } diff --git a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java index a086eb579..97a8123a8 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java @@ -54,16 +54,6 @@ public class UserFacadeServiceImpl implements UserFacadeService { private final LentExtensionService lentExtensionService; private final LentExtensionOptionalFetcher lentExtensionOptionalFetcher; - private List getMyActiveLentExtension(UserSessionDto userSessionDto) { - log.debug("Called getMyActiveLentExtension"); - return lentExtensionOptionalFetcher.findLentExtensionByUserId(userSessionDto.getUserId()) - .parallelStream() - .filter(lentExtension -> lentExtension.getUsedAt() == null && - lentExtension.getExpiredAt().isAfter(LocalDateTime.now())) - .map(userMapper::toLentExtensionResponseDto) - .collect(Collectors.toList()); - } - @Override public MyProfileResponseDto getMyProfile(UserSessionDto user) { log.debug("Called getMyProfile: {}", user.getName()); @@ -72,12 +62,13 @@ public MyProfileResponseDto getMyProfile(UserSessionDto user) { BanHistory banHistory = userOptionalFetcher.findRecentActiveBanHistory(user.getUserId(), LocalDateTime.now()); - List lentExtensionResponseDtos = getMyActiveLentExtension(user); + List lentExtensionResponseDtos = lentExtensionService.getActiveLentExtensionList( + user); if (lentExtensionResponseDtos.isEmpty()) { return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, null); } - + return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, lentExtensionResponseDtos.get(0)); } @@ -301,7 +292,8 @@ public LentExtensionPaginationDto getMyLentExtension(UserSessionDto userSessionD @Override public LentExtensionPaginationDto getMyActiveLentExtensionPage(UserSessionDto userSessionDto) { log.debug("Called getMyActiveLentExtension"); - List result = getMyActiveLentExtension(userSessionDto); + List result = lentExtensionService.getActiveLentExtensionList( + userSessionDto); return userMapper.toLentExtensionPaginationDto(result, (long) result.size()); } From 13c87b5c2da24c2ad994d581f94d5f7ca50eb38d Mon Sep 17 00:00:00 2001 From: Woo Joo Chae Date: Sat, 25 Nov 2023 21:12:24 +0900 Subject: [PATCH 23/24] =?UTF-8?q?[BE]=20REFACTOR:=20getMyProfile=20?= =?UTF-8?q?=EC=97=90=EC=84=9C,=20LentExtension=20=ED=95=98=EB=82=98?= =?UTF-8?q?=EB=A7=8C=20=EA=B0=80=EC=A0=B8=EC=98=A4=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/LentExtensionOptionalFetcher.java | 7 +++++-- .../user/repository/LentExtensionRepository.java | 3 ++- .../cabinet/user/service/UserFacadeServiceImpl.java | 13 ++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/org/ftclub/cabinet/user/repository/LentExtensionOptionalFetcher.java b/backend/src/main/java/org/ftclub/cabinet/user/repository/LentExtensionOptionalFetcher.java index a83344b59..7c391f09d 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/repository/LentExtensionOptionalFetcher.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/repository/LentExtensionOptionalFetcher.java @@ -3,8 +3,6 @@ import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.log4j.Log4j2; -import org.ftclub.cabinet.exception.ExceptionStatus; -import org.ftclub.cabinet.exception.ServiceException; import org.ftclub.cabinet.user.domain.LentExtension; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -33,4 +31,9 @@ public Page findAllNotExpired(PageRequest pageable) { public List findLentExtensionByUserId(Long userId) { return lentExtensionRepository.findAllByUserId(userId); } + + @Transactional(readOnly = true) + public LentExtension findActiveLentExtensionByUserId(Long userId) { + return lentExtensionRepository.findByUserId(userId); + } } diff --git a/backend/src/main/java/org/ftclub/cabinet/user/repository/LentExtensionRepository.java b/backend/src/main/java/org/ftclub/cabinet/user/repository/LentExtensionRepository.java index 387f02d63..642113434 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/repository/LentExtensionRepository.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/repository/LentExtensionRepository.java @@ -1,7 +1,6 @@ package org.ftclub.cabinet.user.repository; import java.util.List; -import java.util.Optional; import org.ftclub.cabinet.user.domain.LentExtension; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -26,4 +25,6 @@ public interface LentExtensionRepository extends JpaRepository findAllByUserId(@Param("userId") Long userId); + + LentExtension findByUserId(@Param("userId") Long userId); } diff --git a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java index 97a8123a8..1b5b3d4a6 100644 --- a/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java +++ b/backend/src/main/java/org/ftclub/cabinet/user/service/UserFacadeServiceImpl.java @@ -62,15 +62,14 @@ public MyProfileResponseDto getMyProfile(UserSessionDto user) { BanHistory banHistory = userOptionalFetcher.findRecentActiveBanHistory(user.getUserId(), LocalDateTime.now()); - List lentExtensionResponseDtos = lentExtensionService.getActiveLentExtensionList( - user); - - if (lentExtensionResponseDtos.isEmpty()) { - return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, null); - } + LentExtensionResponseDto lentExtensionResponseDto = + userMapper.toLentExtensionResponseDto( + lentExtensionOptionalFetcher.findActiveLentExtensionByUserId( + user.getUserId()) + ); return userMapper.toMyProfileResponseDto(user, cabinet, banHistory, - lentExtensionResponseDtos.get(0)); + lentExtensionResponseDto); } @Override From 1571d933ea9f18cec502b887612a42f94a4f0fc3 Mon Sep 17 00:00:00 2001 From: jusohn Date: Sat, 25 Nov 2023 21:14:30 +0900 Subject: [PATCH 24/24] =?UTF-8?q?[FE]=20FIX:=20ProfilePage=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=B0=98=EB=82=A9=20=EC=8B=9C=20=EB=A0=8C=ED=8A=B8?= =?UTF-8?q?=20=EC=83=81=ED=83=9C=EB=A5=BC=20=EC=98=AC=EB=B0=94=EB=A5=B4?= =?UTF-8?q?=EA=B2=8C=20=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?#1424?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/Card/LentInfoCard/LentInfoCard.container.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Card/LentInfoCard/LentInfoCard.container.tsx b/frontend/src/components/Card/LentInfoCard/LentInfoCard.container.tsx index aa926e211..59d71afa0 100644 --- a/frontend/src/components/Card/LentInfoCard/LentInfoCard.container.tsx +++ b/frontend/src/components/Card/LentInfoCard/LentInfoCard.container.tsx @@ -86,7 +86,7 @@ const LentInfoCardContainer = ({ name }: { name: string | null }) => { dateUsed, dateLeft, expireDate, - isLented: myCabinetInfo ? true : false, + isLented: myCabinetInfo && myCabinetInfo.lents.length ? true : false, previousUserName: myCabinetInfo?.previousUserName || "", status: myCabinetInfo.status || "", };