Skip to content

Conversation

@HyemIin
Copy link
Member

@HyemIin HyemIin commented Jul 8, 2025

작업 요약

Issue Link

문제점 및 어려움

해결 방안

Reference

Summary by CodeRabbit

  • 신규 기능

    • 중복 예약 시도를 방지하는 기능이 추가되었습니다. 동일한 사용자와 매장에 대해 대기 중인 예약이 이미 존재하면 예약이 생성되지 않습니다.
    • 대기 기능이 비활성화된 매장에 대한 예약 시도 시 명확한 오류 메시지가 제공됩니다.
  • 버그 수정

    • 매장을 찾을 수 없는 경우, 더 명확한 오류 메시지와 예외 처리가 제공됩니다.
  • 개선 사항

    • 카카오 로그인 시 신규 사용자 등록 시 storeId가 기본값(0)으로 초기화됩니다.
    • 중복 예약 및 대기 비활성화 관련 오류 발생 시 사용자에게 명확한 오류 메시지와 코드가 반환됩니다.

@coderabbitai
Copy link

coderabbitai bot commented Jul 8, 2025

Walkthrough

이 변경사항은 중복 예약 방지를 위한 예외 처리 로직을 도입하고, 관련 예외 및 에러 메시지, 저장소 메서드, 예외 핸들러를 추가 및 수정합니다. 또한 OAuth2 사용자 등록 시 누락된 필드 초기화가 포함되어 있습니다.

Changes

파일/경로 요약 변경 내용 요약
.../exception/GlobalExceptionHandler.java DuplicateReservationException, StoreWaitingDisabledException 예외 핸들러 메서드 추가 및 관련 import 추가
.../oauth/oauth2/CustomOAuth2UserService.java 카카오 OAuth2 회원가입 시 User 엔티티의 storeId 필드 0L로 초기화 추가
.../reservation/service/ReservationService.java 예약 생성 시 매장 존재 확인, 대기 활성화 여부 검사, 중복 예약 검사 및 예외 처리 추가
.../exception/ErrorMessage.java DUPLICATE_RESERVATION, STORE_WAITING_DISABLED 에러 메시지/코드 enum 상수 추가
.../reservation/exception/DuplicateReservationException.java 중복 예약 예외 클래스 신설, 에러 메시지 상수 사용
.../reservation/repository/ReservationRepository.java 사용자, 매장, 상태 리스트로 예약 존재 여부 확인하는 메서드 추가 및 관련 import 추가
.../store/exception/StoreWaitingDisabledException.java 매장 대기 비활성화 예외 클래스 신설, 에러 메시지 상수 사용

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
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee8fd1c and f7b311f.

📒 Files selected for processing (4)
  • 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/reservation/service/ReservationService.java (3 hunks)
  • nowait-common/src/main/java/com/nowait/common/exception/ErrorMessage.java (2 hunks)
  • nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/store/exception/StoreWaitingDisabledException.java (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/store/exception/StoreWaitingDisabledException.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/service/ReservationService.java
  • nowait-common/src/main/java/com/nowait/common/exception/ErrorMessage.java
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/exception/GlobalExceptionHandler.java
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot requested a review from Jjiggu July 8, 2025 09:22
Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5b7b907 and 0806f71.

📒 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으로 변경하여 더 구체적인 예외 처리를 제공합니다.

@HyemIin HyemIin merged commit 0a52ceb into develop Jul 8, 2025
1 check passed
@HyemIin HyemIin deleted the feature/#72-예약중복등록방지 branch July 8, 2025 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants