-
Notifications
You must be signed in to change notification settings - Fork 0
feat(Reservation): 예약 중복 등록 방지 #73
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/#72-\uC608\uC57D\uC911\uBCF5\uB4F1\uB85D\uBC29\uC9C0"
Conversation
Walkthrough이 변경사항은 중복 예약 방지를 위한 예외 처리 로직을 도입하고, 관련 예외 및 에러 메시지, 저장소 메서드, 예외 핸들러를 추가 및 수정합니다. 또한 OAuth2 사용자 등록 시 누락된 필드 초기화가 포함되어 있습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ReservationService
participant StoreRepository
participant ReservationRepository
participant ExceptionHandler
User->>ReservationService: create(userId, storeId, ...)
ReservationService->>StoreRepository: findById(storeId)
StoreRepository-->>ReservationService: Store or throw StoreNotFoundException
ReservationService->>ReservationRepository: existsByUserAndStoreAndStatusIn(user, store, [WAITING, CALLING])
ReservationRepository-->>ReservationService: true/false
alt 중복 예약 존재
ReservationService-->>ExceptionHandler: throw DuplicateReservationException
ExceptionHandler-->>User: ErrorResponse(DUPLICATE_RESERVATION)
else 대기 비활성화
ReservationService-->>ExceptionHandler: throw StoreWaitingDisabledException
ExceptionHandler-->>User: ErrorResponse(STORE_WAITING_DISABLED)
else 정상 예약 생성
ReservationService->>ReservationRepository: save(reservation)
ReservationRepository-->>ReservationService: Reservation
ReservationService-->>User: 예약 결과 반환
end
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
✨ 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: 2
🧹 Nitpick comments (1)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/oauth/oauth2/CustomOAuth2UserService.java (1)
57-57: 매직 넘버 대신 상수 사용을 권장합니다.하드코딩된
0L값을 직접 사용하는 것보다 의미 있는 상수로 정의하는 것이 좋습니다. 또한 OAuth2 사용자가 특정 스토어에 속하지 않은 경우storeId를 0으로 설정하는 것이 비즈니스 로직상 적절한지 확인이 필요합니다.다음과 같이 상수로 정의하는 것을 권장합니다:
+private static final Long DEFAULT_STORE_ID = 0L; User user = User.builder() .email(oAuth2Response.getEmail()) .nickname(oAuth2Response.getNickName()) .profileImage(oAuth2Response.getProfileImage()) .socialType(SocialType.KAKAO) .role(Role.USER) - .storeId(0L) + .storeId(DEFAULT_STORE_ID) .build();
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/exception/GlobalExceptionHandler.java(2 hunks)nowait-app-user-api/src/main/java/com/nowait/applicationuser/oauth/oauth2/CustomOAuth2UserService.java(1 hunks)nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/service/ReservationService.java(3 hunks)nowait-common/src/main/java/com/nowait/common/exception/ErrorMessage.java(1 hunks)nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/reservation/exception/DuplicateReservationException.java(1 hunks)nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/reservation/repository/ReservationRepository.java(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/exception/GlobalExceptionHandler.java (1)
nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/reservation/exception/DuplicateReservationException.java (1)
DuplicateReservationException(5-9)
🔇 Additional comments (8)
nowait-common/src/main/java/com/nowait/common/exception/ErrorMessage.java (1)
30-30: 새로운 에러 메시지 상수가 올바르게 추가되었습니다.중복 예약 방지를 위한 에러 메시지와 코드가 기존 패턴에 맞게 정의되어 있습니다.
nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/reservation/exception/DuplicateReservationException.java (1)
5-9: 예외 클래스가 올바르게 구현되었습니다.RuntimeException을 상속하고 중앙 집중화된 ErrorMessage를 사용하는 구조가 적절합니다.
nowait-app-user-api/src/main/java/com/nowait/applicationuser/exception/GlobalExceptionHandler.java (2)
29-29: import 문이 올바르게 추가되었습니다.DuplicateReservationException에 대한 import가 적절하게 추가되었습니다.
166-171: 예외 핸들러가 올바르게 구현되었습니다.DuplicateReservationException에 대한 핸들러가 기존 패턴에 맞게 구현되어 있으며, 적절한 HTTP 상태 코드와 에러 메시지를 반환합니다.
nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/reservation/repository/ReservationRepository.java (2)
8-8: 필요한 import 문들이 올바르게 추가되었습니다.새로운 저장소 메서드를 위한 ReservationStatus, Store, User import가 적절하게 추가되었습니다.
Also applies to: 10-11
16-16: 저장소 메서드가 올바르게 추가되었습니다.Spring Data JPA의 메서드 네이밍 규칙을 따르며, 중복 예약 체크를 위한 효율적인 구현입니다.
nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/service/ReservationService.java (2)
4-4: 필요한 import 문들이 올바르게 추가되었습니다.List와 StoreNotFoundException import가 적절하게 추가되었습니다.
Also applies to: 15-15
37-37: 예외 타입 변경이 올바르게 적용되었습니다.IllegalArgumentException에서 StoreNotFoundException으로 변경하여 더 구체적인 예외 처리를 제공합니다.
...ser-api/src/main/java/com/nowait/applicationuser/reservation/service/ReservationService.java
Show resolved
Hide resolved
...ser-api/src/main/java/com/nowait/applicationuser/reservation/service/ReservationService.java
Outdated
Show resolved
Hide resolved
- 예약 create 시 방어로직 추가
작업 요약
Issue Link
문제점 및 어려움
해결 방안
Reference
Summary by CodeRabbit
신규 기능
버그 수정
개선 사항