Skip to content

Conversation

@doup2001
Copy link
Contributor

@doup2001 doup2001 commented May 25, 2025

📌 작업한 내용

✨feat/ZIP-22 : 가중치 스웨거 및 @Valid 구현

🔍 참고 사항

🖼️ 스크린샷

🔗 관련 이슈

✅ 체크리스트

  • 로컬에서 빌드 및 테스트 완료
  • 코드 리뷰 반영 완료
  • 문서화 필요 여부 확인

Summary by CodeRabbit

  • 신규 기능

    • 유저 가중치 API에 대한 Swagger 문서화가 추가되어 API 사용 방법이 명확하게 안내됩니다.
  • 버그 수정

    • 유저 가중치 요청 시 필수 입력값 및 값 범위(1~100)에 대한 유효성 검사가 강화되어 잘못된 입력을 방지합니다.
  • 개선사항

    • 유저 가중치 생성 시 인증된 사용자 정보를 명확히 처리하여 보안성과 일관성이 향상되었습니다.
    • 일부 접근 권한 정책이 조정되어, 특정 API 경로에 대한 접근 제어가 강화되었습니다.

@doup2001 doup2001 self-assigned this May 25, 2025
@coderabbitai
Copy link

coderabbitai bot commented May 25, 2025

Walkthrough

이 변경사항은 유저 가중치 API의 명세 인터페이스를 도입하고, 요청 및 응답 객체의 유효성 검증을 강화하며, 인증된 사용자 정보를 명시적으로 처리하도록 서비스 계층과 API 계층의 메서드 시그니처를 수정합니다. 또한, 접근 제어 정책이 일부 조정되었습니다.

Changes

파일/경로 요약 변경 내용 요약
.../security/jwt/util/RequestMatcherHolder.java 공개 요청 패턴에서 POST /error 제거, GET /api/v1/weight/**에 MEMBER 이상 권한 추가, Swagger 관련 패턴 순서 및 항목 조정
.../server/adapter/in/web/UserWeightApi.java UserWeightApiSpec 인터페이스 구현, create/delete 메서드에 사용자 인증 정보 명시적 전달 및 유효성 검증 추가
.../server/adapter/in/web/dto/request/UserWeightRequest.java id, userId 필드 제거, 가중치 필드를 Integer로 변경 및 @NotNull, @min, @max 유효성 검증 어노테이션 추가
.../server/adapter/in/web/swagger/UserWeightApiSpec.java UserWeightApiSpec 인터페이스 신규 추가, Swagger/OpenAPI 문서화 및 예제 페이로드 상수 정의
.../server/application/in/user/UserWeightUseCase.java createWeight 메서드에 userId 파라미터 추가
.../server/application/service/UserWeightService.java createWeight 메서드에 userId 파라미터 추가, 내부 로직에서 명시적 userId 사용

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Controller (UserWeightApi)
    participant Service (UserWeightService)
    participant UseCase (UserWeightUseCase)
    participant DB

    Client->>Controller (UserWeightApi): POST /api/v1/weight (UserWeightRequest, JWT)
    Controller->>Service (UserWeightService): createWeight(userId, UserWeightRequest)
    Service->>UseCase (UserWeightUseCase): createWeight(userId, UserWeightRequest)
    UseCase->>DB: Save UserWeight
    DB-->>UseCase: Saved UserWeight
    UseCase-->>Service: UserWeight
    Service-->>Controller: UserWeight
    Controller-->>Client: ApiResponse<String>
Loading

Possibly related PRs

Suggested labels

✨ Feature, 📬 API

Poem

🐇
유저 가중치 API에 봄바람이 불어와,
검증과 명세가 튼튼하게 자리 잡았네.
인증 정보 또렷하게, 요청은 꼼꼼하게,
바뀐 시그니처에 토끼도 깡충!
코드밭에 새싹처럼
변화의 기쁨이 자라난다.
🌱

✨ 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
Copy link

Test Coverage Report

File Coverage [0%] 🍏
UserWeightService.java 0% 🍏
UserWeightApi.java 0% 🍏
Total Project Coverage 31.68% 🍏

@github-actions
Copy link

Test Results

 43 files  ±0   43 suites  ±0   5s ⏱️ ±0s
111 tests ±0  111 ✅ ±0  0 💤 ±0  0 ❌ ±0 
112 runs  ±0  112 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 99b7401. ± Comparison against base commit 0a2003e.

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: 0

🧹 Nitpick comments (3)
src/main/java/com/zipte/platform/server/adapter/in/web/UserWeightApi.java (1)

23-30: 보안 강화 및 유효성 검증이 잘 구현되었습니다.

다음과 같은 개선사항이 포함되어 있습니다:

  • @Valid 어노테이션으로 요청 데이터 유효성 검증 강화
  • PrincipalDetails에서 직접 userId 추출로 보안 향상
  • 서비스 계층에 명시적으로 userId 전달

코멘트 스타일을 일관성 있게 개선할 수 있습니다:

-        /// UserId 추출
+        // UserId 추출
src/main/java/com/zipte/platform/server/adapter/in/web/swagger/UserWeightApiSpec.java (2)

20-33: create 메서드의 Swagger 문서화가 잘 구성되었습니다.

상세한 설명과 예제가 포함되어 있어 API 사용자에게 도움이 됩니다.

예제 참조에서 오타를 수정하면 더 좋겠습니다:

-                                    @ExampleObject(name = "나의 가중치 등록 예시", value = SUCCESS_PAYLOAD),
+                                    @ExampleObject(name = "나의 가중치 등록 예시", value = SUCCESS_PAYLOAD)

마지막 쉼표를 제거하여 배열 끝임을 명확히 표시하는 것이 좋습니다.


53-62: 예제 페이로드가 실용적입니다.

실제 사용 가능한 JSON 형태의 예제 데이터가 제공되어 API 테스트에 도움이 됩니다.

JSON 형식을 더 깔끔하게 정리할 수 있습니다:

     String SUCCESS_PAYLOAD = """
             {
-               "convenience": 4,
-               "transportation": 5,
-               "regionPreference": 3,
-               "parkAccess": 2,
-               "distanceToWork": 5
+                "convenience": 4,
+                "transportation": 5,
+                "regionPreference": 3,
+                "parkAccess": 2,
+                "distanceToWork": 5
              }
-            
             """;

들여쓰기를 일관성 있게 조정하고 불필요한 빈 줄을 제거하면 더 깔끔합니다.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0a2003e and 99b7401.

📒 Files selected for processing (6)
  • src/main/java/com/zipte/platform/security/jwt/util/RequestMatcherHolder.java (2 hunks)
  • src/main/java/com/zipte/platform/server/adapter/in/web/UserWeightApi.java (2 hunks)
  • src/main/java/com/zipte/platform/server/adapter/in/web/dto/request/UserWeightRequest.java (1 hunks)
  • src/main/java/com/zipte/platform/server/adapter/in/web/swagger/UserWeightApiSpec.java (1 hunks)
  • src/main/java/com/zipte/platform/server/application/in/user/UserWeightUseCase.java (1 hunks)
  • src/main/java/com/zipte/platform/server/application/service/UserWeightService.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (13)
src/main/java/com/zipte/platform/security/jwt/util/RequestMatcherHolder.java (2)

68-69: 가중치 API 보안 설정이 적절하게 구성되었습니다.

새로운 가중치 API 엔드포인트가 MEMBER 역할을 요구하도록 설정되어 있어, 다른 사용자별 API들과 일관된 보안 정책을 유지하고 있습니다.


93-96: Swagger UI 설정이 올바르게 업데이트되었습니다.

swagger-ui.html 엔드포인트가 추가되고 순서가 조정되어 API 문서화 접근성이 향상되었습니다.

src/main/java/com/zipte/platform/server/application/in/user/UserWeightUseCase.java (1)

22-22: 메서드 시그니처 변경이 보안 관점에서 적절합니다.

명시적인 userId 매개변수 추가로 사용자 컨텍스트를 명확하게 처리하며, 요청 객체에서 사용자 ID를 추출하는 의존성을 제거하여 보안성이 향상되었습니다.

src/main/java/com/zipte/platform/server/application/service/UserWeightService.java (1)

27-42: 서비스 구현이 인터페이스 변경사항과 일관되게 업데이트되었습니다.

명시적인 userId 매개변수 사용으로 사용자 컨텍스트 처리가 개선되었고, 사용자 존재 확인 및 도메인 객체 생성 로직이 적절하게 수정되었습니다.

src/main/java/com/zipte/platform/server/adapter/in/web/dto/request/UserWeightRequest.java (2)

3-5: 검증 어노테이션 임포트가 적절하게 추가되었습니다.

Jakarta Validation API를 사용하여 표준 검증 기능을 구현했습니다.


11-34:

Details

❓ Verification inconclusive

포괄적인 검증 규칙이 잘 구현되었습니다.

모든 가중치 필드에 대해 @NotNull, @min(1), @max(100) 검증이 적용되었고, 한국어 에러 메시지가 제공되어 사용자 경험이 향상되었습니다. Integer 타입 사용으로 null 검증이 가능해졌습니다.

그런데 가중치 값들의 합계에 대한 검증 로직을 확인해보시기 바랍니다. 각 가중치가 1-100 범위일 때, 총합이 100을 초과할 수 있는지 비즈니스 요구사항을 검토해주세요.

다음 스크립트로 가중치 합계 검증 로직이 있는지 확인해보겠습니다:


🏁 Script executed:

#!/bin/bash
# 가중치 합계 검증 로직 확인
rg -A 10 -B 5 "sum.*weight|weight.*sum|total.*weight|weight.*total" --type java

Length of output: 81


가중치 합계 검증 로직 확인 필요

현재 코드베이스에서 가중치 총합(예: 5개 필드 합계)이 100을 초과하지 않는지 제한하는 검증 로직을 찾을 수 없습니다.
비즈니스 요구사항상 총합이 100 이하로 제한되어야 하는지 확인 후, 아래 사항을 반영해 주세요.

  • 총합 검증이 필요하다면 DTO에 @AssertTrue 메서드를 추가하거나 서비스 레이어에서 합산 후 검증 로직을 구현
  • 검증 실패 시 적절한 에러 메시지(예: “가중치 총합은 100을 초과할 수 없습니다.”) 제공
src/main/java/com/zipte/platform/server/adapter/in/web/UserWeightApi.java (3)

7-7: 새로운 import 문이 올바르게 추가되었습니다.

Swagger 인터페이스와 validation 어노테이션을 위한 import가 적절히 추가되었습니다.

Also applies to: 10-10


18-18: Swagger 인터페이스 구현이 올바르게 적용되었습니다.

UserWeightApiSpec 인터페이스를 구현하여 API 문서화와 계약을 명확히 했습니다.


44-45: 메서드 시그니처 포맷팅이 개선되었습니다.

파라미터 포맷팅이 더 읽기 쉽게 조정되었습니다.

src/main/java/com/zipte/platform/server/adapter/in/web/swagger/UserWeightApiSpec.java (4)

1-16: 패키지 구조와 import 문이 적절합니다.

Swagger 관련 클래스들이 올바른 패키지에 위치하고 필요한 의존성들이 정확히 import되었습니다.


17-18: API 태그 설정이 명확합니다.

한국어로 된 명확한 API 그룹 명칭과 설명이 제공되어 문서화 품질이 좋습니다.


35-40: getMyWeight 메서드 문서화가 적절합니다.

간결하고 명확한 설명으로 메서드의 목적이 잘 드러납니다.


42-50: delete 메서드 문서화가 상세합니다.

파라미터에 대한 설명과 예제가 포함되어 있어 좋습니다.

@doup2001 doup2001 merged commit 0006198 into develop May 25, 2025
3 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