-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor: 웨이팅 예외처리 추가 및 공통 메서드 추출 #194
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
Conversation
|
""" Walkthrough컨트롤러의 Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ReservationController
participant ReservationService
participant ReservationRepository
Client->>ReservationController: getCompletedReservationList(storeId, memberDetails)
ReservationController->>ReservationService: getCompletedWaitingUserDetails(storeId, memberDetails)
ReservationService->>ReservationService: authorize(memberDetails, storeId)
ReservationService->>ReservationRepository: findAllByStore_StoreIdAndStatusInAndRequestedAtBetween(...)
ReservationRepository-->>ReservationService: 예약 리스트 반환
ReservationService-->>ReservationController: WaitingUserResponse 리스트 반환
ReservationController-->>Client: 응답 반환
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–20 minutes Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
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: 0
🧹 Nitpick comments (1)
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/service/ReservationService.java (1)
318-325: 권한 검증 로직이 잘 구현되었습니다.
authorize메서드는 다음과 같이 적절하게 구현되었습니다:
- 사용자 존재 여부 확인
- 역할 기반 권한 검증 (SUPER_ADMIN은 모든 매장 접근 가능)
- 리소스 기반 권한 검증 (일반 사용자는 자신의 매장만 접근)
- 적절한 예외 처리
성능 최적화를 위해 빈번한 권한 검증 호출 시 사용자 정보 캐싱을 고려해보세요:
// 예시: 메서드 레벨 캐싱 어노테이션 추가 @Cacheable(value = "userAuth", key = "#member.id + '_' + #storeId") private User authorize(Long storeId, MemberDetails member) { // 기존 로직 }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/controller/ReservationController.java(1 hunks)nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/service/ReservationService.java(2 hunks)nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/reservation/repository/ReservationRepository.java(1 hunks)
🔇 Additional comments (5)
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/controller/ReservationController.java (1)
56-56: LGTM! 인증 정보 전달이 적절합니다.서비스 계층에서 권한 검증을 수행할 수 있도록 인증된 사용자 정보를 전달하는 변경사항이 올바릅니다. 컨트롤러에서 서비스로의 책임 분리가 잘 이루어졌습니다.
nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/reservation/repository/ReservationRepository.java (1)
19-19: ReservationRepository 인터페이스 정리 확인됨삭제된 메서드(
findByStore_StoreIdAndUserId,findByStore_StoreIdAndUserIdAndRequestedAtBetween,findByStore_StoreIdAndUserIdAndStatusInAndRequestedAtBetween, 원본findAllByStore_StoreId등)가 코드베이스에서 호출되지 않음을 확인했습니다.
남아있는 메서드들도 서비스 계층(예:findAllByStore_StoreIdOrderByRequestedAtAsc,findAllByStore_StoreIdAndStatusInAndRequestedAtBetween,findFirstByStore_StoreIdAndUserIdAndStatusInAndRequestedAtBetweenOrderByRequestedAtDesc,existsByUserAndStoreAndStatusIn)과 정확히 맞아떨어집니다.이 PR을 승인합니다.
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/service/ReservationService.java (3)
178-189: 권한 검증과 예외 처리 추가가 우수합니다.메서드에
MemberDetails파라미터를 추가하고 권한 검증 로직을 포함한 것은 보안 측면에서 매우 좋은 개선사항입니다. 또한 예약 결과가 없을 경우 명시적으로 예외를 던지는 것도 PR 목표에 부합합니다.
305-315: 공통 메서드 추출이 훌륭합니다.
findTodayWaiting메서드 추출은 다음과 같은 장점이 있습니다:
- 타임존 처리를 명시적으로 "Asia/Seoul"로 설정
- 날짜 범위 계산 로직의 재사용성 향상
- 단일 책임 원칙 준수
코드의 가독성과 유지보수성이 크게 개선되었습니다.
301-326: 재사용 가능한 유사 패턴 없음 확인 완료
findTodayWaiting과authorize는 해당 서비스(ReservationService) 내에서만 사용되고, 다른 코드에는 동일한 권한 검증이나 오늘 날짜 조회 패턴이 존재하지 않습니다.
추가적인 재사용 대상이 없어 현 상태대로 유지해도 무방합니다.
작업 요약
Issue Link
#192
문제점 및 어려움
해결 방안
Reference
Summary by CodeRabbit
버그 수정
리팩터링