Skip to content

Commit

Permalink
[BE] no unique exception 에러 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Z1Park committed Dec 5, 2023
1 parent 7211f58 commit fbaacfe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public List<LentHistory> findAllActiveLentHistoriesByUserId(Long userId) {
return lentRepository.findAllActiveLentHistoriesByUserId(userId);
}

public Optional<LentHistory> findPreviousLentHistoryByCabinetId(Long cabinetId) {
public List<LentHistory> findPreviousLentHistoryByCabinetId(Long cabinetId) {
log.debug("Called findPreviousLentUserNameByCabinetId: {}", cabinetId);
return lentRepository.findByCabinetIdAndEndedAtIsNotNullOrderByEndedAtDesc(cabinetId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int countReturnByTimeDuration(@Param("startDate") LocalDateTime startDate,
* @param cabinetId 찾으려는 cabinet id
* @return 반납한 {@link LentHistory}의 {@link Optional}
*/
Optional<LentHistory> findByCabinetIdAndEndedAtIsNotNullOrderByEndedAtDesc(
List<LentHistory> findByCabinetIdAndEndedAtIsNotNullOrderByEndedAtDesc(
@Param("cabinetId") Long cabinetId);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ public MyCabinetResponseDto getMyLentInfo(@UserSession UserSessionDto user) {
String previousUserName = lentRedis.getPreviousUserName(
myCabinet.getCabinetId().toString());
if (previousUserName == null) {
Optional<LentHistory> previousLentHistory = lentOptionalFetcher.findPreviousLentHistoryByCabinetId(
List<LentHistory> previousLentHistory = lentOptionalFetcher.findPreviousLentHistoryByCabinetId(
cabinetId);
if (previousLentHistory.isPresent()) {
previousUserName = previousLentHistory.get().getUser().getName();
if (!previousLentHistory.isEmpty()) {
previousUserName = previousLentHistory.get(0).getUser().getName();
}
}
return cabinetMapper.toMyCabinetResponseDto(myCabinet, lentDtoList,
Expand Down

0 comments on commit fbaacfe

Please sign in to comment.