Skip to content

Conversation

@Gyuhyeok99
Copy link
Contributor

@Gyuhyeok99 Gyuhyeok99 commented Mar 29, 2025

User description

관련 이슈

작업 내용

임베디드 타입을 그대로 DTO로 노출하는 구조 개선를 개선하고 응답 DTO 네이밍 컨벤션 통일하였습니다.

특이 사항

리뷰 요구사항 (선택)

그동안 개발된 거 보니까 @NotNull같은 어노테이션 붙어있는 필드는 한 칸 공백이 있어서 따라하긴 했는데 이것도 혹시 따로 정해진 게 있는걸까요?

예시)

public record ApplyRequest(

        @NotNull(message = "gpa score id를 입력해주세요.")
        Long gpaScoreId,

        @NotNull(message = "language test score id를 입력해주세요.")
        Long languageTestScoreId,

        @Valid
        UniversityChoiceRequest universityChoiceRequest
) {
}

public record UniversityChoiceRequest(
        Long firstChoiceUniversityId,
        Long secondChoiceUniversityId,
        Long thirdChoiceUniversityId) {
}


PR Type

Enhancement, Tests


Description

  • Refactored DTOs to encapsulate embedded types for better structure.

    • Introduced GpaResponse and LanguageTestResponse to replace direct use of embedded types.
    • Updated existing DTOs to reference these new encapsulated DTOs.
  • Unified naming conventions for response DTOs.

    • Renamed GpaScoreStatusResponse to GpaScoreStatusesResponse.
    • Renamed LanguageTestScoreStatusResponse to LanguageTestScoreStatusesResponse.
  • Updated service and controller layers to use the new DTOs.

  • Adjusted test cases to align with the new DTO structure and naming conventions.


Changes walkthrough 📝

Relevant files
Enhancement
10 files
ScoreController.java
Updated controller to use new DTOs and naming conventions
+6/-6     
GpaResponse.java
Added `GpaResponse` DTO for encapsulating GPA details       
+17/-0   
GpaScoreStatus.java
Removed `GpaScoreStatus` DTO                                                         
+0/-21   
GpaScoreStatusResponse.java
Refactored `GpaScoreStatusResponse` to use `GpaResponse` 
+14/-2   
GpaScoreStatusesResponse.java
Added `GpaScoreStatusesResponse` DTO for list encapsulation
+11/-0   
LanguageTestResponse.java
Added LanguageTestResponse DTO for encapsulating language test details
+18/-0   
LanguageTestScoreStatus.java
Removed `LanguageTestScoreStatus` DTO                                       
+0/-21   
LanguageTestScoreStatusResponse.java
Refactored LanguageTestScoreStatusResponse to use LanguageTestResponse
+14/-2   
LanguageTestScoreStatusesResponse.java
Added `LanguageTestScoreStatusesResponse` DTO for list encapsulation
+11/-0   
ScoreService.java
Updated service methods to use new DTOs and naming conventions
+10/-10 
Formatting
2 files
GpaScoreRequest.java
Minor formatting update in `GpaScoreRequest`                         
+1/-0     
LanguageTestScoreRequest.java
Minor formatting update in `LanguageTestScoreRequest`       
+1/-0     
Tests
1 files
ScoreServiceTest.java
Updated test cases to align with new DTO structure and naming
conventions
+14/-14 

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Summary by CodeRabbit

    • New Features

      • Enhanced GPA and language test score endpoints now deliver comprehensive, multi-status responses.
      • Introduced new response models that provide detailed score information.
      • Added input validation with custom error messages.
    • Refactor

      • Updated API response structures and method signatures to streamline score information.
      • Removed legacy response models to ensure consistency.
    • Tests

      • Revised test cases to align with the updated response formats and validations.

    @coderabbitai
    Copy link

    coderabbitai bot commented Mar 29, 2025

    Walkthrough

    The changes refactor the score-related API endpoints and service methods to return updated response DTOs that encapsulate multiple statuses. New DTO records have been added to convert embedded types (Gpa, LanguageTest) into dedicated response objects, and naming conventions have been standardized. Validation annotations have been enhanced in request DTOs. Deprecated response records have been removed and corresponding tests have been updated to work with the new data structures.

    Changes

    File(s) Change Summary
    src/main/java/.../ScoreController.java and src/main/java/.../ScoreService.java Updated API endpoint and service method signatures to return new plural response DTOs (GpaScoreStatusesResponse and LanguageTestScoreStatusesResponse) instead of single-status DTOs.
    src/main/java/.../dto/GpaResponse.java, GpaScoreStatusResponse.java, GpaScoreStatusesResponse.java, GpaScoreRequest.java Added new GPA response DTO (GpaResponse), updated GPA status response structure including a static from method, and enhanced GPA request validation with a new @NotNull annotation.
    src/main/java/.../dto/LanguageTestResponse.java, LanguageTestScoreStatusResponse.java, LanguageTestScoreStatusesResponse.java, LanguageTestScoreRequest.java Introduced new LanguageTest response DTO (LanguageTestResponse), modified the LanguageTest status response to include detailed fields and a from converter, and added a new required field with @NotNull annotation in the request DTO.
    src/main/java/.../dto/GpaScoreStatus.java, LanguageTestScoreStatus.java, and src/test/java/.../ScoreServiceTest.java Removed deprecated DTO records and updated test assertions and method calls to match the new response types.

    Sequence Diagram(s)

    sequenceDiagram
        participant Client as API Client
        participant SC as ScoreController
        participant SS as ScoreService
        participant DTO as DTO Converter (static from methods)
    
        Client->>SC: Request GPA/LanguageTest Score Status
        SC->>SS: Invoke service method
        SS->>DTO: Convert domain objects to new DTO response(s)
        DTO-->>SS: Return converted DTOs
        SS-->>SC: Return aggregated response DTO
        SC-->>Client: Send response
    
    Loading

    Assessment against linked issues

    Objective Addressed Explanation
    Convert embedded types to dedicated DTOs (e.g., using GpaResponse, LanguageTestResponse) [#248]
    Unify naming of response DTOs for consistency (e.g., GpaScoreStatusesResponse, LanguageTestScoreStatusesResponse) [#248]

    Poem

    In a burrow of code beneath the moon's soft light,
    I hopped through changes with delight.
    DTOs now prance in names so bright,
    Leaving embedded types far behind in the night.
    A joyful rabbit’s code—hopping into the future right! 🐇✨

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

    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 resolve resolve all the CodeRabbit review comments.
    • @coderabbitai plan to trigger planning for file edits and PR creation.
    • @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.

    Copy link

    Copilot AI left a comment

    Choose a reason for hiding this comment

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

    Pull Request Overview

    This PR refactors the response DTOs for score-related endpoints by replacing direct exposure of embedded types with dedicated response DTO containers and standardizing the naming convention. Key changes include updating service and controller layers to return plural response DTOs, revising test assertions to match the new DTO formats, and removing legacy DTO classes.

    Reviewed Changes

    Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

    Show a summary per file
    File Description
    src/test/java/com/example/solidconnection/score/service/ScoreServiceTest.java Updated test assertions and import statements to match new DTO names
    src/main/java/com/example/solidconnection/score/service/ScoreService.java Refactored methods to return plural response DTOs instead of singular ones
    src/main/java/com/example/solidconnection/score/dto/LanguageTestScoreStatusesResponse.java Introduced a new response container DTO for language test scores
    src/main/java/com/example/solidconnection/score/dto/LanguageTestScoreStatusResponse.java Updated DTO structure to use detailed fields instead of a list
    src/main/java/com/example/solidconnection/score/dto/LanguageTestScoreStatus.java Removed legacy DTO
    src/main/java/com/example/solidconnection/score/dto/LanguageTestScoreRequest.java Minor code style adjustment
    src/main/java/com/example/solidconnection/score/dto/LanguageTestResponse.java Added new DTO to encapsulate language test details
    src/main/java/com/example/solidconnection/score/dto/GpaScoreStatusesResponse.java Introduced a new response container DTO for GPA scores
    src/main/java/com/example/solidconnection/score/dto/GpaScoreStatusResponse.java Updated DTO structure to use detailed fields instead of a list
    src/main/java/com/example/solidconnection/score/dto/GpaScoreStatus.java Removed legacy DTO
    src/main/java/com/example/solidconnection/score/dto/GpaScoreRequest.java Minor code style adjustment
    src/main/java/com/example/solidconnection/score/dto/GpaResponse.java Added new DTO to encapsulate GPA details
    src/main/java/com/example/solidconnection/score/controller/ScoreController.java Updated API endpoints to return plural response DTOs

    @qodo-code-review
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    248 - Fully compliant

    Compliant requirements:

    • Improve structure by not exposing embedded types directly in DTOs
    • Create dedicated DTOs for embedded types
    • Replace direct embedded type references with new DTOs
    • Unify naming conventions for response DTOs
    • Rename inconsistent DTOs to follow conventions
    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Unnecessary Whitespace

    There's an unnecessary blank line added after the record declaration that doesn't serve any purpose and is inconsistent with other similar files.

    @NotNull(message = "학점을 입력해주세요.")
    Unnecessary Whitespace

    There's an unnecessary blank line added after the record declaration that doesn't serve any purpose and is inconsistent with other similar files.

    @NotNull(message = "어학 종류를 입력해주세요.")

    @qodo-code-review
    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Remove unnecessary blank line

    Remove the unnecessary blank line after the opening parenthesis in the record
    declaration. This blank line disrupts the formatting consistency and doesn't
    follow standard Java record declaration style.

    src/main/java/com/example/solidconnection/score/dto/GpaScoreRequest.java [5-7]

     public record GpaScoreRequest(
    -
             @NotNull(message = "학점을 입력해주세요.")
             Double gpa,
     
             @NotNull(message = "학점 기준을 입력해주세요.")

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 3

    __

    Why: The suggestion correctly identifies an unnecessary blank line after the opening parenthesis in the record declaration. Removing it improves code formatting consistency and follows standard Java record declaration style.

    Low
    • More

    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 (1)
    src/main/java/com/example/solidconnection/score/service/ScoreService.java (1)

    50-57: Consider addressing TODOs in a future PR

    There are several TODOs in this service regarding the relationship between SiteUser and scores. Consider addressing these in a follow-up PR to improve the entity relationships and fetch strategies.

    📜 Review details

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

    📥 Commits

    Reviewing files that changed from the base of the PR and between 2117baa and c870c68.

    📒 Files selected for processing (13)
    • src/main/java/com/example/solidconnection/score/controller/ScoreController.java (2 hunks)
    • src/main/java/com/example/solidconnection/score/dto/GpaResponse.java (1 hunks)
    • src/main/java/com/example/solidconnection/score/dto/GpaScoreRequest.java (1 hunks)
    • src/main/java/com/example/solidconnection/score/dto/GpaScoreStatus.java (0 hunks)
    • src/main/java/com/example/solidconnection/score/dto/GpaScoreStatusResponse.java (1 hunks)
    • src/main/java/com/example/solidconnection/score/dto/GpaScoreStatusesResponse.java (1 hunks)
    • src/main/java/com/example/solidconnection/score/dto/LanguageTestResponse.java (1 hunks)
    • src/main/java/com/example/solidconnection/score/dto/LanguageTestScoreRequest.java (1 hunks)
    • src/main/java/com/example/solidconnection/score/dto/LanguageTestScoreStatus.java (0 hunks)
    • src/main/java/com/example/solidconnection/score/dto/LanguageTestScoreStatusResponse.java (1 hunks)
    • src/main/java/com/example/solidconnection/score/dto/LanguageTestScoreStatusesResponse.java (1 hunks)
    • src/main/java/com/example/solidconnection/score/service/ScoreService.java (2 hunks)
    • src/test/java/com/example/solidconnection/score/service/ScoreServiceTest.java (5 hunks)
    💤 Files with no reviewable changes (2)
    • src/main/java/com/example/solidconnection/score/dto/LanguageTestScoreStatus.java
    • src/main/java/com/example/solidconnection/score/dto/GpaScoreStatus.java
    🔇 Additional comments (19)
    src/main/java/com/example/solidconnection/score/dto/GpaScoreStatusesResponse.java (1)

    5-11: Well-structured wrapper response for collections

    This new record class follows a good pattern for API responses containing collections of items. The naming convention clearly indicates a collection with the plural "Statuses", and the static factory method provides a clean way to construct the response from domain objects.

    src/main/java/com/example/solidconnection/score/dto/LanguageTestScoreRequest.java (1)

    8-10: Good addition of validation for required field

    Adding the @NotNull validation ensures the language test type is properly provided in requests, improving input validation and API robustness.

    src/main/java/com/example/solidconnection/score/dto/GpaScoreRequest.java (1)

    6-8: Consistent validation pattern applied

    The addition of @NotNull validation for the GPA field maintains consistency with other request DTOs and ensures all required fields are properly validated.

    src/main/java/com/example/solidconnection/score/dto/GpaResponse.java (1)

    5-16: Good encapsulation of embedded type as dedicated DTO

    Creating a dedicated response DTO for the Gpa embedded type improves the API structure by properly encapsulating domain objects and creating a clear separation between the internal model and the API contract. The static factory method provides a clean way to construct the response from domain objects.

    src/main/java/com/example/solidconnection/score/dto/LanguageTestResponse.java (1)

    6-18: Well-structured DTO with proper encapsulation

    This new LanguageTestResponse record provides a clean way to encapsulate the embedded LanguageTest type as a dedicated response object. The static factory method follows best practices for converting domain objects to DTOs.

    src/main/java/com/example/solidconnection/score/dto/LanguageTestScoreStatusesResponse.java (1)

    5-11: Good collection response structure with consistent naming

    The LanguageTestScoreStatusesResponse record appropriately encapsulates a list of status responses, following a clear naming convention with pluralized form for collections. The static factory method provides a clean way to construct this response.

    src/main/java/com/example/solidconnection/score/dto/GpaScoreStatusResponse.java (1)

    3-20: Improved structure with dedicated embedded type response

    The refactored GpaScoreStatusResponse now properly encapsulates the GPA data with a dedicated GpaResponse object instead of exposing the embedded type directly. The static factory method provides a clean mapping from domain objects to DTOs, and the additional fields (id, verifyStatus, rejectedReason) provide more comprehensive information in the response.

    src/main/java/com/example/solidconnection/score/dto/LanguageTestScoreStatusResponse.java (1)

    3-20: Consistent refactoring with improved embedded type handling

    The changes to LanguageTestScoreStatusResponse mirror those in GpaScoreStatusResponse, creating a consistent pattern across the codebase. The record now properly uses the dedicated LanguageTestResponse to encapsulate the embedded type data, and includes important metadata like id, verification status, and rejection reason. The static factory method provides a clean way to create these responses from domain objects.

    src/test/java/com/example/solidconnection/score/service/ScoreServiceTest.java (5)

    11-14: Import changes align with new response DTOs

    The import changes reflect the updated response DTO structure, adding GpaScoreStatusesResponse and LanguageTestScoreStatusesResponse which are the wrapper classes for the status list responses.


    65-76: Test updated to use new response wrapper pattern

    The test has been appropriately updated to work with the new response structure. The test now:

    1. Correctly retrieves a GpaScoreStatusesResponse object instead of a direct list
    2. Uses gpaScoreStatusResponseList() accessor method to get the inner list
    3. Maps using GpaScoreStatusResponse::from to create the expected result objects

    This change is consistent with the refactoring to use container objects for collections of responses.


    84-87: Empty response test updated correctly

    The test for empty GPA score lists has been properly updated to use the new wrapper response type and accessor method.


    101-110: Language test scores test updated correctly

    Similar to the GPA scores test, this test has been properly updated to use the new response wrapper pattern, consistently using:

    1. LanguageTestScoreStatusesResponse as the container type
    2. languageTestScoreStatusResponseList() accessor method
    3. LanguageTestScoreStatusResponse::from for mapping individual items

    The changes are consistent with the overall refactoring approach.


    119-122: Empty language test scores test updated correctly

    The test for empty language test score lists has been properly updated to use the new wrapper response type and accessor method.

    src/main/java/com/example/solidconnection/score/controller/ScoreController.java (3)

    5-7: Imports updated for new response wrapper DTOs

    The import statements have been updated to use the new response wrapper classes, which is consistent with the refactoring to standardize DTO naming conventions.


    52-57: GPA score status endpoint updated to use the wrapper response

    The API endpoint return type has been properly updated to return ResponseEntity<GpaScoreStatusesResponse> instead of a direct list response. This change aligns with the refactoring goal of improving embedded type DTO exposure and standardizing response naming conventions.


    61-66: Language test score status endpoint updated to use the wrapper response

    The API endpoint return type has been properly updated to return ResponseEntity<LanguageTestScoreStatusesResponse> instead of a direct list response. This change is consistent with the other endpoints and follows the same pattern of using container objects for collections of responses.

    src/main/java/com/example/solidconnection/score/service/ScoreService.java (3)

    12-15: Imports updated for new response wrapper DTOs

    The import statements have been updated to include the new response wrapper classes, which is consistent with the refactoring to standardize DTO naming conventions.


    77-88: GPA score status service method refactored to use wrapper response

    The method has been properly updated to:

    1. Return GpaScoreStatusesResponse instead of a direct list
    2. Rename the variable to clearly indicate it contains response objects (gpaScoreStatusResponseList)
    3. Use the correct mapping function (GpaScoreStatusResponse::from)
    4. Create a wrapper response object using the static factory method from

    This implementation consistently follows the refactoring goal of having proper container objects for collections.


    90-101: Language test score status service method refactored to use wrapper response

    The method has been properly updated to:

    1. Return LanguageTestScoreStatusesResponse instead of a direct list
    2. Rename the variable to clearly indicate it contains response objects (languageTestScoreStatusResponseList)
    3. Use the correct mapping function (LanguageTestScoreStatusResponse::from)
    4. Create a wrapper response object using the static factory method from

    The implementation is consistent with the GPA score status method and follows the same pattern.

    Copy link
    Collaborator

    @nayonsoso nayonsoso left a comment

    Choose a reason for hiding this comment

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

    백로그를 바로바로 처리하는 정신 너무 좋습니다!! 😇
    ‘컨벤션을 맞추자’는 이 PR의 목적에 맞게 깔끔하게 수정해주신 것 같습니다.

    혹시 이 작업을 하시면서, ‘이 부분도 고쳤으면 좋겠다’ 하신 부분이 있으셨나요?

    @Gyuhyeok99
    Copy link
    Contributor Author

    생기면 추가로 말씀드리겠습니다!

    @Gyuhyeok99 Gyuhyeok99 merged commit 1bce344 into solid-connection:develop Mar 31, 2025
    1 check passed
    @Gyuhyeok99 Gyuhyeok99 deleted the refactor/248-dto-encapsulation branch May 11, 2025 15:51
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    refactor: 임베디드 타입 DTO에 직접 노출 개선 및 응답 DTO 네이밍 컨벤션 통일

    3 participants