Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Service;
Expand All @@ -17,7 +18,6 @@
import com.nowait.applicationadmin.reservation.repository.WaitingRedisRepository;
import com.nowait.common.enums.ReservationStatus;
import com.nowait.common.enums.Role;
import com.nowait.domaincorerdb.order.exception.OrderUpdateUnauthorizedException;
import com.nowait.domaincorerdb.reservation.entity.Reservation;
import com.nowait.domaincorerdb.reservation.exception.ReservationNotFoundException;
import com.nowait.domaincorerdb.reservation.exception.ReservationUpdateUnauthorizedException;
Expand Down Expand Up @@ -95,21 +95,21 @@ public List<WaitingUserResponse> getAllWaitingUserDetails(Long storeId) {
Integer partySize = waitingRedisRepository.getWaitingPartySize(storeId, userId);
String status = waitingRedisRepository.getWaitingStatus(storeId, userId);

// 2. DB에서 userName, createdAt 조회
// 2. DB에서 userName, createdAt, reservationId 조회
String userName = null;
LocalDateTime createdAt = null;
Long reservationId = null;

// UserName 조회 (예: UserRepository)
userName = userRepository.findById(Long.valueOf(userId))
.map(User::getNickname)
.orElse(null);

// createAt 조회 (예: ReservationRepository)
createdAt = reservationRepository.findByStore_StoreIdAndUserId(storeId, Long.valueOf(userId))
.map(Reservation::getRequestedAt)
.orElse(null);
Optional<Reservation> reservationOpt = reservationRepository.findByStore_StoreIdAndUserId(storeId, Long.valueOf(userId));
if (reservationOpt.isPresent()) {
Reservation reservation = reservationOpt.get();
createdAt = reservation.getRequestedAt();
reservationId = reservation.getId();
userName = reservation.getUser().getNickname();
}

return new WaitingUserResponse(
reservationId != null ? reservationId.toString() : null,
userId,
partySize,
userName,
Expand All @@ -119,6 +119,7 @@ public List<WaitingUserResponse> getAllWaitingUserDetails(Long storeId) {
);
})
.toList();

}

// 완료 or 취소 처리된 대기 리스트 조회
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ public List<StoreWaitingInfo> getStoresByWaitingCount(boolean desc) {
if (desc) comparator = comparator.reversed();
result.sort(comparator);

return result;
return result.stream()
.limit(5)
.toList();
}

private RedisConnection getSafeConnection() {
Expand Down