Skip to content

[refactor] #105 RESTful URI 구조로 통일 및 Admin API 분리#106

Merged
2hyunjinn merged 4 commits intomainfrom
refactor/#105
May 5, 2025
Merged

[refactor] #105 RESTful URI 구조로 통일 및 Admin API 분리#106
2hyunjinn merged 4 commits intomainfrom
refactor/#105

Conversation

@2hyunjinn
Copy link
Copy Markdown
Member

@2hyunjinn 2hyunjinn commented May 5, 2025

📌 PR 제목

[refactor] #105 RESTful URI 구조로 통일 및 Admin API 분리

📌 PR 내용

  • 전체 컨트롤러의 URI를 RESTful하게 통일하고, admin 전용 API를 별도 컨트롤러로 분리했습니다.

🛠 작업 내용

  • /{festivalId}/participants/me 형태로 URI 구조 일관성 확보
  • Admin 전용 API를 AdminController로 분리
  • PointController 내 URI 일관성 확보
  • 중복되는 URI 패턴 정리 및 명확한 리소스 명명 적용

🔍 관련 이슈

Closes #105

📸 스크린샷 (Optional)

image

📚 레퍼런스 (Optional)

N/A

Summary by CodeRabbit

  • New Features

    • Introduced new admin endpoints for managing festivals, participants, and points, including creating festivals, retrieving festival details, searching participants by nickname, recharging points, and viewing participant point history.
  • Refactor

    • Updated and reorganized endpoint paths for participant and point operations to provide a more consistent and hierarchical URL structure.
    • Moved several data transfer objects to new package locations for improved organization.
  • Bug Fixes

    • Removed admin-related endpoints from non-admin controllers to prevent unauthorized access and improve endpoint clarity.
  • Style

    • Updated endpoint naming for verification to enhance clarity and consistency.

@2hyunjinn 2hyunjinn added the refactor This doesn't seem right label May 5, 2025
@2hyunjinn 2hyunjinn self-assigned this May 5, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented May 5, 2025

Walkthrough

This update introduces a new AdminController dedicated to administrative endpoints for managing festivals, participants, and points, moving related logic out of the previous controllers. The package structure for several DTOs is reorganized, relocating them under an admin-specific package. Participant and point-related endpoints are refactored for more RESTful and consistent URI patterns, with participant endpoints now nested under /v1/festivals/{festivalId}/participants and admin endpoints under /v1/admin/festivals. The FestivalController and PointController have admin-specific methods removed, and related imports are updated throughout the codebase.

Changes

File(s) Change Summary
src/main/java/org/festimate/team/api/admin/AdminController.java New controller for admin endpoints: festival creation, listing, detail, participant search, point recharge/history.
src/main/java/org/festimate/team/api/admin/dto/AdminFestivalDetailResponse.java,
AdminFestivalResponse.java,
FestivalRequest.java,
FestivalResponse.java,
SearchParticipantResponse.java
Moved DTOs from festival/participant packages to admin.dto package; no logic changes.
src/main/java/org/festimate/team/api/facade/FestivalFacade.java,
ParticipantFacade.java
Updated imports to use DTOs from new admin.dto package.
src/main/java/org/festimate/team/api/festival/FestivalController.java Removed admin endpoints; renamed /verify-code to /verify; updated JWT parsing logic.
src/main/java/org/festimate/team/api/participant/ParticipantController.java Refactored all endpoints to /v1/festivals/{festivalId}/participants; removed admin participant search endpoint.
src/main/java/org/festimate/team/api/point/PointController.java Removed admin endpoints; updated user point history endpoint path.
src/main/java/org/festimate/team/domain/festival/service/FestivalService.java,
impl/FestivalServiceImpl.java
Updated imports for FestivalRequest to new package.
src/test/java/org/festimate/team/api/facade/FestivalFacadeTest.java Updated import for FestivalRequest to new package.

Sequence Diagram(s)

sequenceDiagram
    participant Admin
    participant AdminController
    participant JwtService
    participant FestivalFacade
    participant ParticipantFacade
    participant PointFacade

    Admin->>AdminController: POST /v1/admin/festivals (createFestival)
    AdminController->>JwtService: parseTokenAndGetUserId(token)
    AdminController->>FestivalFacade: createFestival(userId, request)
    FestivalFacade-->>AdminController: FestivalResponse
    AdminController-->>Admin: ApiResponse<FestivalResponse>

    Admin->>AdminController: GET /v1/admin/festivals (getAllFestivals)
    AdminController->>JwtService: parseTokenAndGetUserId(token)
    AdminController->>FestivalFacade: getAllFestivals(userId)
    FestivalFacade-->>AdminController: List<AdminFestivalResponse>
    AdminController-->>Admin: ApiResponse<List<AdminFestivalResponse>>

    Admin->>AdminController: POST /v1/admin/festivals/{festivalId}/points (rechargePoints)
    AdminController->>JwtService: parseTokenAndGetUserId(token)
    AdminController->>PointFacade: rechargePoints(userId, festivalId, request)
    PointFacade-->>AdminController: void
    AdminController-->>Admin: ApiResponse<Void>
Loading

Assessment against linked issues

Objective Addressed Explanation
Refactor participant-related API URIs for RESTful consistency (#105)
Move admin endpoints to a dedicated AdminController and package (#105)
Remove admin logic from non-admin controllers and update imports accordingly (#105)

Possibly related PRs

Poem

In the warren of code, a new path appears,
Admins now gather where logic is clear.
Endpoints align, RESTful and neat,
DTOs hop to a new package retreat.
Controllers refactored, confusion undone—
This rabbit applauds: refactoring won!
🐇✨


📜 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 56ed78e and 05e3780.

📒 Files selected for processing (1)
  • src/main/java/org/festimate/team/api/admin/AdminController.java (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/org/festimate/team/api/admin/AdminController.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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
Copy Markdown

github-actions bot commented May 5, 2025

Test Results

40 tests   40 ✅  1s ⏱️
10 suites   0 💤
10 files     0 ❌

Results for commit 05e3780.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown

@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

🧹 Nitpick comments (4)
src/main/java/org/festimate/team/api/festival/FestivalController.java (1)

24-25: Consider storing and passing the userId to the facade.

The method parses the user ID from the token but doesn't store or pass it to the facade. For consistency with other methods, consider passing the user ID to the facade method.

-        jwtService.parseTokenAndGetUserId(accessToken);
-        FestivalVerifyResponse response = festivalFacade.verifyFestival(request);
+        Long userId = jwtService.parseTokenAndGetUserId(accessToken);
+        FestivalVerifyResponse response = festivalFacade.verifyFestival(userId, request);
src/main/java/org/festimate/team/api/admin/AdminController.java (1)

56-66: Consistent error handling should be implemented.

While the controller properly delegates to facade methods, there's no explicit error handling. Consider implementing global exception handling or adding try-catch blocks to handle potential errors from the facade layer.

src/main/java/org/festimate/team/api/participant/ParticipantController.java (2)

87-97: Consider response status for the modify endpoint.

The modifyMyMessage endpoint returns ResponseBuilder.created(null) which suggests resource creation, but this method is performing an update. Consider using ResponseBuilder.ok(null) to better reflect the HTTP semantics.

-        return ResponseBuilder.created(null);
+        return ResponseBuilder.ok(null);

22-31: Inconsistent parameter naming style.

In the getFestivalType method, the festivalId parameter is defined as @PathVariable Long festivalId, whereas in other methods it's defined with the explicit name, e.g., @PathVariable("festivalId") Long festivalId. Consider standardizing this approach throughout the controller for better consistency.

-            @PathVariable Long festivalId,
+            @PathVariable("festivalId") Long festivalId,
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5a022be and 56ed78e.

📒 Files selected for processing (14)
  • src/main/java/org/festimate/team/api/admin/AdminController.java (1 hunks)
  • src/main/java/org/festimate/team/api/admin/dto/AdminFestivalDetailResponse.java (1 hunks)
  • src/main/java/org/festimate/team/api/admin/dto/AdminFestivalResponse.java (1 hunks)
  • src/main/java/org/festimate/team/api/admin/dto/FestivalRequest.java (1 hunks)
  • src/main/java/org/festimate/team/api/admin/dto/FestivalResponse.java (1 hunks)
  • src/main/java/org/festimate/team/api/admin/dto/SearchParticipantResponse.java (1 hunks)
  • src/main/java/org/festimate/team/api/facade/FestivalFacade.java (1 hunks)
  • src/main/java/org/festimate/team/api/facade/ParticipantFacade.java (1 hunks)
  • src/main/java/org/festimate/team/api/festival/FestivalController.java (1 hunks)
  • src/main/java/org/festimate/team/api/participant/ParticipantController.java (6 hunks)
  • src/main/java/org/festimate/team/api/point/PointController.java (1 hunks)
  • src/main/java/org/festimate/team/domain/festival/service/FestivalService.java (1 hunks)
  • src/main/java/org/festimate/team/domain/festival/service/impl/FestivalServiceImpl.java (1 hunks)
  • src/test/java/org/festimate/team/api/facade/FestivalFacadeTest.java (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/main/java/org/festimate/team/api/admin/AdminController.java (1)
src/main/java/org/festimate/team/global/response/ResponseBuilder.java (1)
  • ResponseBuilder (5-19)
src/main/java/org/festimate/team/api/participant/ParticipantController.java (1)
src/main/java/org/festimate/team/global/response/ResponseBuilder.java (1)
  • ResponseBuilder (5-19)
🔇 Additional comments (17)
src/main/java/org/festimate/team/api/admin/dto/AdminFestivalResponse.java (1)

1-1: Package Declaration Updated for Admin Context

The package has been changed to org.festimate.team.api.admin.dto to reflect the new AdminController boundary. Confirm that the directory path (.../api/admin/dto/) matches this declaration and that all references to this class in facades and controllers are updated.

src/main/java/org/festimate/team/api/admin/dto/SearchParticipantResponse.java (1)

1-1: Package Declaration Updated for Admin Participant Search

The package change to org.festimate.team.api.admin.dto correctly isolates admin-specific DTOs. Ensure the ParticipantController no longer references this DTO and that the AdminController imports it from the new location.

src/main/java/org/festimate/team/api/facade/ParticipantFacade.java (1)

4-4: Import Updated to Admin DTO for Participant Search

The import for SearchParticipantResponse now points to the admin DTO package, aligning with the new AdminController. Verify that no stale imports of the old package remain and that any controller or service using this DTO references the updated path.

src/main/java/org/festimate/team/domain/festival/service/impl/FestivalServiceImpl.java (1)

7-7: Import Updated to Admin DTO for FestivalRequest

The FestivalRequest import now references the admin-specific DTO package, matching the shift of festival management endpoints to AdminController. Confirm that validation and mapping logic consume the correct DTO and that the original non-admin endpoints no longer rely on this class.

src/main/java/org/festimate/team/domain/festival/service/FestivalService.java (1)

3-3: Interface Signature Adjusted to Admin FestivalRequest

The service interface now accepts FestivalRequest from org.festimate.team.api.admin.dto. Ensure downstream implementations and callers (including facades and controllers) are updated to use the admin DTO and that no legacy imports remain.

src/test/java/org/festimate/team/api/facade/FestivalFacadeTest.java (1)

3-3: Correct import for relocated FestivalRequest.
The import has been updated to org.festimate.team.api.admin.dto.FestivalRequest to reflect the DTO move under the admin package.

src/main/java/org/festimate/team/api/admin/dto/FestivalRequest.java (1)

1-1: Package declaration updated for admin scope.
Moving FestivalRequest into org.festimate.team.api.admin.dto aligns with separating admin APIs into their own controller.

src/main/java/org/festimate/team/api/admin/dto/AdminFestivalDetailResponse.java (1)

1-1: Package declaration aligned with admin DTOs.
AdminFestivalDetailResponse has been moved to the admin.dto package, matching the new AdminController structure.

src/main/java/org/festimate/team/api/admin/dto/FestivalResponse.java (1)

1-1: Admin DTO package placement confirmed.
FestivalResponse now resides under org.festimate.team.api.admin.dto as part of the admin API refactoring.

src/main/java/org/festimate/team/api/facade/FestivalFacade.java (1)

4-10: Explicit DTO imports for improved clarity.
Replacing the wildcard import with explicit imports from admin.dto and festival.dto ensures that it's clear which controllers use which DTOs, supporting the separation of admin and public APIs.

src/main/java/org/festimate/team/api/point/PointController.java (2)

20-20: Good refactoring to RESTful URI structure.

The endpoint path now follows a more consistent RESTful pattern with nested resources. The change from /festivals/{festivalId}/me/points to /festivals/{festivalId}/participants/me/points clearly identifies the resource hierarchy.


1-28: Excellent job isolating admin endpoints.

The controller now focuses solely on user-specific point operations, with admin functionality properly moved to a dedicated AdminController. This separation of concerns follows good API design principles.

src/main/java/org/festimate/team/api/festival/FestivalController.java (1)

19-19: Good simplification of the endpoint name.

Changing from /verify-code to /verify creates a cleaner, more concise URI that still clearly communicates the endpoint's purpose.

src/main/java/org/festimate/team/api/admin/AdminController.java (2)

1-89: Well-structured admin controller with consolidated endpoints.

The new AdminController successfully centralizes all administrative operations for festivals, participants, and points under a single, dedicated controller. The URI structure is consistent, following REST best practices with clear resource hierarchies.


19-19: Good choice of base request mapping.

Using /v1/admin/festivals as the base path clearly separates admin APIs from regular user APIs and establishes festivals as the primary resource.

src/main/java/org/festimate/team/api/participant/ParticipantController.java (2)

14-14: Good refactoring of base request mapping.

Changing from /v1 to /v1/festivals provides a clearer resource hierarchy and better aligns with RESTful URI conventions.


33-42: Appropriate change from POST to GET for resource retrieval.

The entryFestival endpoint now correctly uses GET instead of POST, following HTTP method semantics since it retrieves a participant's entry status rather than creating a resource.

@2hyunjinn 2hyunjinn merged commit 8e42e95 into main May 5, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[refactor] RESTful URI 구조로 통일 및 Admin API 분리

1 participant