Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
28d6949
refactor(Reservation): 예약 번호 및 호출, 확정, 취소 시각 컬럼 추가
Jjiggu Jul 28, 2025
7a6f958
refactor(Reservation): 예약 Id 및 배너 이미지 필드 추가
Jjiggu Jul 28, 2025
2275012
refactor(Reservation): MyWaitingStoreInfo Dto 추가
Jjiggu Jul 28, 2025
34e2087
refactor(Reservation): 임시 예약번호 및 calling 키 추가
Jjiggu Jul 28, 2025
514d13b
refactor(Reservation): 코드 컨벤션에 맞게 수정
Jjiggu Jul 28, 2025
256b715
refactor(Reservation): 코드 컨벤션에 맞게 수정
Jjiggu Jul 28, 2025
1710029
refactor(Reservation): statuses 추가
Jjiggu Jul 28, 2025
dd57d70
refactor(Reservation): ThreadLocalRandom으로 ID 만드는 로직 삭제 및 기존 로직 리팩토링.…
Jjiggu Jul 28, 2025
1a72411
refactor(Reservation): ThreadLocalRandom으로 ID 만드는 로직 삭제 및 기존 로직 리팩토링.…
Jjiggu Jul 28, 2025
a11281f
refactor(Reservation): 이미지 조회를 위한 findAllByStore_StoreIdInAndImageTyp…
Jjiggu Jul 28, 2025
bb5f427
refactor(Reservation): findAllWithDepartmentByStoreIdIn 추가
Jjiggu Jul 28, 2025
1d04861
refactor(Reservation): ReservationNumber 및 setWaitingCalledAt 추가
Jjiggu Jul 28, 2025
a1a950c
refactor(Reservation): ReservationNumber 추가
Jjiggu Jul 28, 2025
492e687
refactor(Reservation): 기존 로직 개선
Jjiggu Jul 28, 2025
d509b60
refactor(Reservation): reservationId 추가 및 fromRedis 추가
Jjiggu Jul 28, 2025
e3290e3
refactor(Reservation): 사용하지 않는 메서드 삭제
Jjiggu Jul 28, 2025
53e0ca2
refactor(Reservation): 매핑 수정
Jjiggu Jul 28, 2025
3971be7
refactor(Reservation): 만료 시간 호출 시점 기준으로 변경
Jjiggu Jul 28, 2025
325cec2
refactor(Reservation): 시간 처리 일관성있게 변경
Jjiggu Jul 28, 2025
c5aabd3
refactor(Reservation): 조건문 처리
Jjiggu Jul 28, 2025
f56ac5c
refactor(Reservation): SRP 위반하지 않도록 리팩토링
Jjiggu Jul 28, 2025
57ece0f
refactor(Reservation): not null 조건 삭제
Jjiggu Jul 28, 2025
2c29716
Merge pull request #177 from GTable/refactor/#174-code-review
Jjiggu Jul 28, 2025
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 @@ -8,18 +8,15 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.nowait.applicationadmin.reservation.dto.CallingWaitingResponseDto;
import com.nowait.applicationadmin.reservation.dto.EntryStatusResponseDto;
import com.nowait.applicationadmin.reservation.dto.ReservationStatusRequest;
import com.nowait.applicationadmin.reservation.dto.WaitingUserResponse;
import com.nowait.applicationadmin.reservation.service.ReservationService;
import com.nowait.common.api.ApiUtils;
import com.nowait.common.enums.ReservationStatus;
import com.nowait.domaincorerdb.user.entity.MemberDetails;

import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -40,7 +37,13 @@ public class ReservationController {
@ApiResponse(responseCode = "200", description = "주점별 전체 대기 리스트 조회")
public ResponseEntity<?> getWaitingUsersWithScore(@PathVariable Long storeId) {
List<WaitingUserResponse> response = reservationService.getAllWaitingUserDetails(storeId);
return ResponseEntity.ok(response);
return ResponseEntity
.ok()
.body(
ApiUtils.success(
response
)
);
}

@GetMapping("/admin/{storeId}/completed")
Expand All @@ -51,7 +54,13 @@ public ResponseEntity<?> getCompletedReservationList(
@AuthenticationPrincipal MemberDetails memberDetails
) {
List<WaitingUserResponse> response = reservationService.getCompletedWaitingUserDetails(storeId);
return ResponseEntity.ok(response);
return ResponseEntity
.ok()
.body(
ApiUtils.success(
response
)
);
}

// @PatchMapping("/admin/{storeId}/call/{userId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import java.time.LocalDateTime;

import com.nowait.common.enums.ReservationStatus;
import com.nowait.domaincorerdb.reservation.entity.Reservation;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -11,7 +14,10 @@
@Builder
public class EntryStatusResponseDto {
@Schema(description = "예약 ID", example = "1201")
private String id; // reservationId
private String reservationId; // reservationId

@Schema(description = "예약 번호", example = "23-240504-0001")
private String reservationNumber;

@Schema(description = "유저 ID", example = "16")
private String userId;
Expand All @@ -25,6 +31,15 @@ public class EntryStatusResponseDto {
@Schema(description = "대기 등록 시각", example = "2025-07-22T16:00:00")
private LocalDateTime createdAt;

@Schema(description = "호출 시각", example = "2025-07-22T16:00:00")
private LocalDateTime calledAt; // 호출 시각

@Schema(description = "입장 완료 처리 시각", example = "2025-07-22T16:00:00")
private LocalDateTime confirmedAt; // 완료 시각

@Schema(description = "웨이팅 취소 시각", example = "2025-07-22T16:00:00")
private LocalDateTime cancelledAt; // 취소 시각

@Schema(description = "대기 상태", example = "CALLING")
private String status;

Expand All @@ -33,5 +48,26 @@ public class EntryStatusResponseDto {

@Schema(description = "호출 메시지", example = "호출 메시지")
private String message;

public static EntryStatusResponseDto fromEntity(Reservation r) {
return EntryStatusResponseDto.builder()
.reservationId(r.getId().toString())
.reservationNumber(r.getReservationNumber())
.userId(r.getUser().getId().toString())
.partySize(r.getPartySize())
.userName(r.getUser().getNickname())
.createdAt(r.getRequestedAt())
.status(r.getStatus().name())
.calledAt(r.getCalledAt())
.confirmedAt(r.getConfirmedAt())
.cancelledAt(r.getCancelledAt())
.message(switch (r.getStatus()) {
case CALLING -> r.getUser().getNickname() + "님을 호출하였습니다.";
case CONFIRMED -> r.getUser().getNickname() + "님의 입장이 완료되었습니다.";
case CANCELLED -> r.getUser().getNickname() + "님의 예약이 취소되었습니다.";
default -> "";
})
.build();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
@Schema(description = "대기 사용자 응답 DTO")
public class WaitingUserResponse {

@Schema(description = "예약 ID", example = "1201")
private String id; // reservationId
@Schema(description = "예약 ID", example = "16-20240201-0002")
private String reservationNumber;

@Schema(description = "유저 ID", example = "16")
private String userId;
Expand All @@ -39,12 +39,24 @@ public class WaitingUserResponse {

public static WaitingUserResponse fromEntity(Reservation reservation) {
return WaitingUserResponse.builder()
.id(reservation.getId().toString())
.reservationNumber(reservation.getReservationNumber())
.userId(reservation.getUser().getId().toString())
.partySize(reservation.getPartySize())
.userName(reservation.getUser().getNickname())
.createdAt(reservation.getRequestedAt())
.status(reservation.getStatus().name())
.build();
}

public static WaitingUserResponse fromRedis(String reservationId, String userId, Integer partySize, String userName, LocalDateTime createdAt, String status, Double score) {
return WaitingUserResponse.builder()
.reservationNumber(reservationId)
.userId(userId)
.partySize(partySize)
.userName(userName)
.createdAt(createdAt)
.status(status)
.score(score)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.nowait.applicationadmin.reservation.repository;

import java.time.Duration;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;

Expand All @@ -16,6 +16,7 @@
@Repository
@RequiredArgsConstructor
public class WaitingRedisRepository {

private final StringRedisTemplate redisTemplate;

// 대기열 전체 인원수 조회
Expand Down Expand Up @@ -54,6 +55,19 @@ public Integer getWaitingPartySize(Long storeId, String userId) {
return value == null ? null : Integer.valueOf(value.toString());
}

// ReservationNumber 조회
public String getReservationId(Long storeId, String userId) {
String status = getWaitingStatus(storeId, userId);
if (!"WAITING".equals(status) && !"CALLING".equals(status)) {
// 이미 종료된 대기라면, 예약 번호도 없던 것처럼 취급
return null;
}
String numberMapKey = RedisKeyUtils.buildReservationNumberKey(storeId);
Object val = redisTemplate.opsForHash().get(numberMapKey, userId);

return val != null ? val.toString() : null;
}

public void deleteWaiting(Long storeId, String userId) {
String statusKey = RedisKeyUtils.buildWaitingStatusKeyPrefix() + storeId;
redisTemplate.opsForHash().delete(statusKey, userId);
Expand All @@ -63,6 +77,26 @@ public void deleteWaiting(Long storeId, String userId) {

String partyKey = RedisKeyUtils.buildWaitingPartySizeKeyPrefix() + storeId;
redisTemplate.opsForHash().delete(partyKey, userId);

String numberMapKey = RedisKeyUtils.buildReservationNumberKey(storeId);
redisTemplate.opsForHash().delete(numberMapKey, userId);

String key = RedisKeyUtils.buildWaitingCalledAtKeyPrefix() + storeId;
redisTemplate.opsForHash().delete(key, userId);
}

// 호출 시각 기록
public void setWaitingCalledAt(Long storeId, String userId, long timestamp) {
String key = RedisKeyUtils.buildWaitingCalledAtKeyPrefix() + storeId;
redisTemplate.opsForHash().put(key, userId, String.valueOf(timestamp));

redisTemplate.expireAt(key, RedisKeyUtils.expireAtNext03());
}

public Long getWaitingCalledAt(Long storeId, String userId) {
String key = RedisKeyUtils.buildWaitingCalledAtKeyPrefix() + storeId;
Object val = redisTemplate.opsForHash().get(key, userId);
return val == null ? null : Long.valueOf(val.toString());
}
}

Loading