-
Notifications
You must be signed in to change notification settings - Fork 0
feat(Reservation): 대기열 조회 및 취소 #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "feature/#121-\uC0AC\uC6A9\uC790\uC8FC\uC810\uC608\uC57D\uAE30\uB2A5\uAC1C\uC120"
Conversation
- 대기열 조회 및 취소 api 추가
WalkthroughReservationController에 매장별 대기열 정보를 조회하고 취소할 수 있는 두 개의 새로운 REST API 엔드포인트가 추가되었습니다. ReservationService의 myWaitingInfo, cancelWaiting 메서드는 CustomOAuth2User를 인자로 받도록 시그니처가 변경되었으며, registerWaiting 메서드에는 매니저 역할 검증 로직이 추가되었습니다. WaitingRedisRepository의 getPartySize 메서드는 null 체크가 제거되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ReservationController
participant ReservationService
participant WaitingRedisRepository
Client->>ReservationController: GET /get/queue/redis/{storeId}
ReservationController->>ReservationService: myWaitingInfo(storeId, CustomOAuth2User)
ReservationService->>WaitingRedisRepository: getPartySize(storeId, userId)
WaitingRedisRepository-->>ReservationService: partySize
ReservationService-->>ReservationController: WaitingResponseDto
ReservationController-->>Client: API Success Response
Client->>ReservationController: DELETE /delete/queue/redis/{storeId}
ReservationController->>ReservationService: cancelWaiting(storeId, CustomOAuth2User)
ReservationService->>WaitingRedisRepository: (cancel logic)
WaitingRedisRepository-->>ReservationService: result
ReservationService-->>ReservationController: boolean
ReservationController-->>Client: API Success Response
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/service/ReservationService.java (1)
76-76: getPartySize 메서드에서 null 반환 시 NPE 방지 필요
WaitingRedisRepository.getPartySize는redisTemplate.opsForHash().get호출 결과가 null일 경우 바로toString()을 호출해 NPE가 발생할 수 있습니다. 다음과 같이 null 처리 로직을 추가해 기본값을 반환하거나 예외를 명확히 던지도록 수정해주세요.• 파일: nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/repository/WaitingRedisRepository.java
위치: 메서드 선언부(27–30행)제안 수정 예시:
public Integer getPartySize(Long storeId, String userId) { String partyKey = RedisKeyUtils.buildWaitingPartySizeKeyPrefix() + storeId; - Object value = redisTemplate.opsForHash().get(partyKey, userId); - return Integer.valueOf(value.toString()); + Object value = redisTemplate.opsForHash().get(partyKey, userId); + if (value == null) { + // 대기 인원 정보가 없을 땐 기본값 0 반환 + return 0; + } + return Integer.valueOf(value.toString()); }
🧹 Nitpick comments (2)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/service/ReservationService.java (2)
69-74: 불필요한 입력 검증 로직
userId는Long.toString()으로 생성되므로trim().isEmpty()검증이 불필요합니다. Long 값은 항상 유효한 문자열을 생성합니다.다음과 같이 수정하는 것을 고려하세요:
- if (storeId == null || userId.trim().isEmpty()) { + if (storeId == null) {
83-87: 불필요한 입력 검증 로직
cancelWaiting메서드에서도 동일한 문제가 있습니다.userId는Long.toString()으로 생성되므로trim().isEmpty()검증이 불필요합니다.다음과 같이 수정하는 것을 고려하세요:
- if (storeId == null || userId.trim().isEmpty()) { + if (storeId == null) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/controller/ReservationController.java(2 hunks)nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/repository/WaitingRedisRepository.java(1 hunks)nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/service/ReservationService.java(4 hunks)
🔇 Additional comments (3)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/service/ReservationService.java (1)
46-51: 매니저 역할 검증 로직 잘 구현됨매니저가 대기열에 등록하지 못하도록 하는 비즈니스 로직이 적절히 구현되었습니다.
nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/controller/ReservationController.java (2)
69-84: 대기열 조회 API 잘 구현됨새로운 GET 엔드포인트가 적절히 구현되었습니다. RESTful 설계 원칙을 따르고 있고, OpenAPI 문서화도 적절합니다.
86-100: 대기열 취소 API 잘 구현됨DELETE 엔드포인트가 적절한 HTTP 메서드를 사용하여 구현되었습니다. 기존 코드 패턴과 일관성을 유지하고 있습니다.
| String partyKey = RedisKeyUtils.buildWaitingPartySizeKeyPrefix() + storeId; | ||
| Object value = redisTemplate.opsForHash().get(partyKey, userId); | ||
| return value == null ? null : Integer.valueOf(value.toString()); | ||
| return Integer.valueOf(value.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null 체크 제거로 인한 NPE 위험
Redis에서 값을 가져올 때 null 체크를 제거하면 키가 존재하지 않을 경우 NullPointerException이 발생합니다.
다음과 같이 수정하여 안전한 처리를 보장하세요:
- return Integer.valueOf(value.toString());
+ return value != null ? Integer.valueOf(value.toString()) : null;또는 기본값을 반환하도록 수정:
- return Integer.valueOf(value.toString());
+ return value != null ? Integer.valueOf(value.toString()) : 0;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| return Integer.valueOf(value.toString()); | |
| return value != null | |
| ? Integer.valueOf(value.toString()) | |
| : 0; |
🤖 Prompt for AI Agents
In
nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/repository/WaitingRedisRepository.java
at line 30, the code directly converts a Redis value to Integer without checking
for null, which can cause a NullPointerException if the key does not exist. Add
a null check before converting the value, and return a default value (e.g., 0)
or handle the null case safely to prevent the exception.
작업 요약
Issue Link
#121
문제점 및 어려움
해결 방안
Reference
Summary by CodeRabbit
신규 기능
버그 수정
리팩터