Skip to content

MOSU-218 내 문의글 조회 내역 기능 구현#223

Merged
jbh010204 merged 3 commits intodevelopfrom
refactor/mosu-218
Aug 6, 2025
Merged

MOSU-218 내 문의글 조회 내역 기능 구현#223
jbh010204 merged 3 commits intodevelopfrom
refactor/mosu-218

Conversation

@jbh010204
Copy link
Member

@jbh010204 jbh010204 commented Aug 6, 2025

✨ 구현한 기능

📢 논의하고 싶은 내용

🎸 기타

Summary by CodeRabbit

  • New Features

    • Introduced dedicated admin endpoints for managing inquiry answers, including creating, updating, and deleting answers, accessible only to administrators.
    • Added the ability for users to view a paginated list of their own inquiries.
  • Improvements

    • Enhanced access control for viewing inquiry details to ensure proper permissions.
    • Simplified user inquiry endpoints to focus solely on user-submitted inquiries.
  • Documentation

    • Updated and added API documentation for new and revised inquiry endpoints, including admin operations.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @jbh010204, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've implemented the functionality for users to view their own 1:1 inquiry history. This involved adding a new service method and repository query to fetch user-specific inquiries. Additionally, I've refactored the existing inquiry controllers by extracting all administrator-specific inquiry management endpoints into a new dedicated AdminInquiryController, ensuring a clearer separation of concerns between user and admin functionalities.

Highlights

  • User-Specific Inquiry History: I've implemented a new API endpoint and the necessary backend logic to enable authenticated users to retrieve a paginated list of their own 1:1 inquiries, fulfilling the core requirement of viewing personal inquiry history.
  • Separation of Admin and User Concerns: All administrative operations related to 1:1 inquiries, such as listing all inquiries and managing answers (creating, updating, deleting), have been extracted from the general InquiryController and moved into a newly created AdminInquiryController. This improves modularity and clarifies responsibility.
  • Enhanced Inquiry Detail Security: The getInquiryDetail method in the InquiryService now includes a permission check, ensuring that only the owner of an inquiry or an authorized administrator can view its detailed information.
  • QueryDSL Utility Refactoring: The getTotalCount method within the QueryDSL repository implementation has been refactored to be more generic and reusable, allowing it to calculate total counts for various QueryDSL queries more efficiently.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a feature for users to view their own inquiries and refactors admin-related inquiry endpoints into a separate controller. The changes are a good step forward, but I've identified several critical issues. There are significant bugs in the data access layer where pagination queries calculate total counts incorrectly, which will break pagination. Additionally, there's a critical authorization flaw in how inquiry details are fetched. I've also included some suggestions to improve the clarity of the API documentation.

import life.mosu.mosuserver.domain.inquiry.entity.InquiryStatus;
import life.mosu.mosuserver.global.util.ApiResponseWrapper;
import life.mosu.mosuserver.presentation.admin.docs.AdminInquiryControllerDocs;
import life.mosu.mosuserver.presentation.inquiry.InquiryController;

Choose a reason for hiding this comment

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

medium

This import of life.mosu.mosuserver.presentation.inquiry.InquiryController is unused and should be removed to maintain code cleanliness.

Comment on lines 35 to 38
ResponseEntity<ApiResponseWrapper<Void>> create(
@AuthenticationPrincipal PrincipalDetails principalDetails,
PrincipalDetails principalDetails,
@Parameter(description = "문의 생성에 필요한 정보") @RequestBody @Valid InquiryCreateRequest request
);

Choose a reason for hiding this comment

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

medium

The PrincipalDetails parameter is resolved from the security context and not provided by the client in the request. To prevent it from appearing as a request body in the Swagger UI, you should annotate it with @Parameter(hidden = true).

Suggested change
ResponseEntity<ApiResponseWrapper<Void>> create(
@AuthenticationPrincipal PrincipalDetails principalDetails,
PrincipalDetails principalDetails,
@Parameter(description = "문의 생성에 필요한 정보") @RequestBody @Valid InquiryCreateRequest request
);
ResponseEntity<ApiResponseWrapper<Void>> create(
@Parameter(hidden = true) PrincipalDetails principalDetails,
@Parameter(description = "문의 생성에 필요한 정보") @RequestBody @Valid InquiryCreateRequest request
);

Comment on lines 54 to 58
ResponseEntity<ApiResponseWrapper<InquiryDetailResponse>> getInquiryDetail(
PrincipalDetails principalDetails,
@Parameter(name = "postId", description = "조회할 문의의 ID", in = ParameterIn.PATH)
@PathVariable Long postId
);

Choose a reason for hiding this comment

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

medium

The PrincipalDetails parameter is resolved from the security context and is not part of the request from the client. It should be hidden from the Swagger documentation to avoid confusion for API consumers.

Suggested change
ResponseEntity<ApiResponseWrapper<InquiryDetailResponse>> getInquiryDetail(
PrincipalDetails principalDetails,
@Parameter(name = "postId", description = "조회할 문의의 ID", in = ParameterIn.PATH)
@PathVariable Long postId
);
ResponseEntity<ApiResponseWrapper<InquiryDetailResponse>> getInquiryDetail(
@Parameter(hidden = true) PrincipalDetails principalDetails,
@Parameter(name = "postId", description = "조회할 문의의 ID", in = ParameterIn.PATH)
@PathVariable Long postId
);

@coderabbitai
Copy link

coderabbitai bot commented Aug 6, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

This update introduces an admin controller and documentation for managing inquiries and answers, adds user-specific inquiry retrieval, enhances access control in inquiry detail retrieval, and refactors repository logic for paginated user inquiries. The user-facing inquiry controller is simplified to focus on personal inquiries, with all answer management moved to the admin context.

Changes

Cohort / File(s) Change Summary
Inquiry Service and Repository Enhancements
src/main/java/life/mosu/mosuserver/application/inquiry/InquiryService.java, src/main/java/life/mosu/mosuserver/domain/inquiry/repository/InquiryQueryRepository.java, src/main/java/life/mosu/mosuserver/infra/persistence/jpa/InquiryJpaRepositoryImpl.java
Added user-specific inquiry retrieval (getMyInquiry), updated inquiry detail to require user and permission check, refactored repository for paginated user inquiries and generic count handling.
Admin Inquiry Management
src/main/java/life/mosu/mosuserver/presentation/admin/AdminInquiryController.java, src/main/java/life/mosu/mosuserver/presentation/admin/docs/AdminInquiryControllerDocs.java
Introduced new admin controller and corresponding Swagger documentation for listing inquiries and managing inquiry answers (create, update, delete) with role-based access control.
User Inquiry Controller Simplification
src/main/java/life/mosu/mosuserver/presentation/inquiry/InquiryController.java, src/main/java/life/mosu/mosuserver/presentation/inquiry/InquiryControllerDocs.java
Removed inquiry answer endpoints, switched inquiry list to user-specific retrieval, updated endpoints to require explicit user context, and cleaned up related documentation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant InquiryController
    participant InquiryService
    participant InquiryRepository

    User->>InquiryController: GET /inquiry/my
    InquiryController->>InquiryService: getMyInquiry(userId, pageable)
    InquiryService->>InquiryRepository: searchMyInquiry(userId, pageable)
    InquiryRepository-->>InquiryService: Page<InquiryResponse>
    InquiryService-->>InquiryController: Page<InquiryResponse>
    InquiryController-->>User: ApiResponseWrapper<Page<InquiryResponse>>
Loading
sequenceDiagram
    participant Admin
    participant AdminInquiryController
    participant InquiryService
    participant InquiryAnswerService

    Admin->>AdminInquiryController: POST /admin/inquiry/{postId}/answer
    AdminInquiryController->>InquiryAnswerService: createAnswer(postId, request)
    InquiryAnswerService-->>AdminInquiryController: void
    AdminInquiryController-->>Admin: ApiResponseWrapper<Void>
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

우선순위 중

Suggested reviewers

  • wlgns12370
  • chominju02

Poem

A rabbit hops through fields of code,
Where admin paths and user roads
Are neatly split, permissions tight—
Inquiries sorted left and right!
With answers managed by the wise,
And user lists a sweet surprise,
This patch brings order—what a sight! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 c04c57e and e46ced0.

📒 Files selected for processing (4)
  • src/main/java/life/mosu/mosuserver/application/inquiry/InquiryService.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/infra/persistence/jpa/InquiryJpaRepositoryImpl.java (4 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/admin/AdminInquiryController.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/inquiry/InquiryControllerDocs.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/java/life/mosu/mosuserver/application/inquiry/InquiryService.java
  • src/main/java/life/mosu/mosuserver/presentation/inquiry/InquiryControllerDocs.java
  • src/main/java/life/mosu/mosuserver/presentation/admin/AdminInquiryController.java
🔇 Additional comments (5)
src/main/java/life/mosu/mosuserver/infra/persistence/jpa/InquiryJpaRepositoryImpl.java (5)

6-6: LGTM! Appropriate imports for enhanced functionality.

The new imports support the generalized count method and EntityManager-based query cloning functionality.

Also applies to: 12-12


30-30: LGTM! Proper EntityManager injection.

EntityManager injection is correctly implemented to support query cloning in the count operation.


47-47: Excellent fix for the pagination issue.

The refactoring to use getTotalCount(query, inquiry.count()) properly addresses the critical pagination bug by calculating the total count from a cloned query before pagination is applied.


56-71: Well-implemented user-specific inquiry retrieval.

The searchMyInquiry method correctly:

  • Filters inquiries by user ID
  • Uses the generalized count method to avoid pagination bugs
  • Follows consistent naming conventions
  • Maintains the same structure as other query methods

The implementation properly addresses the pagination concerns from previous reviews.


103-109: Excellent refactoring that fixes pagination and improves maintainability.

The generalized getTotalCount method is a significant improvement:

  • Fixes the critical pagination bug by using query cloning
  • Promotes code reuse across different query methods
  • Type-safe implementation with generics
  • Robust null handling with Optional

This refactoring addresses all the concerns raised in previous reviews and follows best practices.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/mosu-218

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.
  • 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate unit tests to generate unit tests for 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.

@jbh010204 jbh010204 merged commit adb7ba6 into develop Aug 6, 2025
3 checks passed
@jbh010204 jbh010204 deleted the refactor/mosu-218 branch August 6, 2025 15:11
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.

1 participant