Skip to content

Commit

Permalink
[BE] FIX : CabinetFacadeService 줄 정리 및 이름 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Z1Park committed Jun 11, 2024
1 parent 25e17c4 commit 163b915
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static org.ftclub.cabinet.cabinet.domain.CabinetStatus.AVAILABLE;
import static org.ftclub.cabinet.cabinet.domain.CabinetStatus.PENDING;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -75,8 +76,7 @@ public List<BuildingFloorsDto> getBuildingFloorsResponse() {
List<String> allBuildings = cabinetQueryService.findAllBuildings();
return allBuildings.stream()
.map(building -> cabinetMapper.toBuildingFloorsDto(building,
cabinetQueryService.findAllFloorsByBuilding(building))
)
cabinetQueryService.findAllFloorsByBuilding(building)))
.collect(Collectors.toList());
}

Expand All @@ -99,8 +99,8 @@ public CabinetInfoResponseDto getCabinetInfo(Long cabinetId) {
LocalDateTime sessionExpiredAt = lentRedisService.getSessionExpired(cabinetId);
return cabinetMapper.toCabinetInfoResponseDto(cabinet, lentDtos, sessionExpiredAt);
}
List<LentHistory> cabinetActiveLentHistories = lentQueryService.findCabinetActiveLentHistories(
cabinetId);
List<LentHistory> cabinetActiveLentHistories =
lentQueryService.findCabinetActiveLentHistories(cabinetId);
List<LentDto> lentDtos = cabinetActiveLentHistories.stream()
.map(lentHistory -> lentMapper.toLentDto(lentHistory.getUser(), lentHistory))
.collect(Collectors.toList());
Expand All @@ -109,8 +109,7 @@ public CabinetInfoResponseDto getCabinetInfo(Long cabinetId) {
List<Long> usersInCabinet = lentRedisService.findUsersInCabinet(cabinetId);
List<User> users = userQueryService.findUsers(usersInCabinet);
users.forEach(user -> lentDtos.add(
LentDto.builder().userId(user.getId()).name(user.getName()).build()
));
LentDto.builder().userId(user.getId()).name(user.getName()).build()));
}
LocalDateTime sessionExpiredAt = lentRedisService.getSessionExpired(cabinetId);

Expand Down Expand Up @@ -145,8 +144,7 @@ public List<CabinetsPerSectionResponseDto> getCabinetsPerSection(String building

// 층, 건물에 따른 유저가 알람 등록한 section 조회
Set<String> unsetAlarmSection =
sectionAlarmQueryService.getUnsentAlarm(userId, building, floor)
.stream()
sectionAlarmQueryService.getUnsentAlarm(userId, building, floor).stream()
.map(alarm -> alarm.getCabinetPlace().getLocation().getSection())
.collect(Collectors.toSet());

Expand Down Expand Up @@ -217,7 +215,7 @@ private String getCabinetTitle(Cabinet cabinet, List<LentHistory> lentHistories)
public CabinetPendingResponseDto getAvailableCabinets(String building) {
// 현재 시간 및 어제 13시 00분 00초 시간 설정
final LocalDateTime now = LocalDateTime.now();
final LocalDateTime yesterday = now.minusDays(1).withHour(13).withMinute(0).withSecond(0);
final LocalDate yesterday = now.minusDays(1).toLocalDate();

// 빌딩에 있는 CLUB 대여 타입이 아니면서, AVAILABLE, PENDING 상태인 사물함 조회
List<Cabinet> availableCabinets = cabinetQueryService.findCabinetsNotLentTypeAndStatus(
Expand All @@ -230,9 +228,9 @@ public CabinetPendingResponseDto getAvailableCabinets(String building) {
Map<Long, List<LentHistory>> lentHistoriesMap;
// 현재 시간이 13시 이전이면 어제 반납된 사물함을 조회
if (now.getHour() < 13) {
lentHistoriesMap = lentQueryService.findPendingLentHistoriesOnDate(
yesterday.toLocalDate(), cabinetIds)
.stream().collect(groupingBy(LentHistory::getCabinetId));
lentHistoriesMap =
lentQueryService.findAvailableLentHistoriesOnDate(yesterday, cabinetIds)
.stream().collect(groupingBy(LentHistory::getCabinetId));
} else {
// 13시 이후면 현재 PENDING 인 사물함들을 조회
lentHistoriesMap = lentQueryService.findCabinetLentHistories(cabinetIds)
Expand Down Expand Up @@ -286,8 +284,8 @@ public CabinetPaginationDto getCabinetPaginationByStatus(CabinetStatus status,
*/
@Transactional(readOnly = true)
public LentHistoryPaginationDto getLentHistoryPagination(Long cabinetId, Pageable pageable) {
Page<LentHistory> lentHistories = lentQueryService.findCabinetLentHistoriesWithUserAndCabinet(
cabinetId, pageable);
Page<LentHistory> lentHistories =
lentQueryService.findCabinetLentHistoriesWithUserAndCabinet(cabinetId, pageable);
List<LentHistoryDto> result = lentHistories.stream()
.map(lh -> lentMapper.toLentHistoryDto(lh, lh.getUser(), lh.getCabinet()))
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ public List<LentHistory> findOverdueLentHistories(LocalDateTime now, Pageable pa
* @param cabinetIds 찾으려는 cabinet id {@link List}
* @return 기준 날짜보다 반납 기한이 나중인 대여 기록 {@link List}
*/
public List<LentHistory> findPendingLentHistoriesOnDate(LocalDate date, List<Long> cabinetIds) {
public List<LentHistory> findAvailableLentHistoriesOnDate(LocalDate date,
List<Long> cabinetIds) {
return lentRepository.findAllByCabinetIdsEndedAtEqualDate(date, cabinetIds);
}

Expand Down

0 comments on commit 163b915

Please sign in to comment.