Skip to content

Conversation

@HyemIin
Copy link
Member

@HyemIin HyemIin commented Jul 18, 2025

작업 요약

  • 대기열 조회 및 취소 api 추가

Issue Link

#121

문제점 및 어려움

해결 방안

Reference

Summary by CodeRabbit

  • 신규 기능

    • 사용자가 특정 매장의 대기열 정보를 조회할 수 있는 API 엔드포인트가 추가되었습니다.
    • 사용자가 특정 매장의 대기열을 취소할 수 있는 API 엔드포인트가 추가되었습니다.
  • 버그 수정

    • 대기 등록 시 매장 관리자 계정은 대기 등록이 불가능하도록 역할 검증이 추가되었습니다.
  • 리팩터

    • 사용자 인증 정보를 일관성 있게 처리하도록 내부 로직이 개선되었습니다.

- 대기열 조회 및 취소 api 추가
@HyemIin HyemIin self-assigned this Jul 18, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 18, 2025

Walkthrough

ReservationController에 매장별 대기열 정보를 조회하고 취소할 수 있는 두 개의 새로운 REST API 엔드포인트가 추가되었습니다. ReservationService의 myWaitingInfo, cancelWaiting 메서드는 CustomOAuth2User를 인자로 받도록 시그니처가 변경되었으며, registerWaiting 메서드에는 매니저 역할 검증 로직이 추가되었습니다. WaitingRedisRepository의 getPartySize 메서드는 null 체크가 제거되었습니다.

Changes

파일/경로 변경 요약
.../reservation/controller/ReservationController.java 매장별 대기열 조회(GET) 및 취소(DELETE) REST API 엔드포인트 2개 추가, OpenAPI 문서화 추가
.../reservation/service/ReservationService.java myWaitingInfo, cancelWaiting 메서드가 CustomOAuth2User를 인자로 받도록 변경, registerWaiting에 역할 검증 로직 추가
.../reservation/repository/WaitingRedisRepository.java getPartySize 메서드의 null 체크 로직 제거

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
Loading

Possibly related PRs

Suggested reviewers

  • Jjiggu
✨ 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 18, 2025 09:41
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: 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.getPartySizeredisTemplate.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: 불필요한 입력 검증 로직

userIdLong.toString()으로 생성되므로 trim().isEmpty() 검증이 불필요합니다. Long 값은 항상 유효한 문자열을 생성합니다.

다음과 같이 수정하는 것을 고려하세요:

-		if (storeId == null || userId.trim().isEmpty()) {
+		if (storeId == null) {

83-87: 불필요한 입력 검증 로직

cancelWaiting 메서드에서도 동일한 문제가 있습니다. userIdLong.toString()으로 생성되므로 trim().isEmpty() 검증이 불필요합니다.

다음과 같이 수정하는 것을 고려하세요:

-		if (storeId == null || userId.trim().isEmpty()) {
+		if (storeId == null) {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6b63816 and 9085d4f.

📒 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());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Suggested change
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.

@HyemIin HyemIin merged commit 9b469de into develop Jul 18, 2025
2 checks passed
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