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

feat(KL-119): add s3 image #59

Merged
merged 65 commits into from
Aug 29, 2024

Conversation

ohhamma
Copy link
Contributor

@ohhamma ohhamma commented Aug 28, 2024

πŸ“Œ μ—°κ΄€λœ 이슈

πŸ“ μž‘μ—… λ‚΄μš©

  • s3 μ—°κ²° (aws sdk v2 μ‚¬μš©)
    • 사진 μ—…λ‘œλ“œ μ‹œ presigned url λ°˜ν™˜
    • μ—…λ‘œλ“œ μ™„λ£Œ μ‹œ μƒν’ˆ / μœ μ € 사진 ν•„λ“œ μ—…λ°μ΄νŠΈ (κΈ°μ‘΄ 사진은 deprecated 처리)
  • cloudfront μ—°κ²°
    • 사진 쑰회 μ‹œ cloudfront λ„λ©”μΈμœΌλ‘œ μ‘°νšŒν•˜λ„λ‘

🌳 μž‘μ—… 브랜치λͺ…

  • KL-119/μƒν’ˆμ‚¬μ§„-s-3-등둝

πŸ“Έ μŠ€ν¬λ¦°μƒ· (선택)

πŸ’¬ 리뷰 μš”κ΅¬μ‚¬ν•­ (선택)

Summary by CodeRabbit

  • New Features

    • Introduced functionality for managing image uploads, including presigned URL generation for user and product images.
    • Added a new endpoint for updating user information in the UserController.
    • Enhanced product management with dynamic handling of associated images.
  • Bug Fixes

    • Updated user retrieval logic to provide more accurate user data handling and error management.
  • Refactor

    • Simplified the creation and updating of user and product entities by restructuring methods.
    • Improved the readability and maintainability of the codebase by isolating specific functionalities into dedicated methods.
  • Documentation

    • Updated API metadata for improved clarity in documentation.
  • Chores

    • Improved error handling capabilities by adding specific exceptions related to image processing and user operations.

ohhamma added 30 commits August 21, 2024 22:18
- 파일 ν™•μž₯자 μœ νš¨ν•˜μ§€ μ•Šμ€ 경우 λ˜μ§€λŠ” FileExtensionInvalidException도 μΆ”κ°€
KL-119/feat: add imageType and targetId

- 이미지 μ—…λ‘œλ“œ μ„œλΉ„μŠ€λ₯Ό μœ μ € ν”„λ‘œν•„ 이미지 μ—…λ‘œλ“œ μ„œλΉ„μŠ€λ‘œ λ³€κ²½
- ImageType enum μΆ”κ°€ 및 Image μ—”ν‹°ν‹° ν•„λ“œμ— μΆ”κ°€
- targetId도 Image μ—”ν‹°ν‹° ν•„λ“œμ— μΆ”κ°€
refactor: move presigned url api to image domain
- MIME type κ·œμ •μ— 맞게 jpeg둜 μˆ˜μ •
@ohhamma ohhamma added the ✨ Feature μƒˆλ‘œμš΄ κΈ°λŠ₯ 개발 및 μš”μ²­ label Aug 28, 2024
@ohhamma ohhamma requested review from idealflower-k and min3m August 28, 2024 08:28
@ohhamma ohhamma self-assigned this Aug 28, 2024
Copy link

coderabbitai bot commented Aug 28, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes encompass a variety of enhancements across the codebase, focusing on user management, image handling, and AWS integration. Key modifications include the introduction of new classes and methods for managing image uploads, updates to user-related functionalities, and the establishment of AWS S3 configuration for image storage. Additionally, several exceptions have been defined to improve error handling, while existing structures have been refined for clarity and maintainability.

Changes

Files Change Summary
.github/workflows/makefile.yaml Simplified .env file creation process by replacing jq with direct echoing of the ENV secret into the file.
build.gradle Added AWS SDK dependencies and updated the Spring profile for tests.
src/main/java/taco/.../controller/TagController.java Updated @Tag annotation to reflect a change in focus from tags to categories.
src/main/java/taco/.../controller/ImageController.java Introduced new RESTful endpoints for handling user and product image uploads using presigned URLs.
src/main/java/taco/.../dao/ImageRepository.java Created a repository interface for Image entities with methods for querying images based on type and target ID.
src/main/java/taco/.../domain/FileExtension.java Added an enum for common image file extensions with a method for converting strings to enum constants.
src/main/java/taco/.../domain/Image.java Introduced an entity class for images with properties related to image data and methods for managing upload states.
src/main/java/taco/.../domain/ImageType.java Created an enum for image types with a method for safe retrieval from string representations.
src/main/java/taco/.../domain/UploadState.java Defined an enum for upload states with a method for matching string values to enum constants.
src/main/java/taco/.../dto/request/ImageUploadRequest.java Introduced a record class for encapsulating image upload request data with validation.
src/main/java/taco/.../dto/response/PresignedUrlResponse.java Defined a record for presigned URL responses with a static factory method for instantiation.
src/main/java/taco/.../exception/FileExtensionNotFoundException.java Created a specific exception for handling scenarios where a file extension is not found.
src/main/java/taco/.../exception/ImageNotFoundException.java Introduced an exception for cases where an image is not found.
src/main/java/taco/.../exception/ImageTypeNotFoundException.java Defined an exception for handling missing image types.
src/main/java/taco/.../exception/ImageUploadNotCompleteException.java Created an exception for incomplete image uploads.
src/main/java/taco/.../exception/ImageUrlInvalidException.java Defined an exception for invalid image URLs.
src/main/java/taco/.../exception/UploadStateNotFoundException.java Created an exception for cases where an upload state is not found.
src/main/java/taco/.../service/ImageKeyGenerator.java Introduced a utility class for generating unique image keys.
src/main/java/taco/.../service/ImageService.java Defined an interface for managing image upload functionality.
src/main/java/taco/.../service/ImageServiceImpl.java Implemented the image service interface with methods for handling image uploads.
src/main/java/taco/.../service/OauthKakaoLoginServiceImpl.java Modified user registration logic to simplify gender and profile image handling.
src/main/java/taco/.../domain/Product.java Enhanced product class to manage associated images with new methods and fields.
src/main/java/taco/.../domain/ProductImage.java Introduced a new entity class for product images with necessary persistence annotations.
src/main/java/taco/.../dto/response/ProductDetailResponse.java Updated response DTO to include product images.
src/main/java/taco/.../dto/response/ProductImageResponse.java Created a DTO for product images with a factory method for instantiation.
src/main/java/taco/.../dto/response/ProductSimpleResponse.java Expanded response object to include product images.
src/main/java/taco/.../service/ProductServiceImpl.java Refactored product update logic to improve tag management.
src/main/java/taco/.../controller/SearchController.java Updated @Tag annotation for the search controller to reflect a new versioning scheme.
src/main/java/taco/.../controller/UserController.java Added a new endpoint for updating user information and simplified existing user retrieval logic.
src/main/java/taco/.../converter/GenderConverter.java Refined gender conversion logic for database representation.
src/main/java/taco/.../domain/Gender.java Renamed fields and methods in the Gender enum for clarity.
src/main/java/taco/.../domain/User.java Modified user fields and methods to enhance clarity regarding user profile images.
src/main/java/taco/.../dto/request/UserCreateRequest.java Removed the profile field from user creation requests to simplify data handling.
src/main/java/taco/.../dto/request/UserUpdateRequest.java Introduced a new record for user update requests with validation annotations.
src/main/java/taco/.../dto/response/UserDetailResponse.java Updated field names to clarify the purpose of the profile image URL.
src/main/java/taco/.../exception/GenderNotFoundException.java Defined a new exception class for handling missing gender values.
src/main/java/taco/.../service/UserService.java Transformed UserService into an interface with updated method signatures for user management.
src/main/java/taco/.../service/UserServiceImpl.java Implemented the user service interface with methods for user retrieval and management.
src/main/java/taco/.../constants/ImageValidationMessages.java Introduced a constants class for image validation messages.
src/main/java/taco/.../constants/NotificationConstants.java Modified the constants class to prevent instantiation and subclassing.
src/main/java/taco/.../constants/UserConstants.java Updated the TEST_USER constant to adjust user initialization logic.
src/main/java/taco/.../config/s3/S3Config.java Created a configuration class for AWS S3 services, defining beans for credentials, S3 client, and presigner.
src/main/java/taco/.../error/exception/ErrorCode.java Updated existing error messages and added new error codes for image handling scenarios.
src/main/java/taco/.../util/UserUtil.java Modified user retrieval methods to enhance robustness by using ID-based access.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ImageService
    participant S3Client

    User->>ImageService: Request Image Upload URL
    ImageService->>S3Client: Generate Presigned URL
    S3Client-->>ImageService: Return Presigned URL
    ImageService-->>User: Provide Presigned URL
Loading

🐰 In the meadow, I hop and play,
With images bright, they light the way.
From uploads swift to clouds so high,
New paths for data, oh my, oh my!
With each little change, we dance and cheer,
A world of wonders, so bright and 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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 Aug 28, 2024

@coderabbitai review

Copy link

coderabbitai bot commented Aug 28, 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.

@ohhamma
Copy link
Contributor Author

ohhamma commented Aug 28, 2024

@coderabbitai review

Copy link

coderabbitai bot commented Aug 28, 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: 9

Outside diff range, codebase verification and nitpick comments (8)
src/test/resources/application-test.yaml (1)

1-22: Configuration settings approved; fix YAML formatting.

The configurations are appropriate for a test environment. However, add a newline at the end of the file to resolve the yamllint error.

+ 
Tools
yamllint

[error] 22-22: no new line character at the end of file

(new-line-at-end-of-file)

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

11-15: Unused method findByImageTypeAndTargetId in ImageRepository.

The method findByImageTypeAndTargetId is defined but not used anywhere in the codebase. Consider reviewing its necessity and removing it if it's not needed to maintain clean and efficient code.

  • Location: src/main/java/taco/klkl/domain/image/dao/ImageRepository.java
Analysis chain

Interface for image repository operations approved.

The defined methods are appropriate for managing images. Verify that these methods are correctly used in the service layer.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of methods in ImageRepository.

# Test: Search for the usage of `findByImageTypeAndTargetId` and `findAllByImageTypeAndTargetId`. Expect: Correct usage in the service layer.
rg --type java -A 5 $'findByImageTypeAndTargetId|findAllByImageTypeAndTargetId'

Length of output: 1144


Script:

#!/bin/bash
# Description: Verify the usage of `findByImageTypeAndTargetId` method in the entire codebase.

# Test: Search for the usage of `findByImageTypeAndTargetId`. Expect: To find its usage or confirm it's unused.
rg --type java -A 5 'findByImageTypeAndTargetId'

Length of output: 484

src/main/java/taco/klkl/domain/user/controller/UserController.java (2)

33-36: Approved addition of the updateMe method with suggestions for enhancement.

The new updateMe method enhances user functionality by allowing updates through the API. Ensure that data validation and security measures are robust, especially in handling sensitive user information.

Consider implementing additional security measures such as rate limiting and more comprehensive input validation to protect against potential security vulnerabilities.


29-31: Add specific mapping for the getMe method in UserController.java.

The getMe method is not currently accessible due to the absence of a specific endpoint mapping for /me. Consider adding an annotation like @GetMapping("/me") to the getMe method to ensure it is correctly mapped and accessible under /v1/users/me.

  • File: src/main/java/taco/klkl/domain/user/controller/UserController.java
  • Suggested Action: Add @GetMapping("/me") to the getMe method.
Analysis chain

Approved changes in the getMe method with a suggestion.

The method now returns UserDetailResponse directly, simplifying the API. Verify that this change does not affect how the API handles responses, especially in terms of HTTP status codes and error handling.

Run the following script to verify the impact on API response handling:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the API response handling for the `getMe` method.

# Test: Check the API response. Expect: Correct HTTP status codes and error handling.
curl -i http://localhost:8080/v1/users/me

Length of output: 604


Script:

#!/bin/bash
# Check for the endpoint mapping in UserController.java to verify if the endpoint is correctly defined.
ast-grep --lang java --pattern '@RequestMapping("/v1/users/me")' 

Length of output: 66


Script:

#!/bin/bash
# Search for all endpoint mappings in UserController.java to verify the defined endpoints.
ast-grep --lang java --pattern '@RequestMapping($_)' 

Length of output: 1385

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

106-107: Security Concern: Lack of Validation in updateProfileImageUrl Method

The createImageUrl method does not perform any validation or sanitization of the URL components, which could lead to security vulnerabilities or data integrity issues. Consider implementing validation and sanitization to ensure the generated URLs are safe and valid. Additionally, add test cases to verify the behavior of updateProfileImageUrl.

  • ImageServiceImpl.java: Add validation in createImageUrl.
Analysis chain

New Feature: Method to update profile image URL.

The addition of the updateProfileImageUrl method allows for dynamic updates to the user's profile image URL. This method should be integrated carefully to ensure it does not introduce security or data integrity issues.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the new method does not introduce security or data integrity issues.

# Test: Search for the usage of the `updateProfileImageUrl` method. Expect: Proper validation and error handling.
rg --type java -A 5 $'updateProfileImageUrl'

Length of output: 916


Script:

#!/bin/bash
# Search for the definition and usage of `imageUrl` in ImageServiceImpl.java to check for validation or error handling.
rg --type java 'imageUrl' -A 5

# Search for any tests related to `updateProfileImageUrl` to verify its behavior.
rg --type java 'updateProfileImageUrl' --files-with-matches | xargs -I {} rg 'test' {}

Length of output: 4504


Script:

#!/bin/bash
# Search for the implementation of the `createImageUrl` method to check for validation or sanitization.
rg --type java 'createImageUrl' -A 5

Length of output: 1521

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

70-83: Method for marking user image upload completion is correctly implemented but could benefit from enhanced logging.

The method uploadCompleteUserImage correctly handles transaction management, exception scenarios, and entity updates. Consider adding logging at key steps for better traceability and debugging.

Consider adding logging statements before and after significant operations such as fetching images and updating the user profile.


98-116: Core method for creating image upload URLs is well-implemented but should include error handling for AWS SDK interactions.

The method createImageUploadUrl is central to the service's functionality, correctly handling image entity creation and S3 interactions. However, consider adding error handling to manage potential AWS SDK exceptions.

Add try-catch blocks around AWS SDK calls to handle potential exceptions and provide fallback mechanisms or appropriate error responses.


118-161: Supporting methods are well-implemented, focusing on single responsibilities.

Methods like createAndSaveImageEntity, uploadCompleteImage, createPutObjectRequest, createPutObjectPresignRequest, and createImageUrl are well-designed, each focusing on a specific part of the functionality. Consider enhancing these methods with more detailed logging and robust error handling, especially for interactions with external systems.

Enhance logging and error handling in methods interacting with AWS S3 and the database to improve maintainability and fault tolerance.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2fdb4c7 and 8da39c3.

Files selected for processing (60)
  • .github/workflows/makefile.yaml (1 hunks)
  • build.gradle (2 hunks)
  • src/main/java/taco/klkl/domain/category/controller/TagController.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/controller/ImageController.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/dao/ImageRepository.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/domain/FileExtension.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/domain/Image.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/domain/ImageType.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/domain/UploadState.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/dto/request/ImageUploadRequest.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/dto/response/PresignedUrlResponse.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/exception/FileExtensionNotFoundException.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/exception/ImageNotFoundException.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/exception/ImageTypeNotFoundException.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/exception/ImageUploadNotCompleteException.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/exception/ImageUrlInvalidException.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/exception/UploadStateNotFoundException.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/service/ImageKeyGenerator.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 (1 hunks)
  • src/main/java/taco/klkl/domain/oauth/service/OauthKakaoLoginServiceImpl.java (1 hunks)
  • src/main/java/taco/klkl/domain/product/domain/Product.java (5 hunks)
  • src/main/java/taco/klkl/domain/product/domain/ProductImage.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/ProductImageResponse.java (1 hunks)
  • src/main/java/taco/klkl/domain/product/dto/response/ProductSimpleResponse.java (1 hunks)
  • src/main/java/taco/klkl/domain/product/service/ProductServiceImpl.java (2 hunks)
  • src/main/java/taco/klkl/domain/search/controller/SearchController.java (1 hunks)
  • src/main/java/taco/klkl/domain/user/controller/UserController.java (1 hunks)
  • src/main/java/taco/klkl/domain/user/converter/GenderConverter.java (1 hunks)
  • src/main/java/taco/klkl/domain/user/domain/Gender.java (1 hunks)
  • src/main/java/taco/klkl/domain/user/domain/User.java (1 hunks)
  • src/main/java/taco/klkl/domain/user/dto/request/UserCreateRequest.java (1 hunks)
  • src/main/java/taco/klkl/domain/user/dto/request/UserUpdateRequest.java (1 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/domain/user/exception/GenderNotFoundException.java (1 hunks)
  • src/main/java/taco/klkl/domain/user/service/UserService.java (1 hunks)
  • src/main/java/taco/klkl/domain/user/service/UserServiceImpl.java (1 hunks)
  • src/main/java/taco/klkl/global/common/constants/ImageValidationMessages.java (1 hunks)
  • src/main/java/taco/klkl/global/common/constants/NotificationConstants.java (1 hunks)
  • src/main/java/taco/klkl/global/common/constants/UserConstants.java (1 hunks)
  • src/main/java/taco/klkl/global/config/s3/S3Config.java (1 hunks)
  • src/main/java/taco/klkl/global/error/exception/ErrorCode.java (2 hunks)
  • src/main/java/taco/klkl/global/util/UserUtil.java (2 hunks)
  • src/main/resources/application-storage.yaml (1 hunks)
  • src/main/resources/application.yaml (1 hunks)
  • src/main/resources/database/data.sql (1 hunks)
  • src/test/java/taco/klkl/domain/comment/controller/CommentControllerTest.java (1 hunks)
  • src/test/java/taco/klkl/domain/comment/service/CommentServiceTest.java (1 hunks)
  • src/test/java/taco/klkl/domain/notification/service/NotificationServiceTest.java (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 (3 hunks)
  • src/test/java/taco/klkl/domain/user/controller/UserControllerTest.java (1 hunks)
  • src/test/java/taco/klkl/domain/user/dto/request/UserRequestDtoTest.java (3 hunks)
  • src/test/java/taco/klkl/domain/user/dto/response/UserDetailResponseTest.java (3 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)
  • src/test/resources/application-test.yaml (1 hunks)
Files skipped from review due to trivial changes (5)
  • .github/workflows/makefile.yaml
  • src/main/java/taco/klkl/domain/category/controller/TagController.java
  • src/main/java/taco/klkl/domain/image/service/ImageKeyGenerator.java
  • src/main/java/taco/klkl/domain/search/controller/SearchController.java
  • src/main/java/taco/klkl/global/common/constants/ImageValidationMessages.java
Additional context used
yamllint
src/main/resources/application-storage.yaml

[error] 20-20: no new line character at the end of file

(new-line-at-end-of-file)

src/test/resources/application-test.yaml

[error] 22-22: no new line character at the end of file

(new-line-at-end-of-file)

Additional comments not posted (98)
src/main/resources/application.yaml (1)

11-11: Confirm the order of configuration entries.

The addition of - storage under the include section is noted. Please confirm if the order of entries (swagger, storage, oauth) has any impact on how configurations are processed or if any specific order is required by the application.

Verification successful

Order of Configuration Entries Does Not Impact Processing

The search through the codebase did not reveal any documentation or code logic indicating that the order of entries (swagger, storage, oauth) in the include section affects configuration processing. Therefore, it is reasonable to conclude that the order does not impact the application's behavior.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the order of configuration entries and their impact.

# Test: Search for documentation or comments in the repository regarding the order of configuration entries.
rg --type yaml "include:" -A 5

Length of output: 321


Script:

#!/bin/bash
# Search for occurrences of `swagger`, `storage`, and `oauth` in the codebase to check for order dependencies.
rg "swagger|storage|oauth" -A 5

Length of output: 87723

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

3-9: Well-structured record for PresignedUrlResponse.

The use of a record is appropriate here, providing a concise and immutable data structure. The factory method from enhances usability by simplifying instance creation. This is a clean and effective implementation.

The code changes are approved.

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

6-10: Appropriate use of custom exception handling.

The ImageNotFoundException class is well-implemented, extending CustomException with a specific ErrorCode. This approach ensures consistent error handling across the application.

The code changes are approved.

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

6-9: Well-implemented custom exception class.

The GenderNotFoundException class is correctly defined and extends CustomException with an appropriate error code, ensuring consistent error handling across the application.

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

6-9: Excellent use of Java records and validation.

The ImageUploadRequest record is well-defined with appropriate validation annotations, ensuring that the file extension is correctly validated. This approach enhances data integrity and usability.

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

6-9: Well-implemented custom exception class.

The ImageUrlInvalidException class is correctly defined and extends CustomException with an appropriate error code, ensuring consistent error handling across the application.

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

6-9: Well-structured custom exception class.

The implementation of ImageTypeNotFoundException is straightforward and follows Java best practices for custom exceptions. It correctly utilizes the ErrorCode enum to standardize error handling.

The code changes are approved.

Verify the existence of IMAGE_TYPE_NOT_FOUND in the ErrorCode enum:

Verification successful

Verification Successful: IMAGE_TYPE_NOT_FOUND Exists in ErrorCode Enum

The IMAGE_TYPE_NOT_FOUND entry is present in the ErrorCode enum, confirming the correct implementation of the ImageTypeNotFoundException class. No issues found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of IMAGE_TYPE_NOT_FOUND in the ErrorCode enum.

# Test: Search for IMAGE_TYPE_NOT_FOUND in ErrorCode.java. Expect: At least one occurrence.
rg --type java 'IMAGE_TYPE_NOT_FOUND' src/main/java/taco/klkl/global/error/exception/ErrorCode.java

Length of output: 166

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

6-9: Consistent implementation of custom exception.

The UploadStateNotFoundException class is implemented consistently with other custom exceptions in the project. It uses the ErrorCode enum effectively to standardize error responses.

The code changes are approved.

Verify the existence of UPLOAD_STATE_NOT_FOUND in the ErrorCode enum:

Verification successful

Verification successful: UPLOAD_STATE_NOT_FOUND exists in ErrorCode enum.

The UPLOAD_STATE_NOT_FOUND constant is present in the ErrorCode enum, confirming that the UploadStateNotFoundException class uses a valid error code. This supports the review comment that the exception is implemented consistently with other custom exceptions in the project.

  • Location: src/main/java/taco/klkl/global/error/exception/ErrorCode.java
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of UPLOAD_STATE_NOT_FOUND in the ErrorCode enum.

# Test: Search for UPLOAD_STATE_NOT_FOUND in ErrorCode.java. Expect: At least one occurrence.
rg --type java 'UPLOAD_STATE_NOT_FOUND' src/main/java/taco/klkl/global/error/exception/ErrorCode.java

Length of output: 170

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

6-9: Consistent and clear custom exception implementation.

The FileExtensionNotFoundException class is well-implemented, following the established patterns for custom exceptions in the project. It effectively uses the ErrorCode enum for standardized error handling.

The code changes are approved.

Verify the existence of FILE_EXTENSION_NOT_FOUND in the ErrorCode enum:

Verification successful

Verification Successful: FILE_EXTENSION_NOT_FOUND Exists in ErrorCode Enum

The FILE_EXTENSION_NOT_FOUND entry is present in the ErrorCode enum, confirming the consistent implementation of the FileExtensionNotFoundException class. No issues were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of FILE_EXTENSION_NOT_FOUND in the ErrorCode enum.

# Test: Search for FILE_EXTENSION_NOT_FOUND in ErrorCode.java. Expect: At least one occurrence.
rg --type java 'FILE_EXTENSION_NOT_FOUND' src/main/java/taco/klkl/global/error/exception/ErrorCode.java

Length of output: 174

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

6-9: Well-structured custom exception class.

The implementation of ImageUploadNotCompleteException is clean and follows Java's exception handling conventions effectively. Using a specific ErrorCode enhances error clarity and handling across the application.

The code changes are approved.

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

7-7: Improved field naming and method parameter handling.

Renaming profile to profileImageUrl clarifies that the field is intended to hold a URL, enhancing code readability and expressiveness. The use of final in the method parameter is a good practice, ensuring the immutability of the input within the method.

The code changes are approved.

Also applies to: 13-13

src/main/java/taco/klkl/global/common/constants/NotificationConstants.java (1)

3-3: Enhanced class integrity and proper use of design patterns.

Declaring NotificationConstants as final and adding a private constructor are excellent practices for utility classes. These changes prevent any subclassing and instantiation, ensuring that the class is used strictly as a holder for constants.

The code changes are approved.

Also applies to: 10-11

src/main/java/taco/klkl/domain/product/dto/response/ProductImageResponse.java (2)

5-8: Record definition is well-formed.

The ProductImageResponse record is defined with appropriate fields and follows Java's conventions for immutable data structures.


9-11: Method implementation is correct.

The static method from correctly creates a ProductImageResponse instance from a ProductImage object. Using final for the method parameter is a good practice.

src/main/java/taco/klkl/domain/user/dto/request/UserUpdateRequest.java (1)

6-11: Record definition is well-formed and validations are appropriate.

The UserUpdateRequest record is defined with necessary validation annotations ensuring data integrity. This setup is crucial for robust data handling in user update operations.

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

7-7: Field renaming enhances clarity.

Renaming the profile field to profileImageUrl improves clarity and accurately reflects the data stored.


12-15: Method update is correct, but verify initial value for totalLikeCount.

The method from is correctly updated to use the new field names and includes the final modifier for the parameter, which is good practice. However, ensure that initializing totalLikeCount to 0 is intended and consistent with business requirements.

Please confirm the initialization logic for totalLikeCount to ensure it aligns with the intended business logic.

src/main/resources/application-storage.yaml (4)

1-4: Configuration profile is correctly set.

The on-profile: "storage" setting is appropriate for segregating storage-specific configurations.


5-8: File size limits are appropriately configured.

The settings for max-file-size and max-request-size are suitable for handling image uploads.


11-14: AWS credentials are securely configured.

Using environment variables for access-key and secret-key enhances security.


17-18: S3 bucket configuration is correct.

The bucket setting is correctly configured to use an environment variable.

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

7-7: Import for custom exception is correctly added.

The import of GenderNotFoundException is necessary for the updated exception handling in the from method.

src/main/java/taco/klkl/global/common/constants/UserConstants.java (1)

Line range hint 6-6: Adjustment in TEST_USER instantiation aligns with new image handling.

The removal of the image path from the TEST_USER instantiation is consistent with the new S3 image handling strategy. Verify that this change does not impact other functionalities that might rely on the image path.

Verification successful

No impact on functionalities due to TEST_USER image path removal

The removal of the image path from the TEST_USER instantiation does not impact other functionalities. The usage of TEST_USER is confined to test files, and there is no dependency on the image path in these contexts.

  • UserConstants.TEST_USER is used in various test files, such as UserControllerTest, SearchServiceImplTest, ProductServiceImplTest, NotificationControllerTest, and SearchControllerTest.
  • No test cases rely on the image path for their assertions or logic.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the removal of the image path does not impact other functionalities.

# Test: Search for usages of `TEST_USER`. Expect: No dependency on the image path.
rg --type java -A 5 $'TEST_USER'

Length of output: 4239

src/main/java/taco/klkl/domain/user/service/UserService.java (4)

7-7: Import and annotation changes approved.

The import of UserUpdateRequest is necessary for the new updateUser method. The removal of @Service is appropriate as interfaces should not carry implementation-specific annotations.

Also applies to: 11-11


11-11: Transformation from class to interface approved.

This change enhances modularity and testability. Ensure that there is an implementing class that handles the business logic previously contained in this class.

Verification successful

Implementation of UserService confirmed.

The UserService interface is correctly implemented by the UserServiceImpl class, ensuring that the business logic is appropriately handled. This transformation enhances the modularity and testability of the service layer.

  • UserServiceImpl is found in src/main/java/taco/klkl/domain/user/service/UserServiceImpl.java.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of an implementing class for UserService.

# Test: Search for classes implementing UserService. Expect: At least one implementing class.
rg --type java -A 5 $'implements UserService'

Length of output: 573


12-12: Verify handling of removed getMyInfo method.

Ensure that the functionality provided by the getMyInfo method is either deprecated or implemented elsewhere in the application.

Verification successful

Functionality of getMyInfo is now handled by getCurrentUser.

The getCurrentUser method is used across the codebase, indicating it has replaced the removed getMyInfo method. This transition maintains the functionality for retrieving user information.

  • UserServiceImpl.java: Implements getCurrentUser.
  • UserController.java: Uses getCurrentUser.
  • Tests: Verify getCurrentUser functionality.
  • CommentService.java: TODO comment suggests future use of getCurrentUser.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify handling of user information retrieval.

# Test: Search for methods handling user information retrieval. Expect: Alternative implementations if `getMyInfo` is deprecated.
rg --type java -A 5 $'getUserInfo|getCurrentUser'

Length of output: 4299


16-16: Addition of updateUser method approved.

This method enhances the service's capabilities. Verify its implementation in the class that implements this interface.

Verification successful

Implementation of updateUser method verified successfully.

The method is correctly implemented in UserServiceImpl.java and is integrated into the user update flow of the application.

  • UserServiceImpl.java: Proper implementation of updateUser method.
  • UserController.java: Usage of updateUser method in the controller layer.
Scripts executed

The following scripts were executed for the analysis:

Script:

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

# Test: Search for the implementation of `updateUser`. Expect: Proper implementation in the implementing class.
rg --type java -A 5 $'updateUser'

Length of output: 2012

src/main/java/taco/klkl/domain/user/dto/request/UserCreateRequest.java (2)

Line range hint 5-9: Approved changes in the record declaration.

The removal of the profile field simplifies the data model and aligns with the updated requirements.

The code changes are approved.


18-18: Approved changes in the factory method.

The factory method of has been updated to exclude the profile parameter, reflecting the changes in the record declaration.

The code changes are approved.

Run the following script to verify the absence of the profile field in the codebase:

Verification successful

Verification Successful: No profile Field Found in UserCreateRequest Context

The search results confirm that the profile parameter has been removed from the UserCreateRequest factory method, as indicated in the review comment. The occurrences of profile in the codebase are related to other contexts and do not contradict the approved changes.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the absence of the `profile` field in the codebase.

# Test: Search for the `profile` field. Expect: No occurrences.
rg --type java $'profile'

Length of output: 3707

src/main/java/taco/klkl/domain/user/converter/GenderConverter.java (2)

11-15: Approved changes in the convertToDatabaseColumn method.

The method now returns gender.getValue(), which likely standardizes or simplifies the database representation of the Gender enum.

The code changes are approved.


19-23: Approved changes in the convertToEntityAttribute method.

The method now utilizes Gender.from(dbData), improving the clarity or efficiency of the conversion process from database string to Gender enum.

The code changes are approved.

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

8-22: Approved introduction of the new ImageService interface.

The interface methods for handling image uploads and marking them as complete align with the PR's objectives to manage image registration in S3 effectively.

The code changes are approved.

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

1-24: Well-structured enumeration for image types.

The ImageType enum is well-defined with clear responsibilities. The use of Lombok annotations (@Getter, @RequiredArgsConstructor) enhances readability and reduces boilerplate. The from method is implemented correctly, using Java streams to filter and find the appropriate enum, and throws a custom exception if not found, which is a robust way to handle errors in this context.

The code changes are approved.

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

1-25: Consistent and clear enumeration for upload states.

The UploadState enum is consistent with the pattern used in ImageType.java, which is good for maintaining a uniform approach across the domain. The use of Lombok annotations enhances readability and the from method's implementation using Java streams is correct. The custom exception for not found scenarios is appropriately used here as well.

The code changes are approved.

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

12-12: Approved addition of the images field.

The inclusion of the images field in the ProductSimpleResponse record is a positive change, enhancing the data structure to support multiple images per product.

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

17-25: Approved changes in the testUserSimpleResponseDto method.

The test method has been correctly updated to reflect the new profileImageUrl field in the UserSimpleResponse DTO.


39-39: Approved changes in the testFrom method.

The test method has been correctly updated to reflect the simplified constructor in the User class.

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

4-12: Approved addition of new imports and annotations.

The new imports and annotations are necessary to support the new updateMe method and are correctly placed in the file.

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

15-17: Good use of Lombok and JPA annotations.

The use of @Getter, @Entity, and @NoArgsConstructor annotations from Lombok and JPA respectively is appropriate and helps reduce boilerplate code. The @NoArgsConstructor is correctly set to PROTECTED to align with JPA requirements for entities.


46-62: Well-implemented factory method and constructor.

The static factory method of and the private constructor are well implemented, promoting immutability and encapsulation of the entity creation logic.


24-31: Review the use of FetchType.LAZY.

The @ManyToOne association is set to FetchType.LAZY. Ensure that this lazy fetching strategy is handled properly in the service layer to avoid LazyInitializationException.

Consider verifying the handling of this lazy association in the service layer or suggest eager fetching if lazy loading is not managed.

Verification successful

Lazy Loading is Properly Managed in the Service Layer

The @Transactional annotation in the ImageServiceImpl class ensures that lazy loading of ProductImage is handled correctly, preventing LazyInitializationException. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for handling of lazy loading in service layer for ProductImage.

# Test: Search for ProductImage usage in service layer. Expect: Proper session management or fetching strategy.
rg --type java -A 5 $'ProductImage'

Length of output: 12638


Script:

#!/bin/bash
# Description: Search for service classes handling ProductImage and check for session management or eager fetching.

# Find all Java files in service directories that might handle ProductImage
fd --type f --extension java service | xargs rg -A 10 'ProductImage'

Length of output: 2941

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

18-18: Variable renaming enhances clarity.

Renaming the profile variable to profileImageUrl improves the descriptiveness of the variable, aligning it with its actual content.


28-28: Method renaming aligns with variable changes.

The method call change from profile() to profileImageUrl() is consistent with the variable renaming, maintaining coherence in the API.


44-44: Ensure alignment with data model changes.

The removal of the profile parameter in the User.of method call suggests a significant model change. Verify that this aligns with the intended changes in the data model.

Check the implementation of the User class to confirm these changes.

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

17-17: Good addition of the images field.

Adding the images field to the ProductDetailResponse record enhances the detail and utility of the response, allowing it to encapsulate a list of images associated with the product.


32-38: Proper handling of the new images field in the from method.

The implementation in the from method correctly populates the new images field by streaming through the product's images and mapping them to ProductImageResponse instances. This ensures that the response is comprehensive and up-to-date.

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

34-34: Verify the integration of getCurrentUser() and profileImageUrl.

Ensure that the getCurrentUser() method is correctly implemented in the UserService and that it integrates seamlessly with existing functionalities. Additionally, verify that the profileImageUrl field is properly managed within the user model and correctly reflects in the user interface where applicable.

Also applies to: 41-41

Verification successful

Integration of getCurrentUser() and profileImageUrl is verified and correctly implemented.

The getCurrentUser() method is properly implemented in UserServiceImpl and is utilized across various tests, ensuring its functionality. The profileImageUrl field is correctly integrated within the User class and response DTOs, with comprehensive test coverage confirming its usage. No issues were found with the integration.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `getCurrentUser()` and usage of `profileImageUrl`.

# Test: Search for the method implementation and usage.
ast-grep --lang java --pattern $'class UserService {
  $$$
  getCurrentUser($_) {
    $$$
  }
  $$$  
}'

# Test: Search for the field usage.
ast-grep --lang java --pattern $'class User {
  $$$
  profileImageUrl: $_
  $$$
}'

Length of output: 189


Script:

#!/bin/bash
# Description: Search for the `getCurrentUser()` method and `profileImageUrl` field across the entire codebase.

# Search for the `getCurrentUser` method definition and usage.
rg 'getCurrentUser\(' -A 3

# Search for the `profileImageUrl` field definition and usage.
rg 'profileImageUrl' -A 3

Length of output: 10495

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

23-24: Approve the updated retrieval method with suggestions for enhancement.

The use of findById for fetching a user by ID is a robust approach. However, consider adding logging before throwing the exception to aid in debugging and monitoring.

The changes are approved, but consider enhancing logging:

-		return userRepository.findById(1L)
-			.orElseThrow(UserNotFoundException::new);
+		return userRepository.findById(1L)
+			.orElseThrow(() -> {
+				log.error("User not found with ID: 1L");
+				return new UserNotFoundException();
+			});
src/test/java/taco/klkl/domain/user/dto/request/UserRequestDtoTest.java (3)

27-27: Approved: Updated test reflects the new data model.

The test has been updated to use a self-introduction string instead of a profile image path, aligning with the changes in the data model.


40-40: Approved: Test correctly reflects the updated data model.

The test now uses a self-introduction string, consistent with the new data model requirements.


53-53: Approved: Test update aligns with the new data model.

The test has been updated to use a self-introduction string, which is consistent with the updated data model.

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

43-51: Approved: Test updates reflect improved API clarity and naming.

The renaming of the method to getCurrentUser and the update to the JSON response field to profileImageUrl both enhance clarity and specificity in the API and its tests.

build.gradle (2)

61-62: Approved: Addition of AWS S3 dependencies.

The new dependencies for AWS SDK and S3 are crucial for integrating S3 services, aligning with the PR's objectives.


77-77: Approved: Update to the active Spring profile for testing.

The update from 'local,h2' to 'test' for the active Spring profile likely enhances the relevance and effectiveness of the testing environment.

src/main/java/taco/klkl/domain/oauth/service/OauthKakaoLoginServiceImpl.java (2)

61-61: Refactor: Simplified user creation parameters.

The change from Gender.MALE.getDescription() to Gender.MALE.getValue() is a positive shift towards using more straightforward, value-based attributes. However, ensure that all parts of the application that rely on this method are updated to handle this change correctly.

Verification successful

Verification Successful: Consistent Update to Gender Value Usage

The change from Gender.MALE.getDescription() to Gender.MALE.getValue() has been consistently applied across the codebase. No occurrences of the former method were found, confirming that all relevant parts of the application have been updated to handle this change correctly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all parts of the application using `Gender.MALE.getDescription()` have been updated.

# Test: Search for the usage of `Gender.MALE.getDescription()`. Expect: No occurrences.
rg --type java -A 5 $'Gender.MALE.getDescription()'

Length of output: 52


Script:

#!/bin/bash
# Description: Verify that all parts of the application using `getDescription()` for the Gender class have been updated.

# Test: Search for any usage of `getDescription()` in the Gender class. Expect: No occurrences.
rg --type java -A 5 'Gender\..*\.getDescription()'

Length of output: 52


61-61: Removed profile image URL from user creation.

The removal of the profile image URL parameter in the user creation process simplifies the data required. This change likely ties into the broader image handling updates mentioned in the PR summary. Ensure that this does not affect other functionalities where the profile image might be expected.

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

25-30: Refactor: Updated field for clarity.

The renaming of the profile field to profileImageUrl clarifies its purpose as holding the URL of the user's profile image. This change should be reflected in the database schema and any part of the application that interacts with user profiles.

Verification successful

Renaming Verification Complete: No Issues Found

The renaming of the profile field to profileImageUrl has been consistently applied across the codebase. The search results show that the old profile field is no longer in use, and the new profileImageUrl field is correctly referenced in relevant parts of the application. The occurrences of profile in some files are unrelated to this change.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the database schema and related application parts have been updated.

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

Length of output: 13272


72-78: Enhancement: Constructor refactoring for clarity.

The constructor now directly initializes profileImageUrl with a default value, enhancing clarity and ensuring consistency. This change should be accompanied by updates to any constructors or factory methods that previously included the profile parameter.

Verification successful

Constructor Refactoring Verified: No Issues Found

The refactoring of the User constructor to initialize profileImageUrl with a default value has been successfully applied. The constructor invocation matches the new signature, and no outdated usages were found. Factory methods like createUser should align with this change, but no issues were detected in the search.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all constructors and factory methods have been updated.

# Test: Search for the old constructor usage with the `profile` parameter. Expect: No occurrences.
rg --type java -A 5 $'User(.*,.*,.*,.*,.)'

Length of output: 779


Script:

#!/bin/bash
# Search for all constructor definitions in the User class to ensure they match the new signature.
ast-grep --lang java --pattern 'class User {
  $$$
  User($_, $_, $_, $_) {
    $$$
  }
  $$$
}'

# Search for all invocations of the User constructor to ensure they match the new signature.
rg --type java 'new User('

# Search for any factory methods related to the User class.
rg --type java 'User createUser('

Length of output: 315


Script:

#!/bin/bash
# Search for all constructor definitions in the User class to ensure they match the new signature.
ast-grep --lang java --pattern 'class User {
  $$$
  User($_, $_, $_, $_) {
    $$$
  }
  $$$
}'

# Correct the search pattern for all invocations of the User constructor.
rg --type java 'new User\('

# Correct the search pattern for any factory methods related to the User class.
rg --type java 'User createUser\('

Length of output: 517

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

30-35: New Feature: Method for creating user image upload URL.

The method createUserImageUploadUrl effectively handles the creation of presigned URLs for user image uploads. Ensure that this method includes proper security checks and error handling to prevent unauthorized access and ensure robustness.


51-57: New Feature: Method for creating product image upload URL.

This method extends the functionality to product images, allowing for the creation of presigned URLs for product image uploads. Similar to the user image upload method, ensure that security measures and error handling are adequately implemented.

src/main/java/taco/klkl/domain/user/service/UserServiceImpl.java (6)

17-21: Well-structured class-level annotations

The use of @Slf4j, @Service, @Primary, and @Transactional(readOnly = true) annotations are appropriate for a primary service implementation. The @RequiredArgsConstructor is effectively used for dependency injection, which enhances the cleanliness and maintainability of the code.


32-36: Correct implementation of getCurrentUser method

This method correctly utilizes the UserUtil to fetch the current user and then transforms it into a UserDetailResponse. The method is concise and adheres to the single responsibility principle.


38-43: Appropriate use of @Transactional for createUser

The createUser method is correctly annotated with @Transactional, which is necessary for operations that modify the database. The method implementation is straightforward and effectively separates the creation of the user entity and its persistence.


45-51: Effective transaction management in updateUser

This method is also annotated with @Transactional and correctly updates the user entity based on the provided request. The method ensures that the user is fetched, updated, and the response is generated from the updated entity, which is a good practice.


53-65: Clear and concise user entity creation

The createUserEntity method is well-implemented, taking inputs from the UserCreateRequest and constructing a User object. The use of Gender.from() suggests a safe conversion from string to enum, which is a good practice to avoid errors related to invalid enum values.


67-79: Robust user update logic

The updateUserEntity method handles the update logic by taking a User and a UserUpdateRequest, and applying changes directly. This method encapsulates the logic for updating user properties, which maintains clean separation of concerns.

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

16-21: Proper use of class-level annotations for JPA entity

The @Getter, @Entity, and @NoArgsConstructor annotations are correctly applied. The entity name is explicitly set, which is good for clarity when dealing with JPA repositories.


21-26: Correct configuration of the primary key

The id field is properly annotated with @Id and @GeneratedValue with a strategy of GenerationType.AUTO. This setup is typical and appropriate for an auto-generated primary key.


28-33: Appropriate use of enum type for imageType

The imageType field uses @Enumerated(EnumType.STRING) which is a good practice for readability and maintainability of the database values as opposed to ordinal.


41-45: Proper definition of imageKey field

The imageKey field is crucial for identifying the image and is correctly marked as non-nullable. This ensures data integrity and is essential for the retrieval and management of images.


47-52: Correct use of enums for fileExtension

Like imageType, the fileExtension field is also using @Enumerated(EnumType.STRING), ensuring that the file extension is stored as a readable string in the database.


54-59: Effective state management with uploadState

The uploadState field is annotated to store the state of the image upload process. Using an enum and marking it as non-nullable ensures that every image has a defined state at all times.


61-66: Immutable createdAt field setup

The createdAt field is configured to be non-nullable and non-updatable, which is a best practice for audit fields in entity classes. This setup ensures that the creation timestamp is preserved without alteration.


68-80: Well-implemented constructor and factory method

The private constructor and public static factory method ensure that the Image object is always instantiated with a consistent state. This pattern is beneficial for maintaining the integrity of the data throughout the application.


91-97: State transition methods for image lifecycle management

The methods uploadComplete and markAsDeprecated are simple and effective for managing the state transitions of the image. These methods ensure that the image's state can be updated in a controlled manner, reflecting its lifecycle accurately.


99-104: Correct implementation of createFileName method

This method constructs the file name based on the image's properties. The structure used ensures that the file path and name are predictable and structured, which is useful for organizing and retrieving files.

src/test/java/taco/klkl/domain/user/service/UserServiceImplTest.java (3)

21-34: Proper setup for unit testing with Mockito

The use of @ExtendWith(MockitoExtension.class) and the configuration of mocks and injects is correctly done. This setup is essential for isolating the service being tested and ensuring that the unit tests are not dependent on external factors.


38-54: Accurate test for getCurrentUser method

The test method testGetCurrentUser is well-structured, using mocks to simulate the behavior of dependencies and verifying the results with assertions. The use of UserConstants.DEFAULT_TOTAL_LIKE_COUNT in assertions is a good practice to ensure that constants are respected in the logic.


71-78: Detailed test for createUser method

The test for createUser effectively simulates the user creation process, including the handling of gender data. The assertions are focused and relevant, ensuring that the created user's details match the expected values.

src/main/java/taco/klkl/global/error/exception/ErrorCode.java (3)

22-22: New error code for gender not found.

Ensure that this new error code is used appropriately wherever gender-related validations are performed.

The addition seems relevant given the context of user profiles.


21-21: Updated terminology for USER_NOT_FOUND.

The change from "μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” μœ μ €μž…λ‹ˆλ‹€." to "μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” μ‚¬μš©μžμž…λ‹ˆλ‹€." is noted. Ensure that this terminology update is consistent across all user-related error messages in the application.


63-68: New error codes for image handling.

The addition of error codes related to image handling (FILE_EXTENSION_NOT_FOUND, IMAGE_TYPE_NOT_FOUND, UPLOAD_STATE_NOT_FOUND, IMAGE_NOT_FOUND, IMAGE_UPLOAD_NOT_COMPLETE, IMAGE_URL_INVALID) is crucial for robust error handling in the new image upload feature.

These error codes should be integrated into the image upload and handling logic.

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

2-2: Updated column name in klkl_user table.

The change from profile to profile_image_url is appropriate for clarity. Verify that all references to the old column name in the application are updated to reflect this change.

Verification successful

Column Name Update Verified

The column name change from profile to profile_image_url appears to have been correctly propagated throughout the application. No references to the old column name in the context of database operations were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the update of the column name across the application.

# Test: Search for old column name usage. Expect: No occurrences of the old name.
rg --type sql -A 5 $'profile'

Length of output: 427


Script:

#!/bin/bash
# Description: Verify the update of the column name across the entire application.

# Test: Search for old column name usage in all file types. Expect: No occurrences of the old name.
rg 'profile'

Length of output: 13148

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

34-34: New import for ProductUtil.

The addition of ProductUtil is intended to centralize tag creation logic. Ensure that ProductUtil.createTagsByProduct is implemented correctly and used consistently in other relevant parts of the application.

The import is justified given the changes in tag handling.


114-141: Enhanced test for ProductSimpleResponse.

The modifications in the test method include the use of ProductUtil for tag creation and the handling of product images. These changes improve the maintainability and clarity of the test.

Ensure that the new methods and the logic for handling images and tags are thoroughly tested to verify their correctness.

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

32-53: Class-level annotations and fields are correctly set up.

The use of @Slf4j, @Primary, @Service, and @Transactional annotations are appropriate and correctly implemented. The configuration fields are properly injected using @Value.


54-59: Method implementation for creating user image upload URL is correct.

The method createUserImageUploadUrl correctly handles transaction management and utilizes utility classes effectively to fetch user details and delegate URL creation.


61-67: Consistent method implementation for product image upload URL.

The method createProductImageUploadUrl is consistent with createUserImageUploadUrl, effectively reusing the URL creation logic for product images.


85-96: Method for marking product image upload completion is correctly implemented.

The method uploadCompleteProductImage effectively handles multiple images and updates the product entity consistently with the user image upload completion method.

src/test/java/taco/klkl/domain/comment/service/CommentServiceTest.java (1)

60-60: Verify the implementation and usage of the new gender determination method.

The change to use Gender.from(userRequestDto.gender()) for determining the user's gender needs to be verified across the application to ensure consistency and correctness.

Run the following script to verify the implementation and usage of Gender.from:

src/test/java/taco/klkl/domain/comment/controller/CommentControllerTest.java (1)

75-75: Verify the implementation and usage of the new gender determination method in controller tests.

The change to use Gender.from(requestDto.gender()) for determining the user's gender in controller tests needs to be verified across the application to ensure consistency and correctness.

Run the following script to verify the implementation and usage of Gender.from:

Verification successful

The Gender.from method is correctly implemented and consistently used across the application.

The method is utilized in both service implementations and test files, indicating that it is a central part of the application's logic for handling gender data and is adequately tested. No issues were found with its implementation or usage.

  • UserServiceImpl.java: Used in service logic.
  • GenderConverter.java: Used in data conversion.
  • UserServiceImplTest.java, CommentServiceTest.java, CommentControllerTest.java: Used in tests.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and usage of `Gender.from`.

# Test: Search for the implementation and usage of `Gender.from`.
ast-grep --lang java --pattern $'Gender.from($_)'

Length of output: 747

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

35-35: Approved new import for handling image responses.

The addition of ProductImageResponse is consistent with the PR's focus on handling product images via S3. This import is necessary for the new test setups and assertions that involve image handling.


64-64: Update to user profile image field in test setup.

The change from profile to profileImageUrl in the UserDetailResponse setup aligns with the updated data model which now includes a more descriptive field for user profile images. This is crucial for ensuring that the tests reflect the actual application behavior.


91-95: Addition of product image responses in test setup.

The setup now includes a list of ProductImageResponse objects, which are used in the ProductSimpleResponse and ProductDetailResponse. This change is necessary to test the new functionality related to image handling as described in the PR summary.


98-98: Inclusion of image responses in product responses.

The imageResponses are now part of both ProductSimpleResponse and ProductDetailResponse setups. This inclusion is essential for testing the full integration of image handling within product responses, ensuring that the functionality works as expected across different parts of the application.

Also applies to: 108-108


279-280: Update to assertions for user profile image URL.

The assertions have been updated to check the profileImageUrl instead of the previous profile field. This change is necessary to ensure that the tests are validating against the correct and updated field names in the user details, aligning with changes in the data model.

Also applies to: 324-325, 368-369

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

52-58: Review of new field images in Product class.

The images field is annotated with @OneToMany and @OrderBy, which are correctly used here to manage the relationship with ProductImage and ensure the images are ordered by orderIndex. This setup is appropriate for the functionality described in the PR summary.

However, consider adding more details in the code comments about how and why images are ordered this way, especially if orderIndex has specific business implications.


251-273: Review of the constructor in Product class.

The constructor has been moved without changes to its implementation. This rearrangement is likely for better readability and organization of the class. It's well-implemented and initializes all fields appropriately, setting defaults for likeCount and createdAt.

No issues found with the constructor's current implementation.

@taco-official taco-official deleted a comment from coderabbitai bot Aug 28, 2024
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.

νŒ€μž₯λ‹˜ 이 μ–΄λ €μš΄ κ±Έ 혼자 λ‹€ ν•˜μ‹œλ‹€λ‹ˆ λŒ€λ‹¨ν•˜μ‹­λ‹ˆλ‹€...
3S와 기타 μˆ˜μ •μ‚¬ν•­ ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€!
κ³ μƒν•˜μ…¨μŠ΅λ‹ˆλ‹€! :)

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.

μ»€λ°‹λŸ‰μ΄λž‘ 파일 κ°―μˆ˜κ°€ 정말 μ–΄λ¨Έμ–΄λ§ˆ ν•˜λ„€μš”β€¦! μ €λž‘ μƒν™”λ‹˜μ΄ λΉ μ Έμ„œ 혼자 λ‹€ ν•˜μ…¨μ–΄μ•Όν–ˆμ„ 텐데 정말 κ³ μƒλ§ŽμœΌμ…¨μŠ΅λ‹ˆλ‹€!!! S3κ΄€λ ¨ 컀밋 ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€! κ³ μƒν•˜μ…¨μŠ΅λ‹ˆλ‹€~~

@ohhamma ohhamma merged commit e01921e into develop Aug 29, 2024
2 checks passed
@ohhamma ohhamma deleted the KL-119/μƒν’ˆμ‚¬μ§„-s-3-등둝 branch August 29, 2024 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature μƒˆλ‘œμš΄ κΈ°λŠ₯ 개발 및 μš”μ²­
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants