Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(KL-165): change image logic #62

Merged

Conversation

ohhamma
Copy link
Contributor

@ohhamma ohhamma commented Sep 6, 2024

๐Ÿ“Œ ์—ฐ๊ด€๋œ ์ด์Šˆ

๐Ÿ“ ์ž‘์—… ๋‚ด์šฉ

  • user์™€ product ์—”ํ‹ฐํ‹ฐ์— image ์—ฐ๊ฒฐ
  • ์ด๋ฏธ์ง€ url ์ƒ์„ฑ ๋กœ์ง ๋ถ„๋ฆฌ
  • ํ•œ๋ฒˆ์— ์—ฌ๋Ÿฌ ์ด๋ฏธ์ง€ presigned url์„ ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ์ˆ˜์ •
  • presigned url๊ณผ ํ•จ๊ป˜ id๋ฅผ ๋ณด๋‚ด์ฃผ๋„๋ก ์ˆ˜์ •
  • ์ด๋ฏธ์ง€ id๋ฅผ ๋ฐ›์•„์„œ upload complete๋ฅผ ํ•˜๋„๋ก ์ˆ˜์ •
    • ์‘๋‹ต์œผ๋กœ ์ด๋ฏธ์ง€ id๋ฅผ ๋ฐ›๋„๋ก ์ˆ˜์ •
  • product ๋Œ€ํ‘œ ์ด๋ฏธ์ง€ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋กœ์ง ์ถ”๊ฐ€

๐ŸŒณ ์ž‘์—… ๋ธŒ๋žœ์น˜๋ช…

  • KL-165/์‚ฌ์ง„-๋กœ์ง-๋ณ€๊ฒฝ

๐Ÿ“ธ ์Šคํฌ๋ฆฐ์ƒท (์„ ํƒ)

๐Ÿ’ฌ ๋ฆฌ๋ทฐ ์š”๊ตฌ์‚ฌํ•ญ (์„ ํƒ)

Summary by CodeRabbit

  • New Features

    • Introduced support for multiple image uploads and retrieval of presigned URLs for multiple images.
    • Added methods for handling completion of single and multiple image uploads with structured responses.
    • Enhanced Image class to generate URLs for images.
    • New DTOs for handling multiple image uploads and updates.
    • Added utility methods for generating image URLs and profile URLs.
  • Bug Fixes

    • Removed deprecated JPG file extension, ensuring only valid formats are supported.
  • Documentation

    • Updated comments and method names for clarity and consistency across the codebase.
  • Refactor

    • Improved method signatures and response structures for better usability and maintainability.
    • Streamlined data handling in response DTOs, focusing on single image URLs rather than collections.
  • Chores

    • Cleaned up unused imports and redundant code across various files.

@ohhamma ohhamma added the โ™ป๏ธ Refactor ์ฝ”๋“œ ๋ฆฌํŒฉํ† ๋ง label Sep 6, 2024
@ohhamma ohhamma requested a review from min3m September 6, 2024 08:11
@ohhamma ohhamma self-assigned this Sep 6, 2024
Copy link

coderabbitai bot commented Sep 6, 2024

Walkthrough

The changes involve significant updates to the image handling functionality across various components of the application. Key modifications include the introduction of new request and response DTOs for single and multiple image uploads, the renaming of methods for clarity, and the restructuring of image-related data models. Additionally, the handling of user and product images has been refined, with a shift from URL strings to object references, enhancing the overall data integrity and management.

Changes

Files Change Summary
src/main/java/taco/klkl/domain/image/controller/ImageController.java, .../ImageService.java, .../ImageServiceImpl.java Updated methods to handle single and multiple image uploads, with new request and response DTOs introduced. Method names changed for clarity, and response structures refined to accommodate batch processing.
src/main/java/taco/klkl/domain/image/domain/FileExtension.java, .../Image.java Removed JPG from FileExtension enum; renamed methods in Image class for clarity and added URL generation functionality.
src/main/java/taco/klkl/domain/image/dto/request/MultipleImagesUpdateRequest.java, .../SingleImageUpdateRequest.java, .../SingleImageUploadRequest.java Introduced new DTOs for handling multiple image updates and uploads, with validation annotations updated for data integrity.
src/main/java/taco/klkl/domain/image/dto/response/MultipleUploadCompleteResponse.java, .../SingleUploadCompleteResponse.java, .../PresignedUrlResponse.java New response DTOs created for handling upload completions and presigned URL responses, with modifications to constructors for improved data encapsulation.
src/main/java/taco/klkl/domain/product/domain/Product.java, .../ProductImage.java Updated image handling in Product class to use Image objects instead of URLs; renamed fields for clarity.
src/main/java/taco/klkl/domain/user/domain/User.java, .../UserDetailResponse.java, .../UserSimpleResponse.java Removed profileImageUrl field in favor of an Image entity; updated response DTOs to reflect new naming conventions and utility methods for generating profile URLs.
src/main/resources/database/data.sql Removed profile_image_url from SQL insert statement for klkl_user table, reflecting changes in the data model.
src/test/java/taco/klkl/domain/... Updated tests across various files to align with new naming conventions and data structures, particularly related to user and product image handling.
src/main/java/taco/klkl/global/util/ImageUtil.java, .../ProductUtil.java, .../UserUtil.java Introduced utility methods for generating URLs and handling image retrieval, enhancing the functionality of existing utility classes.
src/main/java/taco/klkl/infra/cloudfront/CloudFrontUrlGenerator.java New class introduced for generating CloudFront URLs based on file names, utilizing Spring's dependency injection.
src/main/java/taco/klkl/global/common/constants/ImageValidationMessages.java Added new validation message constants for image ID checks and updated existing constants for clarity.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ImageController
    participant ImageService
    participant ImageUtil
    participant CloudFrontUrlGenerator

    User->>ImageController: Upload Image Request
    ImageController->>ImageService: createUserImageUploadUrl(SingleImageUploadRequest)
    ImageService->>ImageUtil: Find Image by ID
    ImageUtil->>ImageService: Return Image
    ImageService->>CloudFrontUrlGenerator: Generate URL
    CloudFrontUrlGenerator-->>ImageService: Return Generated URL
    ImageService-->>ImageController: Return PresignedUrlResponse
    ImageController-->>User: Respond with Upload URL
Loading

๐Ÿฐ "Oh, what a change in the land of images,
New paths for uploads, like magical bridges!
With URLs and objects, so neat and so bright,
Our data dances, a wonderful sight!
Hooray for the updates, let's hop and let's cheer,
For a world full of images, now crystal clear!" ๐Ÿฅ•


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 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.

@ohhamma
Copy link
Contributor Author

ohhamma commented Sep 6, 2024

@coderabbitai review

Copy link

coderabbitai bot commented Sep 6, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Outside diff range, codebase verification and nitpick comments (2)
src/main/java/taco/klkl/global/util/ProductUtil.java (1)

39-44: Efficient use of streams in image URL generation.

The method generateImageUrlsByProduct is well-implemented, using Java streams effectively to transform product images into URLs. The code is clean and adheres to best practices in functional programming.

Consider adding error handling or checks to ensure that the images are not null before attempting to retrieve URLs.

src/main/java/taco/klkl/domain/user/domain/User.java (1)

Line range hint 26-99: Well-implemented changes to user image handling.

The shift from a simple URL string to a more structured Image entity in the User class enhances data encapsulation and allows for more complex image handling. The use of @OneToOne and @JoinColumn annotations is correctly applied, and the updateImage method is properly updated.

Consider adding a convenience method in the User class to directly retrieve the image URL, which could improve usability.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5e8f458 and aa054f2.

Files selected for processing (35)
  • src/main/java/taco/klkl/domain/image/controller/ImageController.java (3 hunks)
  • src/main/java/taco/klkl/domain/image/domain/FileExtension.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/domain/Image.java (2 hunks)
  • src/main/java/taco/klkl/domain/image/dto/request/MultipleImagesUpdateRequest.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/dto/request/MultipleImagesUploadRequest.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/dto/request/SingleImageUpdateRequest.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/dto/request/SingleImageUploadRequest.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/dto/response/MultipleUploadCompleteResponse.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/dto/response/PresignedUrlResponse.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/dto/response/SingleUploadCompleteResponse.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/service/ImageService.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/service/ImageServiceImpl.java (4 hunks)
  • src/main/java/taco/klkl/domain/notification/service/NotificationServiceImpl.java (1 hunks)
  • src/main/java/taco/klkl/domain/product/domain/Product.java (3 hunks)
  • src/main/java/taco/klkl/domain/product/domain/ProductImage.java (2 hunks)
  • src/main/java/taco/klkl/domain/product/dto/request/ProductCreateUpdateRequest.java (1 hunks)
  • src/main/java/taco/klkl/domain/product/dto/response/ProductDetailResponse.java (3 hunks)
  • src/main/java/taco/klkl/domain/product/dto/response/ProductNotificationResponse.java (1 hunks)
  • src/main/java/taco/klkl/domain/product/dto/response/ProductSimpleResponse.java (3 hunks)
  • src/main/java/taco/klkl/domain/user/domain/User.java (5 hunks)
  • src/main/java/taco/klkl/domain/user/dto/response/UserDetailResponse.java (1 hunks)
  • src/main/java/taco/klkl/domain/user/dto/response/UserSimpleResponse.java (1 hunks)
  • src/main/java/taco/klkl/global/common/constants/ImageValidationMessages.java (1 hunks)
  • src/main/java/taco/klkl/global/util/ImageUtil.java (1 hunks)
  • src/main/java/taco/klkl/global/util/ProductUtil.java (3 hunks)
  • src/main/java/taco/klkl/global/util/UserUtil.java (2 hunks)
  • src/main/java/taco/klkl/infra/cloudfront/CloudFrontUrlGenerator.java (1 hunks)
  • src/main/resources/database/data.sql (1 hunks)
  • src/test/java/taco/klkl/domain/product/controller/ProductControllerTest.java (7 hunks)
  • src/test/java/taco/klkl/domain/product/dto/response/ProductSimpleResponseTest.java (2 hunks)
  • src/test/java/taco/klkl/domain/user/controller/UserControllerTest.java (2 hunks)
  • src/test/java/taco/klkl/domain/user/dto/response/UserDetailResponseTest.java (2 hunks)
  • src/test/java/taco/klkl/domain/user/dto/response/UserSimpleResponseTest.java (1 hunks)
  • src/test/java/taco/klkl/domain/user/integration/UserIntegrationTest.java (1 hunks)
  • src/test/java/taco/klkl/domain/user/service/UserServiceImplTest.java (2 hunks)
Files skipped from review due to trivial changes (3)
  • src/main/java/taco/klkl/domain/notification/service/NotificationServiceImpl.java
  • src/main/java/taco/klkl/domain/product/dto/request/ProductCreateUpdateRequest.java
  • src/test/java/taco/klkl/domain/user/service/UserServiceImplTest.java
Additional comments not posted (56)
src/main/java/taco/klkl/domain/image/dto/response/SingleUploadCompleteResponse.java (1)

3-9: Record Implementation Approved

The SingleUploadCompleteResponse record is correctly implemented. It uses Java's record feature effectively to encapsulate the imageId in an immutable structure, which is ideal for DTOs.

src/main/java/taco/klkl/domain/image/dto/request/SingleImageUpdateRequest.java (1)

6-10: Record Implementation Approved

The SingleImageUpdateRequest record is correctly implemented. It uses Java's record feature effectively to encapsulate the imageId in an immutable structure, which is ideal for DTOs. The use of the NotNull validation ensures that the imageId is always provided, which is crucial for the integrity of the data.

src/main/java/taco/klkl/domain/image/dto/response/MultipleUploadCompleteResponse.java (1)

5-11: Record Implementation Approved

The MultipleUploadCompleteResponse record is correctly implemented. It uses Java's record feature effectively to encapsulate the imageIds in an immutable structure, which is ideal for DTOs. The static factory method from provides a clean way to create instances of this record.

src/main/java/taco/klkl/domain/image/dto/request/SingleImageUploadRequest.java (1)

8-8: Change in Validation Logic: From @NotBlank to @NotNull.

The change in the validation annotation for fileExtension from @NotBlank to @NotNull alters how input validation is handled. This change allows the field to contain whitespace, which was previously not allowed. Ensure that this change aligns with the intended validation strategy for fileExtension and verify its impact on the application where this DTO is used.

src/main/java/taco/klkl/domain/image/dto/response/PresignedUrlResponse.java (1)

9-13: Enhanced Functionality in PresignedUrlResponse.

The changes to the PresignedUrlResponse class, including the method name change from from to of and the addition of an id in the constructor, enhance the functionality by linking the presigned URL to a specific image entity. This change is beneficial for tracking and managing images more effectively in the system.

src/main/java/taco/klkl/domain/image/dto/request/MultipleImagesUpdateRequest.java (1)

8-11: Appropriate Validation in MultipleImagesUpdateRequest.

The use of @NotEmpty for the imageIds field in the MultipleImagesUpdateRequest DTO is appropriate. It ensures that the list is not empty, which is crucial for the operation to make sense. This validation is well-suited for the intended functionality of updating multiple images.

src/main/java/taco/klkl/domain/image/dto/request/MultipleImagesUploadRequest.java (1)

8-11: Well-structured record for multiple image uploads.

The use of Java records here is appropriate for the immutable data structure required for image upload requests. The @NotEmpty validation on fileExtensions ensures that the list is not empty, which is crucial for processing the uploads correctly.

src/main/java/taco/klkl/domain/product/dto/response/ProductNotificationResponse.java (1)

7-7: Improved clarity and efficiency in image URL handling.

Renaming productImageUrl to mainImageUrl and updating the from method to directly use getMainImageUrl() simplifies the logic and improves the efficiency of the image retrieval process. This change aligns well with the PR's objectives and enhances the clarity of the data structure.

Also applies to: 13-13

src/main/java/taco/klkl/domain/user/dto/response/UserSimpleResponse.java (1)

8-8: Refined handling of profile URLs.

Renaming profileImageUrl to profileUrl and using UserUtil.generateProfileUrlByUser(user) for URL generation enhances the flexibility and potential complexity of URL formatting. This change likely supports broader or more varied use cases for URLs, aligning well with the PR's objectives.

Also applies to: 14-14

src/main/java/taco/klkl/global/common/constants/ImageValidationMessages.java (4)

4-4: Approved: New constant for image ID validation.

The addition of IMAGE_ID_NOT_NULL enhances validation by ensuring image IDs are not null, which is crucial for data integrity.


5-5: Approved: New constant for non-empty image ID arrays.

The addition of IMAGE_IDS_NOT_EMPTY ensures that arrays of image IDs are not empty, supporting operations involving multiple images.


7-7: Approved: Renaming for stricter file extension validation.

Renaming FILE_EXTENSION_NOT_BLANK to FILE_EXTENSION_NOT_NULL enforces a stricter validation rule, ensuring that file extensions are provided.


8-8: Approved: New constant for non-empty file extension arrays.

The addition of FILE_EXTENSIONS_NOT_EMPTY ensures that arrays of file extensions are not empty, supporting operations involving multiple file types.

src/main/java/taco/klkl/domain/user/dto/response/UserDetailResponse.java (3)

4-4: Approved: Import of UserUtil for URL generation.

The addition of import taco.klkl.global.util.UserUtil supports the encapsulation of URL generation logic, aligning with best practices.


8-8: Approved: Renaming for broader URL handling.

Renaming profileImageUrl to profileUrl reflects a more flexible handling of profile URLs, potentially accommodating various types of content.


16-16: Approved: Enhanced URL generation logic.

Using UserUtil.generateProfileUrlByUser(user) in the from method enhances the flexibility and robustness of profile URL generation.

src/main/java/taco/klkl/domain/image/domain/FileExtension.java (1)

Line range hint 1-12: Verify the impact of removing JPG from the enum.

The removal of JPG from FileExtension simplifies the enum but could potentially break existing functionality if JPG was previously supported. Ensure that this change is reflected and handled appropriately across all parts of the application.

Run the following script to verify the impact of this change:

src/main/java/taco/klkl/global/util/ImageUtil.java (1)

11-21: Well-implemented method for fetching images.

The method findImageEntityByImageTypeAndId is well-implemented, using clean and concise Java practices. It correctly uses the repository to fetch an image and handles the case where the image is not found by throwing a custom exception. This is a good use of Optional and exception handling in Java.

src/main/java/taco/klkl/domain/product/dto/response/ProductSimpleResponse.java (1)

Line range hint 11-28: Simplified data structure and updated method align with PR objectives.

The changes to the ProductSimpleResponse record and the from method are well-aligned with the PR's objectives to simplify the handling of product images. The shift to a single mainImageUrl simplifies the API response and is a positive change for consumers of this API.

src/test/java/taco/klkl/domain/user/dto/response/UserSimpleResponseTest.java (2)

17-17: Approved: Test method updates are correct.

The changes in the test method testUserSimpleResponseDto correctly reflect the updated profile URL handling and method name. The test assertions are appropriately updated to use the new getter method, ensuring consistency with the DTO changes.

Also applies to: 25-25


Line range hint 34-34: No changes needed: Test method testFrom remains unaffected.

This method does not reflect any of the changes related to the PR and continues to function as intended.

src/main/java/taco/klkl/domain/image/service/ImageService.java (4)

29-32: Approved: Method updated for multiple image upload completion.

The renaming to uploadCompleteProductImages and the use of MultipleImagesUpdateRequest are appropriate for handling the completion of multiple image uploads. Verify that the method correctly handles these requests.

Run the following script to verify the functionality:

Verification successful

Method uploadCompleteProductImages is correctly implemented and integrated.

The method uploadCompleteProductImages is implemented in ImageServiceImpl.java and invoked in ImageController.java, confirming its integration into the application. Ensure that the internal logic, such as expireOldImages, correctly handles the image update requests.

  • Location of Implementation:
    • src/main/java/taco/klkl/domain/image/service/ImageServiceImpl.java
    • src/main/java/taco/klkl/domain/image/controller/ImageController.java
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the functionality of `uploadCompleteProductImages` in the service layer.

# Test: Search for the method implementation. Expect: Correct handling of `MultipleImagesUpdateRequest`.
ast-grep --lang java --pattern $'class ImageServiceImpl {
  $$$
  uploadCompleteProductImages($_, $_) {
    $$$
  }
  $$$  
}'

Length of output: 127


Script:

#!/bin/bash
# Search for the method `uploadCompleteProductImages` across all Java files to locate its implementation.
rg 'uploadCompleteProductImages' --glob '**/*.java' -A 5

Length of output: 1921


20-23: Approved: Method updated for multiple image uploads.

The renaming to createProductImageUploadUrls and the use of MultipleImagesUploadRequest are appropriate for handling multiple image uploads. Verify that the method correctly generates multiple presigned URLs.

Run the following script to verify the functionality:

Verification successful

Verified: Method implementation aligns with multiple image uploads.

The createProductImageUploadUrls method is correctly implemented in ImageServiceImpl.java to handle multiple image uploads by processing the file extensions from the MultipleImagesUploadRequest. The method is also appropriately declared in the ImageService interface and used in the ImageController. This confirms that the method is set up to generate multiple presigned URLs as intended.

  • Implementation found in: src/main/java/taco/klkl/domain/image/service/ImageServiceImpl.java
  • Declaration in interface: src/main/java/taco/klkl/domain/image/service/ImageService.java
  • Usage in controller: src/main/java/taco/klkl/domain/image/controller/ImageController.java
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the functionality of `createProductImageUploadUrls` in the service layer.

# Test: Search for the method implementation. Expect: Correct generation of multiple presigned URLs.
ast-grep --lang java --pattern $'class ImageServiceImpl {
  $$$
  createProductImageUploadUrls($_, $_) {
    $$$
  }
  $$$  
}'

Length of output: 128


Script:

#!/bin/bash
# Search for the implementation of the `createProductImageUploadUrls` method across all Java files.
rg 'createProductImageUploadUrls' --glob '*.java' -A 5

Length of output: 2277


18-18: Approved: Method signature updated for single image uploads.

The change to accept SingleImageUploadRequest is consistent with the PR's objectives to refine image handling. Ensure that the implementation in the service layer correctly handles this new request type.

Run the following script to verify the implementation:


25-26: Approved: Method updated for single image upload completion.

The update to return SingleUploadCompleteResponse and accept SingleImageUpdateRequest enhances the method's functionality. Ensure that the implementation effectively handles the new request type.

Run the following script to verify the implementation:

Verification successful

Verified: Method uploadCompleteUserImage is correctly implemented.

The method uploadCompleteUserImage in ImageServiceImpl handles SingleImageUpdateRequest by performing user-related operations, confirming its correct implementation. The method is also integrated into the controller, indicating proper usage within the application.

  • Location: src/main/java/taco/klkl/domain/image/service/ImageServiceImpl.java
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `uploadCompleteUserImage` in the service layer.

# Test: Search for the method implementation. Expect: Correct handling of `SingleImageUpdateRequest`.
ast-grep --lang java --pattern $'class ImageServiceImpl {
  $$$
  uploadCompleteUserImage($_, $_) {
    $$$
  }
  $$$  
}'

Length of output: 123


Script:

#!/bin/bash
# Description: Verify the implementation of `uploadCompleteUserImage` in the service layer.

# Test: Search for the method implementation with a single parameter. Expect: Correct handling of `SingleImageUpdateRequest`.
ast-grep --lang java --pattern $'class ImageServiceImpl {
  $$$
  uploadCompleteUserImage(SingleImageUpdateRequest $_) {
    $$$
  }
  $$$  
}'

Length of output: 144


Script:

#!/bin/bash
# Description: Search for the `uploadCompleteUserImage` method across all Java files.

# Test: Locate the method implementation in any class. Expect: Identification of the correct class and method implementation.
rg 'uploadCompleteUserImage' --glob '*.java' -A 5

Length of output: 2153

src/main/java/taco/klkl/domain/product/domain/ProductImage.java (3)

52-65: Approved: Constructor and factory method updated.

The updates to the constructor and factory method of to use the new Image object and order field are consistent with the changes in the data structure. Ensure that these methods are correctly implemented and used throughout the application.

Run the following script to verify the implementation:

Verification successful

Verified: Constructor and factory method are correctly implemented.

The ProductImage class and its constructor are correctly implemented with the parameters Product, Image, and Integer order. The factory method also uses these parameters as expected. The review comment accurately reflects the implementation.

  • Location: src/main/java/taco/klkl/domain/product/domain/ProductImage.java
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the constructor and factory method in `ProductImage`.

# Test: Search for the implementation of the constructor and factory method. Expect: Correct usage of `Image` and `order`.
ast-grep --lang java --pattern $'class ProductImage {
  $$$
  ProductImage($_, $_, $_) {
    $$$
  }
  $$$  
}'

Length of output: 112


Script:

#!/bin/bash
# Search for the definition of the ProductImage class to confirm its existence.
rg 'class ProductImage' -A 10

# Search for constructors within the ProductImage class to verify the parameters.
rg 'ProductImage\(' -A 5

Length of output: 1695


35-42: Approved: Field changed from imageUrl to Image object reference.

The replacement of the imageUrl field with an Image object reference is a significant improvement in terms of object-oriented design and data integrity. Verify that the Image class is correctly used and integrated within the ProductImage class.

Run the following script to verify the integration:

Verification successful

Verified: Successful integration of the Image class within the ProductImage class.

The Image class is correctly used and integrated within the ProductImage class, as evidenced by its presence in the constructor and the of method. This change enhances the object-oriented design and data integrity of the codebase. The integration is consistent and aligns with the intended improvements.

  • ProductImage class constructor and of method use Image.
  • Image field is present in ProductImage.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the `Image` class within the `ProductImage` class.

# Test: Search for the usage of the `Image` class in `ProductImage`. Expect: Correct usage and integration.
ast-grep --lang java --pattern $'class ProductImage {
  $$$
  Image $_;
  $$$  
}'

Length of output: 83


Script:

#!/bin/bash
# Description: Search for the definition of the `Image` class and its usage within the `ProductImage` class.

# Find the definition of the `Image` class.
ast-grep --lang java --pattern 'class Image { $$$ }'

# Search for the usage of the `Image` class within the `ProductImage` class.
rg 'ProductImage' -A 10 | rg 'Image'

Length of output: 11277


45-48: Approved: Field renamed from orderIndex to order.

The renaming of orderIndex to order simplifies the naming convention and aligns better with its usage. Verify that this change is consistently applied throughout the application.

Run the following script to verify the consistency:

Verification successful

Verified: Consistent renaming of orderIndex to order.

The renaming of the field from orderIndex to order in the ProductImage class has been consistently applied throughout the codebase. No occurrences of the old field name orderIndex were found.

  • The order field is correctly defined in src/main/java/taco/klkl/domain/product/domain/ProductImage.java.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency of the `order` field usage in the application.

# Test: Search for the usage of the `order` field in `ProductImage`. Expect: Consistent usage and renaming.
ast-grep --lang java --pattern $'class ProductImage {
  $$$
  Integer order;
  $$$  
}'

Length of output: 88


Script:

#!/bin/bash
# Description: Verify the consistency of the `order` field usage in the application.

# Search for the definition of the `order` field in the `ProductImage` class.
rg --context 5 'Integer order;' --glob '**/*.java'

# Search for any remaining usage of the old `orderIndex` field to ensure it has been fully replaced.
rg --context 5 'orderIndex' --glob '**/*.java'

Length of output: 985

src/main/java/taco/klkl/domain/product/dto/response/ProductDetailResponse.java (3)

17-17: Updated field type from complex objects to simple strings.

The change from ProductImageResponse objects to String URLs simplifies the data structure, aligning with the PR's objectives to streamline image handling. Ensure that all references to the old images field are updated across the application to prevent runtime errors.

Verification successful

Verification successful: The change in ProductDetailResponse.java is independent.

The images field in ProductDetailResponse.java has been correctly updated to imageUrls, and the presence of the images field in Product.java is unrelated to this change. The review comment is verified as correct within its context.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all references to the old `images` field are updated.

# Test: Search for the old field usage. Expect: No occurrences of the old field.
rg --type java -A 5 $'images'

Length of output: 2015


34-34: Simplified image URL generation.

The use of ProductUtil.generateImageUrlsByProduct(product) directly in the constructor simplifies the transformation process. This change should enhance performance and maintainability by reducing the complexity of data handling.

Verification successful

Simplified image URL generation confirmed.

The generateImageUrlsByProduct method in ProductUtil.java efficiently transforms product images into URLs using Java Streams, aligning with the review comment's assertion of enhanced performance and maintainability. The implementation is concise and effective.

  • Location: src/main/java/taco/klkl/global/util/ProductUtil.java
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct implementation of `generateImageUrlsByProduct`.

# Test: Search for the method implementation. Expect: Correct logic handling.
ast-grep --lang java --pattern $'public static List<String> generateImageUrlsByProduct(Product $_) { $$$ }'

Length of output: 108


Script:

#!/bin/bash
# Description: Search for the method name `generateImageUrlsByProduct` across the codebase.

# Test: Use ripgrep to find occurrences of the method name.
rg 'generateImageUrlsByProduct'

Length of output: 295


Script:

#!/bin/bash
# Description: Extract and review the implementation of `generateImageUrlsByProduct`.

# Test: Use ripgrep to extract the method implementation with context.
rg -A 10 'public static List<String> generateImageUrlsByProduct' src/main/java/taco/klkl/global/util/ProductUtil.java

Length of output: 515


45-45: Updated tag generation method.

The method ProductUtil.generateTagsByProduct(product) replaces the older createTagsByProduct method. Verify that this new method is correctly implemented and used consistently across the application.

Verification successful

Method generateTagsByProduct is correctly implemented and tested.

The generateTagsByProduct method in ProductUtil.java is implemented using Java Streams and Optional to handle null values efficiently. It is used consistently across the application, and its functionality is validated by assertions in ProductSimpleResponseTest.java. No issues were found with its implementation or usage.

  • Implementation: src/main/java/taco/klkl/global/util/ProductUtil.java
  • Test: src/test/java/taco/klkl/domain/product/dto/response/ProductSimpleResponseTest.java
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct implementation of `generateTagsByProduct`.

# Test: Search for the method implementation. Expect: Correct logic handling.
ast-grep --lang java --pattern $'public static Set<TagResponse> generateTagsByProduct(Product $_) { $$$ }'

Length of output: 107


Script:

#!/bin/bash
# Search for any occurrences of `generateTagsByProduct` in the codebase to locate its definition and usage.
rg 'generateTagsByProduct'

Length of output: 562


Script:

#!/bin/bash
# Extract the implementation details of `generateTagsByProduct` from ProductUtil.java
ast-grep --lang java --pattern $'public static Set<TagResponse> generateTagsByProduct(final Product product) { $$$ }' src/main/java/taco/klkl/global/util/ProductUtil.java

# Extract the test case details from ProductSimpleResponseTest.java
rg -A 10 'generateTagsByProduct' src/test/java/taco/klkl/domain/product/dto/response/ProductSimpleResponseTest.java

Length of output: 1497


Script:

#!/bin/bash
# Search for assertions in the ProductSimpleResponseTest.java file to confirm validation of the method's output.
rg 'assert' src/test/java/taco/klkl/domain/product/dto/response/ProductSimpleResponseTest.java

Length of output: 1096

src/test/java/taco/klkl/domain/user/dto/response/UserDetailResponseTest.java (2)

18-18: Updated test data to reflect new naming convention.

The test data uses the new profile variable name, reflecting the updated naming convention from profileImageUrl to profileUrl. This change should improve clarity and consistency in the codebase.


28-28: Updated assertion to use new method name.

The assertion now checks profileUrl() instead of profileImageUrl(), aligning with the updated property name in the UserDetailResponse. Ensure that all references to the old method are updated across the test suite to maintain test integrity.

Verification successful

Method Name Update Verified

The transition from profileImageUrl() to profileUrl() has been successfully applied across the codebase. No occurrences of the old method name were found, and the new method name is used consistently in both test and main code files.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all references to the old `profileImageUrl()` method are updated.

# Test: Search for the old method usage. Expect: No occurrences of the old method.
rg --type java -A 5 $'profileImageUrl()'

Length of output: 41


Script:

#!/bin/bash
# Re-run the search for the old method usage to confirm no occurrences.
rg --type java 'profileImageUrl()'

# Search for the new method usage to ensure it is being used.
rg --type java 'profileUrl()'

Length of output: 1934

src/test/java/taco/klkl/domain/user/integration/UserIntegrationTest.java (2)

34-34: Renamed variable for clarity.

The variable userDto has been renamed to currentUser, enhancing clarity regarding its purpose in the test. This change should make the test code more understandable and maintainable.


41-41: Updated assertion to reflect new property name.

The assertion now checks profileUrl() instead of profileImageUrl(), aligning with the updated property name in the UserDetailResponse. This change ensures consistency with the updated data structure and API response format.

Verification successful

Consistent Usage of profileUrl() Verified

The profileUrl() property is consistently used across the codebase, replacing the old profileImageUrl() property. This confirms that the update aligns with the new data structure and API response format. No further action is needed.

  • Files with profileUrl() usage:
    • UserIntegrationTest.java
    • UserSimpleResponseTest.java
    • UserDetailResponseTest.java
    • UserControllerTest.java
    • ProductControllerTest.java
    • UserSimpleResponse.java
    • UserDetailResponse.java
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all references to the old `profileImageUrl()` property are updated.

# Test: Search for the old property usage. Expect: No occurrences of the old property.
rg --type java -A 5 $'profileImageUrl()'

Length of output: 41


Script:

#!/bin/bash
# Description: Verify that the new `profileUrl()` property is used consistently across the codebase.

# Test: Search for the new property usage. Expect: Occurrences of the new property in relevant files.
rg --type java -A 5 $'profileUrl()'

Length of output: 8705

src/main/java/taco/klkl/global/util/ProductUtil.java (1)

46-46: Clear and effective method renaming and implementation.

Renaming createTagsByProduct to generateTagsByProduct improves clarity and consistency. The method's implementation using Optional and streams is robust and adheres to best practices.

src/test/java/taco/klkl/domain/user/controller/UserControllerTest.java (3)

32-32: Variable Renaming Approved: userDetailResponse

The renaming of the variable from responseDto to userDetailResponse enhances clarity and specificity in the test context.


36-37: Test Setup Improvement

The updated instantiation of the User object and the direct creation of userDetailResponse enhance control and readability of the test setup.


44-54: Test Method Update Approved

The updates in the testGetMe method, including the mocked return value and assertions, align with the new response structure. The change from profileImageUrl to profileUrl in the JSON path should be verified across the application for consistency.

Run the following script to verify the consistency of the JSON path change:

Verification successful

JSON Path Change Verified

The JSON path change from profileImageUrl to profileUrl has been consistently applied across the codebase. No occurrences of profileImageUrl were found, and profileUrl is present in relevant test and response files, ensuring alignment with the updated response structure.

  • Files with profileUrl:
    • UserIntegrationTest
    • UserSimpleResponseTest
    • UserDetailResponseTest
    • UserDetailResponse
    • UserSimpleResponse
    • UserControllerTest
    • ProductControllerTest
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency of the JSON path change from `profileImageUrl` to `profileUrl`.

# Test: Search for occurrences of `profileImageUrl` and `profileUrl`. Expect: Only occurrences of `profileUrl`.
rg --type java -A 5 $'profileImageUrl'
rg --type java -A 5 $'profileUrl'

Length of output: 8739

src/main/java/taco/klkl/domain/image/domain/Image.java (3)

92-92: Method Renaming Approved: markAsComplete

The renaming of the method from uploadComplete to markAsComplete enhances semantic clarity by better reflecting its functionality.


100-100: Method Renaming Approved: generateFileName

The renaming of the method from createFileName to generateFileName improves clarity regarding its functionality.


107-109: New Method Approved: getUrl

The addition of the getUrl method, which generates a URL for the image, aligns with the PR's objectives to enhance image handling. Verify its integration with other components to ensure seamless functionality.

Run the following script to verify the integration of the getUrl method with other components:

Verification successful

Integration Verified: getUrl Method

The getUrl method is well-integrated into the codebase, being utilized in utility classes and domain logic. This confirms its role in enhancing image handling by generating URLs for images. The integration appears seamless and consistent with the PR's objectives.

  • Usage Locations:
    • UserUtil.java: Used in a mapping operation.
    • ProductUtil.java: Used in a mapping operation.
    • Product.java: Used as a return value.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the `getUrl` method with other components.

# Test: Search for the usage of `getUrl`. Expect: Proper integration with other components.
rg --type java -A 5 $'getUrl'

Length of output: 1741

src/main/java/taco/klkl/domain/image/controller/ImageController.java (2)

60-63: Upload Completion Method Changes Approved

The changes in the methods uploadCompleteUserImage and uploadCompleteProductImages, which now return structured responses and handle multiple images, improve the API's usability for bulk operations. Verify the integration with the frontend and other components to ensure seamless functionality.

Run the following script to verify the integration of these methods with the frontend and other components:

Also applies to: 71-75


38-38: Method Changes Approved: Handling Multiple Images

The changes to handle multiple images in the methods createUserImageUploadUrl and createProductImageUploadUrls enhance the controller's functionality, aligning with the PR's objectives. Verify the integration with the frontend and other components to ensure seamless functionality.

Run the following script to verify the integration of these methods with the frontend and other components:

Also applies to: 48-50, 52-53

src/main/resources/database/data.sql (2)

2-3: Approved: Removal of profile_image_url from klkl_user table.

The change aligns with the PR objectives to refactor image handling logic. The SQL statement is correctly updated to reflect the new data model without the profile_image_url column.


Line range hint 10-702: Consistency Check: Remaining SQL statements.

The rest of the SQL statements are consistent and correct, with no changes related to the PR objectives. They provide necessary context for the database setup and are not affected by the image handling logic changes.

src/test/java/taco/klkl/domain/product/dto/response/ProductSimpleResponseTest.java (2)

Line range hint 113-129: Updated Test Logic: Handling of mainImageUrl.

The test method testConstructor has been correctly updated to handle the new mainImageUrl parameter instead of a list of images. This change is consistent with the PR objectives to focus on a single main image URL. The assertions are correctly updated to verify the new field.


113-113: Method Renaming: generateTagsByProduct.

The renaming of the method from createTagsByProduct to generateTagsByProduct is noted. This change likely enhances clarity or functionality, aligning with best practices for naming consistency and descriptive method names.

src/main/java/taco/klkl/domain/image/service/ImageServiceImpl.java (6)

60-63: Refined Method Signature: createUserImageUploadUrl.

The method createUserImageUploadUrl has been updated to accept a SingleImageUploadRequest instead of the previous generic request type. This change enhances the specificity and clarity of the method, aligning with the PR objectives to handle single image uploads more effectively.


68-75: Enhanced Batch Processing: createProductImageUploadUrls.

The method createProductImageUploadUrls has been correctly updated to handle multiple image uploads through a MultipleImagesUploadRequest. This allows for batch processing of image uploads, improving efficiency and aligning with the PR objectives for handling multiple images simultaneously.


80-91: Updated Logic for Upload Completion: uploadCompleteUserImage.

The method uploadCompleteUserImage now accepts a SingleImageUpdateRequest and includes logic to directly mark the image as complete and update the user's profile image URL. This change enhances the clarity and specificity of the upload completion process, ensuring that the response includes the updated image ID.


96-116: Batch Processing for Product Images: uploadCompleteProductImages.

The method uploadCompleteProductImages has been updated to handle multiple images using a MultipleImagesUpdateRequest. This method marks the images as complete and updates the associated product with the new images, improving feedback to the caller and aligning with the PR objectives for efficient image management.


122-135: Utility Method Adjustment: createImageUploadUrl.

The utility method createImageUploadUrl has been updated to accept a FileExtension object instead of a string. This change streamlines the process of creating image upload URLs, enhancing the clarity and maintainability of the code.


148-149: New Logic for Expiring Old Images: expireOldImages.

The introduction of the expireOldImages method enhances the management of image lifecycle states by marking images as outdated based on their upload state. This addition aligns with the PR objectives to improve image management.

src/main/java/taco/klkl/domain/product/domain/Product.java (1)

252-258: New Feature: Add method to get main image URL.

The addition of getMainImageUrl method is a good enhancement, providing a straightforward way to access the main image URL. This method correctly handles the case where no images are present by returning null. This implementation is clean and efficient.

src/test/java/taco/klkl/domain/product/controller/ProductControllerTest.java (1)

274-275: Consistency: Ensure consistent use of new user profile URL field in assertions.

The updates in the test assertions to check for profileUrl instead of profileImageUrl are correctly applied across multiple test methods. This consistency is crucial for maintaining the integrity of the tests and should be verified across all tests to ensure no old references remain.

Also applies to: 318-319, 361-362

Copy link

@min3m min3m left a comment

Choose a reason for hiding this comment

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

ํฌ์•„์•„์•…...! ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋ณด๋‹ค ์ž๋ฐ” ์ฝ”๋“œ ๋ณด๋‹ค ํ•˜๋‹ˆ๊นŒ ์ •์‹ ์ด ๋‚˜๊ฐˆ๊ฑฐ ๊ฐ™์Šด๋‹ค ใ…‹ใ…‹ใ…‹... ํ™•์‹คํžˆ ์ž๋ฐ” ์ฝ”๋“œ๊ฐ€ ์ด์˜๋„ค์š”... ์ €ํฌ๊ฐ€ ์žˆ์—ˆ์„๋•Œ ์ž„์‹œ๋กœ ๋„ฃ์–ด๋†จ๋˜ ๊ณณ๋“ค์ด ํ•˜๋‚˜ํ•˜๋‚˜ ์ œ๋Œ€๋กœ ์ฑ„์›Œ์ง€๊ณ  ์žˆ๋Š”๊ฑฐ ๊ฐ™์•„์„œ ์‹ ๊ธฐํ•˜๊ธฐ๋„ ํ•˜๊ณ  ์–ผ๋งˆ๋‚˜ ๊ณ ์ƒํ•˜๊ณ  ๊ณ„์‹ค๊นŒ๋ผ๋Š” ์ƒ๊ฐ๋„ ๋“ญ๋‹ˆ๋‹ค! ์œค์ฃผ๋‹˜, ์ƒ์ •๋‹˜, ์˜์„ฑ๋‹˜ ์„ธ ๋ถ„ ๋ชจ๋‘ ํ™”์ดํŒ…์ž…๋‹ˆ๋‹ค!

Copy link
Contributor

@idealflower-k idealflower-k left a comment

Choose a reason for hiding this comment

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

๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์˜ ์ˆ˜์ •์‚ฌํ•ญ์ด ๋งŽ์€๋ฐ ํ˜ผ์ž ์ฒ˜๋ฆฌํ•˜๋Š๋ผ ๊ณ ์ƒ๋งŽ์Šต๋‹ˆ๋‹ค ํŒ€์žฅ๋‹˜...
ํ•„์š”ํ•œ ์ˆ˜์ •์‚ฌํ•ญ๊ณผ ์ด์œ ๋ฅผ ์ž˜ ํ™•์ธํ–ˆ์Šต๋‹ˆ๋‹ค! ํ™”์ดํŒ…! :)

@ohhamma ohhamma merged commit b3a6c43 into develop Sep 6, 2024
2 checks passed
@ohhamma ohhamma deleted the KL-165/์‚ฌ์ง„-๋กœ์ง-๋ณ€๊ฒฝ branch September 6, 2024 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
โ™ป๏ธ Refactor ์ฝ”๋“œ ๋ฆฌํŒฉํ† ๋ง
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants