Skip to content

Comments

[feat] #139 페스티벌 공동 호스트 추가 API 구현#140

Merged
2hyunjinn merged 3 commits intomainfrom
feat/#139
May 16, 2025
Merged

[feat] #139 페스티벌 공동 호스트 추가 API 구현#140
2hyunjinn merged 3 commits intomainfrom
feat/#139

Conversation

@2hyunjinn
Copy link
Member

@2hyunjinn 2hyunjinn commented May 16, 2025

📌 PR 제목

[feat] #139 페스티벌 공동 호스트 추가 API 구현

📌 PR 내용

  • 페스티벌 생성자가 특정 참가자를 공동 호스트로 추가할 수 있는 API를 구현했습니다.
  • 기존 호스트 여부를 검증한 뒤, 해당 참가자의 유저 정보를 기반으로 FestivalHost 엔티티를 생성합니다.

🛠 작업 내용

  • FestivalHostFacade.addHost() 메서드 구현
  • 유저, 페스티벌, 참가자 조회 및 검증 로직 추가
  • FestivalHostService.addHost() 도메인 로직 구현
  • DB에 새로운 공동 호스트 정보 저장

🔍 관련 이슈

Closes #139

📸 스크린샷 (Optional)

image

📚 레퍼런스 (Optional)

N/A

Summary by CodeRabbit

  • New Features

    • Added a new POST endpoint for administrators to assign hosts to festivals.
    • Introduced support for managing festival hosts, allowing administrators to add a participant as a host to a festival.
  • Bug Fixes

    • None.
  • Documentation

    • None.
  • Refactor

    • Internal restructuring of entity and repository packages related to festival hosts (no impact on user experience).
  • Tests

    • None.
  • Chores

    • None.
  • Revert

    • None.

@2hyunjinn 2hyunjinn self-assigned this May 16, 2025
@2hyunjinn 2hyunjinn added the feat Extra attention is needed label May 16, 2025
@coderabbitai
Copy link

coderabbitai bot commented May 16, 2025

Walkthrough

A new API endpoint was introduced to allow a festival host to add another user as a host for a festival. Supporting classes, DTOs, service interfaces, implementations, and a repository for managing festival hosts were added. Entity and import adjustments were made to support the new feature, and package structure was updated for clarity.

Changes

File(s) Change Summary
src/main/java/org/festimate/team/api/admin/AdminController.java Added a new POST endpoint for adding a festival host, new dependency injection, and refactored imports.
src/main/java/org/festimate/team/api/admin/dto/AddHostRequest.java Introduced new record DTO for host addition requests.
src/main/java/org/festimate/team/api/facade/FestivalHostFacade.java Added new facade class with transactional method for adding a host, using several service dependencies.
src/main/java/org/festimate/team/domain/festival/entity/Festival.java Added import for FestivalHost entity.
src/main/java/org/festimate/team/domain/festivalHost/entity/FestivalHost.java Moved entity to new package and updated import for Festival.
src/main/java/org/festimate/team/domain/festivalHost/repository/FestivalHostRepository.java Added new repository interface for FestivalHost entity.
src/main/java/org/festimate/team/domain/festivalHost/service/FestivalHostService.java Added new service interface for adding a host to a festival.
src/main/java/org/festimate/team/domain/festivalHost/service/impl/FestivalHostServiceImpl.java Implemented service for adding a host, with transactional save logic.
src/test/java/org/festimate/team/common/mock/MockFactory.java Updated import to reflect new FestivalHost entity package.

Sequence Diagram(s)

sequenceDiagram
    participant AdminController
    participant FestivalHostFacade
    participant UserService
    participant FestivalService
    participant ParticipantService
    participant FestivalHostService

    AdminController->>FestivalHostFacade: addHost(userId, festivalId, AddHostRequest)
    FestivalHostFacade->>UserService: findById(userId)
    FestivalHostFacade->>FestivalService: findById(festivalId)
    FestivalHostFacade->>FestivalHostService: check if user is host
    FestivalHostFacade->>ParticipantService: findById(request.participantId)
    FestivalHostFacade->>FestivalHostService: addHost(participant.user, festival)
    FestivalHostService->>FestivalHostRepository: save(new FestivalHost)
Loading

Assessment against linked issues

Objective Addressed Explanation
Allow festival creator to add another user as host (#139)
Verify that the user adding a host is already a festival host (#139)
Add another user as host using userId/participantId (#139)

Poem

A festival host with power anew,
Invites a friend to join the crew.
With DTOs and services spun,
The API welcomes everyone!
Spring beans hop, repositories save—
Another host, so bold and brave.
🐰✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ 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 Results

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

Results for commit 4ba971c.

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

🧹 Nitpick comments (5)
src/main/java/org/festimate/team/api/admin/dto/AddHostRequest.java (1)

1-6: AddHostRequest DTO is concise and immutable
Using a Java record keeps the DTO lightweight. Consider adding a validation annotation (e.g., @Positive or @Min(1)) on participantId to enforce a positive value at the API boundary.

src/main/java/org/festimate/team/domain/festivalHost/service/impl/FestivalHostServiceImpl.java (1)

13-19: Unused logging annotation.

The class has the @Slf4j annotation but doesn't use the logger anywhere in the implementation. Consider adding some logging statements for important operations or removing the annotation if not needed.

src/main/java/org/festimate/team/domain/festivalHost/service/FestivalHostService.java (1)

7-10: Consider adding JavaDoc comments.

Adding method-level documentation would improve the interface's usability by explaining the purpose, parameters, and potential exceptions.

public interface FestivalHostService {
+    /**
+     * Adds a user as a host to a festival.
+     * 
+     * @param newHost The user to be added as a host
+     * @param festival The festival to which the user will be added as a host
+     */
    @Transactional
    void addHost(User newHost, Festival festival);
}
src/main/java/org/festimate/team/api/admin/AdminController.java (1)

5-5: Wildcard imports reduce code readability.

Using wildcard imports (import org.festimate.team.api.facade.*) makes it harder to identify which specific classes are being used. Consider using explicit imports for better code readability and maintenance.

-import org.festimate.team.api.facade.*;
+import org.festimate.team.api.facade.FestivalFacade;
+import org.festimate.team.api.facade.FestivalHostFacade;
+import org.festimate.team.api.facade.ParticipantFacade;
+import org.festimate.team.api.facade.PointFacade;
+import org.festimate.team.api.facade.MatchingFacade;
src/main/java/org/festimate/team/api/facade/FestivalHostFacade.java (1)

15-22: Add JavaDoc to the class and methods.

Consider adding class-level and method-level JavaDoc comments to improve code documentation.

/**
+ * Facade that orchestrates the process of adding a host to a festival.
+ * It coordinates between User, Festival, FestivalHost, and Participant services.
+ */
@Component
@RequiredArgsConstructor
public class FestivalHostFacade {
    private final UserService userService;
    private final FestivalService festivalService;
    private final FestivalHostService festivalHostService;
    private final ParticipantService participantService;

    /**
+    * Adds a participant as a co-host to a festival.
+    * Verifies that the requesting user is a host and that the participant exists.
+    *
+    * @param userId The ID of the user making the request (must be a host)
+    * @param festivalId The ID of the festival to add a host to
+    * @param request The request containing the participant ID to add as host
+    */
    @Transactional
    public void addHost(Long userId, Long festivalId, AddHostRequest request) {
        // ...
    }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 8e53656 and 4ba971c.

📒 Files selected for processing (9)
  • src/main/java/org/festimate/team/api/admin/AdminController.java (3 hunks)
  • src/main/java/org/festimate/team/api/admin/dto/AddHostRequest.java (1 hunks)
  • src/main/java/org/festimate/team/api/facade/FestivalHostFacade.java (1 hunks)
  • src/main/java/org/festimate/team/domain/festival/entity/Festival.java (1 hunks)
  • src/main/java/org/festimate/team/domain/festivalHost/entity/FestivalHost.java (1 hunks)
  • src/main/java/org/festimate/team/domain/festivalHost/repository/FestivalHostRepository.java (1 hunks)
  • src/main/java/org/festimate/team/domain/festivalHost/service/FestivalHostService.java (1 hunks)
  • src/main/java/org/festimate/team/domain/festivalHost/service/impl/FestivalHostServiceImpl.java (1 hunks)
  • src/test/java/org/festimate/team/common/mock/MockFactory.java (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/main/java/org/festimate/team/domain/festivalHost/entity/FestivalHost.java (1)
src/main/java/org/festimate/team/domain/festival/entity/Festival.java (1)
  • Getter (20-111)
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)
🔇 Additional comments (7)
src/main/java/org/festimate/team/domain/festival/entity/Festival.java (1)

8-8: Import update aligns with new package structure
Good catch updating the FestivalHost import to the new festivalHost package. This ensures the List<FestivalHost> mapping remains valid after the refactor.

src/test/java/org/festimate/team/common/mock/MockFactory.java (1)

5-5: Corrected import for FestivalHost in mocks
The test factory now references the relocated FestivalHost entity, so mocks will instantiate the correct class.

src/main/java/org/festimate/team/domain/festivalHost/entity/FestivalHost.java (2)

1-1: New package declaration for FestivalHost
Moving FestivalHost into its own package (festivalHost.entity) improves modularity and clearly separates host-related logic from the core festival domain.


8-8: Added Festival import for JPA mapping
Importing org.festimate.team.domain.festival.entity.Festival is necessary for the @ManyToOne association. The mapping and unique constraint look correct.

src/main/java/org/festimate/team/domain/festivalHost/repository/FestivalHostRepository.java (1)

1-9: CRUD repository for FestivalHost is ready
Extending JpaRepository<FestivalHost, Long> covers all basic operations. No custom queries are needed yet, so this interface suffices.

src/main/java/org/festimate/team/domain/festivalHost/service/impl/FestivalHostServiceImpl.java (1)

1-19: Clean implementation with proper Spring and Lombok annotations.

The class is properly configured with required annotations and dependency injection setup.

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

78-87: HTTP status code inconsistency in the ResponseBuilder.created() method.

The ResponseBuilder.created() method returns a 200 OK status with a "CREATED" success status in the body rather than a true HTTP 201 status code. This is inconsistent with RESTful API conventions, where resource creation typically returns a 201 status code.

Looking at the ResponseBuilder.created() method implementation:

public static <T> ResponseEntity<ApiResponse<T>> created(T data) {
    return ResponseEntity.ok(ApiResponse.success(ResponseSuccess.CREATED, data));
}

This returns a 200 OK status instead of 201 Created. Consider updating the implementation or creating a new method that returns the proper HTTP status code:

-return ResponseBuilder.created(null);
+// If ResponseBuilder needs to maintain backward compatibility
+return ResponseEntity.status(HttpStatus.CREATED)
+        .body(ApiResponse.success(ResponseSuccess.CREATED, null));

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

Labels

feat Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] 페스티벌 호스트 추가 API 기능 구현

1 participant