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-166): user related api #63

Merged
merged 35 commits into from
Sep 10, 2024
Merged

Conversation

ohhamma
Copy link
Contributor

@ohhamma ohhamma commented Sep 9, 2024

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

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

  • μœ μ € ν•„λ“œμ—μ„œ μ—°λ Ή, 성별 제거 (이후 μΆ”κ°€ μ˜ˆμ •)
  • λ§ˆμ΄νŽ˜μ΄μ§€ κ΄€λ ¨ api κ΅¬ν˜„
    • λ‚΄ μƒν’ˆ λͺ©λ‘ 쑰회
    • λ‚΄ 정보 μˆ˜μ •
    • λ‚΄ μ’‹μ•„μš” λͺ©λ‘ 쑰회
    • λ‚΄ νŒ”λ‘œμž‰ λͺ©λ‘ 쑰회 (μœ μ €, μƒν’ˆ)
  • 일반 μ‚¬μš©μž κ΄€λ ¨ api οΏ½κ΅¬ν˜„
    • μœ μ € ν”„λ‘œν•„ 쑰회
    • μœ μ € μƒν’ˆ λͺ©λ‘ 쑰회
    • μœ μ € νŒ”λ‘œμš° 및 νŒ”λ‘œμš° μ·¨μ†Œ
  • κ΄€λ ¨ 더미데이터 μΆ”κ°€

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

  • KL-166/μœ μ €-api-κ΅¬ν˜„

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

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

Summary by CodeRabbit

  • New Features

    • Introduced new endpoints for image uploads and completions for users and products.
    • Added methods to retrieve user-specific data, including products, likes, and following lists.
    • Implemented follow and unfollow functionality for users.
  • Enhancements

    • Updated response types for pagination in various services and controllers.
    • Improved clarity in user management by refining user retrieval methods.
  • Bug Fixes

    • Adjusted notification handling to ensure user-specific operations.
  • Refactor

    • Streamlined user and product management logic, enhancing maintainability and readability.
  • Tests

    • Updated tests to reflect changes in user and product models, ensuring accurate coverage of new functionalities.

@ohhamma ohhamma added the ✨ Feature μƒˆλ‘œμš΄ κΈ°λŠ₯ 개발 및 μš”μ²­ label Sep 9, 2024
@ohhamma ohhamma self-assigned this Sep 9, 2024
Copy link

coderabbitai bot commented Sep 9, 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.


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 ohhamma changed the title feat(KL-166): user api feat(KL-166): user related api Sep 9, 2024
@ohhamma
Copy link
Contributor Author

ohhamma commented Sep 9, 2024

@coderabbitai review

Copy link

coderabbitai bot commented Sep 9, 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 bot commented Sep 9, 2024

Walkthrough

The changes encompass a comprehensive refactoring of the codebase, including the removal of certain user attributes, updates to method signatures, and the introduction of new functionalities across various controllers, services, and repositories. Key modifications include enhancements to user management, comment handling, product interactions, and notification functionalities. Additionally, several tests have been updated to align with these changes, ensuring consistency in user data handling and improving the overall structure of the code.

Changes

File(s) Change Summary
src/main/java/taco/klkl/domain/comment/controller/CommentController.java Whitespace and formatting adjustments to @Operation annotations.
src/main/java/taco/klkl/domain/comment/domain/Comment.java Removed notifications field and associated annotations.
src/main/java/taco/klkl/domain/comment/service/CommentService.java Replaced userUtil.findTestUser() with userUtil.getCurrentUser() in createCommentEntity.
src/main/java/taco/klkl/domain/image/controller/ImageController.java Added endpoints for image uploads and completion, with @ResponseStatus(HttpStatus.CREATED).
src/main/java/taco/klkl/domain/image/service/ImageServiceImpl.java Changed user retrieval method from findCurrentUser() to getCurrentUser().
src/main/java/taco/klkl/domain/like/controller/LikeController.java Added @ResponseStatus(HttpStatus.CREATED) to addLike method.
src/main/java/taco/klkl/domain/like/dao/LikeRepository.java Added findByUserId method and modified existing method signatures to include final.
src/main/java/taco/klkl/domain/like/service/LikeServiceImpl.java Updated user retrieval method from findCurrentUser() to getCurrentUser().
src/main/java/taco/klkl/domain/notification/dao/NotificationRepository.java Renamed method for consistency with Spring Data JPA naming conventions.
src/main/java/taco/klkl/domain/notification/service/NotificationServiceImpl.java Enhanced notification handling with user-specific logic and added validation.
src/main/java/taco/klkl/domain/oauth/service/OauthKakaoLoginServiceImpl.java Removed gender and age parameters from UserCreateRequest.
src/main/java/taco/klkl/domain/product/controller/ProductController.java Updated return types and added new method for retrieving followed products.
src/main/java/taco/klkl/domain/product/dao/ProductRepository.java Added methods for user-specific product retrieval.
src/main/java/taco/klkl/domain/product/service/ProductService.java Updated return types and added new methods for product retrieval based on following.
src/main/java/taco/klkl/domain/user/controller/UserController.java Introduced new endpoints for user-specific data retrieval and follow functionality.
src/main/java/taco/klkl/domain/user/dao/FollowRepository.java Added methods for managing follow relationships.
src/main/java/taco/klkl/domain/user/dao/UserRepository.java Removed findFirstByName method and modified existsByName signature.
src/main/java/taco/klkl/domain/user/domain/Follow.java Introduced Follow class to represent user follow relationships.
src/main/java/taco/klkl/domain/user/domain/User.java Removed gender and age attributes from the User class.
src/main/java/taco/klkl/domain/user/dto/request/UserCreateRequest.java Updated to remove gender and age fields, enhancing validation for name.
src/main/java/taco/klkl/domain/user/dto/request/UserFollowRequest.java Introduced record for user follow requests.
src/main/java/taco/klkl/domain/user/dto/response/UserFollowResponse.java Defined response structure for user follow actions.
src/main/java/taco/klkl/domain/user/service/UserService.java Removed getCurrentUser() and added methods for user product and like retrieval.
src/main/java/taco/klkl/domain/user/service/UserServiceImpl.java Updated user retrieval and follow management methods.
src/main/java/taco/klkl/global/common/constants/CommentValidationMessages.java Added private constructor to prevent instantiation.
src/main/java/taco/klkl/global/common/constants/ProductConstants.java Removed unused import statement.
src/main/java/taco/klkl/global/common/constants/UserConstants.java Removed test-specific constants.
src/main/java/taco/klkl/global/common/constants/UserValidationMessages.java Introduced class for user validation messages.
src/main/java/taco/klkl/global/common/response/PagedResponse.java Renamed PagedResponseDto to PagedResponse.
src/main/java/taco/klkl/global/util/LikeUtil.java Added utility method for retrieving likes by user ID.
src/main/java/taco/klkl/global/util/ProductUtil.java Added method for retrieving products by user ID.
src/main/java/taco/klkl/global/util/UserUtil.java Refactored user retrieval methods for clarity.
src/test/java/taco/klkl/domain/comment/controller/CommentControllerTest.java Updated test setup to reflect user model changes.
src/test/java/taco/klkl/domain/comment/integration/CommentIntegrationTest.java Modified product IDs in test cases.
src/test/java/taco/klkl/domain/comment/service/CommentServiceTest.java Updated user retrieval method and user creation logic in tests.
src/test/java/taco/klkl/domain/like/service/LikeServiceImplTest.java Renamed user retrieval method in tests.
src/test/java/taco/klkl/domain/notification/controller/NotificationControllerTest.java Updated user initialization in tests.
src/test/java/taco/klkl/domain/notification/integration/NotificationIntegrationTest.java Updated notification ID in tests.
src/test/java/taco/klkl/domain/notification/service/NotificationServiceTest.java Updated user retrieval and notification repository method calls in tests.
src/test/java/taco/klkl/domain/product/controller/ProductControllerTest.java Updated response type in tests.
src/test/java/taco/klkl/domain/product/integration/ProductIntegrationTest.java Modified assertions in product retrieval tests.
src/test/java/taco/klkl/domain/product/service/ProductServiceImplTest.java Updated response types and user retrieval in tests.
src/test/java/taco/klkl/domain/user/controller/UserControllerTest.java Added mock for UserUtil and updated user initialization in tests.
src/test/java/taco/klkl/domain/user/dto/request/UserRequestDtoTest.java Updated user create request instantiation in tests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UserService
    participant UserUtil
    participant FollowRepository

    User->>UserUtil: getCurrentUser()
    UserUtil->>UserService: fetch user details
    UserService->>FollowRepository: createUserFollow()
    FollowRepository-->>UserService: follow relationship created
    UserService-->>UserUtil: return updated user info
    User-->>UserUtil: display follow status
Loading

πŸ‡ In the code we hop and play,
New features bloom, bright as day!
With user follows and likes galore,
Our app's a garden, growing more!
So let’s rejoice, both big and small,
For changes made, we celebrate all! 🌼

Tip

New features

Walkthrough comment now includes:

  • Possibly related PRs: A list of potentially related PRs to help you recall past context.
  • Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs. You can also provide custom labeling instructions in the UI or configuration file.

Notes:

  • Please share any feedback in the discussion post on our Discord.
  • Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).

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.

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

Outside diff range, codebase verification and nitpick comments (4)
src/main/java/taco/klkl/domain/product/dao/ProductRepository.java (1)

19-28: Approved: New method findProductsOfFollowedUsers

The addition of the findProductsOfFollowedUsers method with a custom JPQL query is correctly implemented. However, consider reviewing the performance of this query, especially with large datasets, to ensure it meets efficiency standards.

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

34-36: Test coverage needed for findByUserId method in ProductRepository.

The findByUserId method in ProductRepository is declared but lacks explicit test coverage. Ensure that unit tests are added to verify its functionality, especially if it relies on query derivation by Spring Data JPA.

Analysis chain

New method for fetching products by user ID with pagination.

The addition of findProductsByUserId is well-implemented, using pagination to efficiently handle large data sets. Ensure that the corresponding repository method findByUserId is properly implemented and covered by unit tests.

Run the following script to verify the repository method:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `findByUserId` in the product repository.

# Test: Search for the method implementation. Expect: Proper implementation and test coverage.
rg --type java -A 5 $'findByUserId'

Length of output: 2010


Script:

#!/bin/bash
# Check the implementation details of the `findByUserId` method in ProductRepository.java
rg --type java -A 10 'Page<Product> findByUserId' src/main/java/taco/klkl/domain/product/dao/ProductRepository.java

# Search for test cases covering the `findByUserId` method
rg --type java 'findByUserId' --glob '*Test.java'

Length of output: 607

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

81-88: Lack of Unit Tests for findFollowingProducts

The findFollowingProducts function in ProductController.java does not appear to have any associated unit tests. It is important to add tests to verify its functionality, especially for edge cases involving empty or large sets of following IDs. Please ensure that comprehensive tests are implemented to maintain code quality and reliability.

Analysis chain

Approved new functionality with a testing suggestion.

The implementation of findFollowingProducts is consistent with existing pagination and filtering patterns. Ensure thorough testing, particularly with edge cases involving empty or large sets of following IDs.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Test new function `findFollowingProducts`.

# Test: Run unit tests for `findFollowingProducts`. Expect: Coverage of edge cases.
echo "Run unit tests covering `findFollowingProducts` with edge cases."

Length of output: 206


Script:

#!/bin/bash
# Search for unit tests related to the `findFollowingProducts` function in the codebase.
rg 'findFollowingProducts' --glob '*Test.java' -A 5

Length of output: 51


Script:

#!/bin/bash
# Expand the search for references to the `findFollowingProducts` function in all Java files.
rg 'findFollowingProducts' --glob '*.java' -A 5

Length of output: 808

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

61-61: Potential issue with getCurrentUser() implementation.

The getCurrentUser() method in UserUtil.java currently returns a test user (getTestUser()). This implementation might not be suitable for production use, especially given its widespread usage across the codebase. Ensure that getCurrentUser() is correctly implemented to retrieve the actual current user in a production environment.

  • File: src/main/java/taco/klkl/global/util/UserUtil.java
  • Method: getCurrentUser()
Analysis chain

Verify the integration of the new user retrieval method.

The change from userUtil.findCurrentUser() to userUtil.getCurrentUser() in createUserImageUploadUrl suggests a shift in user retrieval logic. Ensure that the new method integrates well with the existing system and does not introduce any regressions.

Scripts executed

The following scripts were executed for the analysis:

Script:

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

# Test: Search for the method implementation and its usage. Expect: Correct implementation and usage.
rg --type java -A 5 $'getCurrentUser'

Length of output: 20828

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b3a6c43 and f0fe22c.

Files selected for processing (51)
  • src/main/java/taco/klkl/domain/comment/controller/CommentController.java (3 hunks)
  • src/main/java/taco/klkl/domain/comment/domain/Comment.java (3 hunks)
  • src/main/java/taco/klkl/domain/comment/service/CommentService.java (1 hunks)
  • src/main/java/taco/klkl/domain/image/controller/ImageController.java (2 hunks)
  • src/main/java/taco/klkl/domain/image/service/ImageServiceImpl.java (2 hunks)
  • src/main/java/taco/klkl/domain/like/controller/LikeController.java (2 hunks)
  • src/main/java/taco/klkl/domain/like/dao/LikeRepository.java (2 hunks)
  • src/main/java/taco/klkl/domain/like/service/LikeServiceImpl.java (1 hunks)
  • src/main/java/taco/klkl/domain/notification/dao/NotificationRepository.java (1 hunks)
  • src/main/java/taco/klkl/domain/notification/service/NotificationServiceImpl.java (2 hunks)
  • src/main/java/taco/klkl/domain/oauth/service/OauthKakaoLoginServiceImpl.java (2 hunks)
  • src/main/java/taco/klkl/domain/product/controller/ProductController.java (5 hunks)
  • src/main/java/taco/klkl/domain/product/dao/ProductRepository.java (1 hunks)
  • src/main/java/taco/klkl/domain/product/service/ProductService.java (3 hunks)
  • src/main/java/taco/klkl/domain/product/service/ProductServiceImpl.java (9 hunks)
  • src/main/java/taco/klkl/domain/user/controller/UserController.java (2 hunks)
  • src/main/java/taco/klkl/domain/user/dao/FollowRepository.java (1 hunks)
  • src/main/java/taco/klkl/domain/user/dao/UserRepository.java (1 hunks)
  • src/main/java/taco/klkl/domain/user/domain/Follow.java (1 hunks)
  • src/main/java/taco/klkl/domain/user/domain/User.java (2 hunks)
  • src/main/java/taco/klkl/domain/user/dto/request/UserCreateRequest.java (1 hunks)
  • src/main/java/taco/klkl/domain/user/dto/request/UserFollowRequest.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/UserFollowResponse.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 (3 hunks)
  • src/main/java/taco/klkl/global/common/constants/CommentValidationMessages.java (1 hunks)
  • src/main/java/taco/klkl/global/common/constants/ProductConstants.java (1 hunks)
  • src/main/java/taco/klkl/global/common/constants/UserConstants.java (1 hunks)
  • src/main/java/taco/klkl/global/common/constants/UserValidationMessages.java (1 hunks)
  • src/main/java/taco/klkl/global/common/response/PagedResponse.java (2 hunks)
  • src/main/java/taco/klkl/global/util/LikeUtil.java (1 hunks)
  • src/main/java/taco/klkl/global/util/ProductUtil.java (2 hunks)
  • src/main/java/taco/klkl/global/util/UserUtil.java (2 hunks)
  • src/main/resources/database/data.sql (2 hunks)
  • src/test/java/taco/klkl/domain/comment/controller/CommentControllerTest.java (2 hunks)
  • src/test/java/taco/klkl/domain/comment/integration/CommentIntegrationTest.java (3 hunks)
  • src/test/java/taco/klkl/domain/comment/service/CommentServiceTest.java (3 hunks)
  • src/test/java/taco/klkl/domain/like/service/LikeServiceImplTest.java (6 hunks)
  • src/test/java/taco/klkl/domain/notification/controller/NotificationControllerTest.java (2 hunks)
  • src/test/java/taco/klkl/domain/notification/integration/NotificationIntegrationTest.java (1 hunks)
  • src/test/java/taco/klkl/domain/notification/service/NotificationServiceTest.java (6 hunks)
  • src/test/java/taco/klkl/domain/product/controller/ProductControllerTest.java (3 hunks)
  • src/test/java/taco/klkl/domain/product/integration/ProductIntegrationTest.java (3 hunks)
  • src/test/java/taco/klkl/domain/product/service/ProductServiceImplTest.java (5 hunks)
  • src/test/java/taco/klkl/domain/user/controller/UserControllerTest.java (2 hunks)
  • src/test/java/taco/klkl/domain/user/dto/request/UserRequestDtoTest.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 (2 hunks)
  • src/test/java/taco/klkl/domain/user/integration/UserIntegrationTest.java (2 hunks)
  • src/test/java/taco/klkl/domain/user/service/UserServiceImplTest.java (3 hunks)
Files skipped from review due to trivial changes (8)
  • src/main/java/taco/klkl/domain/comment/controller/CommentController.java
  • src/main/java/taco/klkl/global/common/constants/CommentValidationMessages.java
  • src/main/java/taco/klkl/global/common/constants/ProductConstants.java
  • src/main/java/taco/klkl/global/common/constants/UserConstants.java
  • src/main/java/taco/klkl/global/common/constants/UserValidationMessages.java
  • src/test/java/taco/klkl/domain/comment/controller/CommentControllerTest.java
  • src/test/java/taco/klkl/domain/like/service/LikeServiceImplTest.java
  • src/test/java/taco/klkl/domain/notification/integration/NotificationIntegrationTest.java
Additional comments not posted (92)
src/main/java/taco/klkl/domain/user/dto/request/UserFollowRequest.java (1)

6-9: Well-structured and clear implementation of UserFollowRequest.

The use of records here is appropriate for the data transfer object, ensuring immutability and thread safety. The @NotNull validation on userId is crucial and correctly implemented with a clear message from UserValidationMessages. This promotes consistency and maintainability.

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

7-7: Enhanced validation for name field.

The change to @NotBlank for the name field is a significant improvement, ensuring that the field cannot be empty or contain only whitespace. This enforces more robust data validation.

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

11-11: Good practice: Use of final in method parameters.

The addition of final to the existsByName method parameter is a good practice, ensuring that the parameter cannot be reassigned within the method, which enhances code clarity and reliability.

src/main/java/taco/klkl/domain/notification/dao/NotificationRepository.java (1)

11-11: Method renaming approved.

The renaming of the method from findAllByComment_Product_User to findByComment_Product_User aligns well with Spring Data JPA conventions and improves readability. Ensure that all references to the old method name are updated across the codebase.

Run the following script to verify the method usage:

Verification successful

Method renaming verified successfully.

All references to the old method name findAllByComment_Product_User have been updated across the codebase. The renaming to findByComment_Product_User is consistent and complete.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the old method name are updated.

# Test: Search for the old method name. Expect: No occurrences.
rg --type java "findAllByComment_Product_User"

Length of output: 46


Script:

#!/bin/bash
# Re-run the verification to ensure all references to the old method name are updated.

# Search for the old method name in all Java files. Expect: No occurrences.
rg --type java "findAllByComment_Product_User" || echo "No occurrences found or an error occurred."

Length of output: 141

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

1-17: New record UserFollowResponse implementation approved.

The implementation of the UserFollowResponse record is well-designed, using Java's record feature to ensure immutability and clarity. The static factory method of is correctly implemented, ensuring that only necessary data is exposed through the use of getId.

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

3-16: Refactoring of UserCreateRequest approved.

The changes to the UserCreateRequest record, including the addition of the @NotBlank annotation to the name field and the removal of the gender and age fields, are well-implemented. These modifications enhance the validation logic and align with the updated data model requirements.

Run the following script to ensure that the removal of gender and age fields is consistent across the codebase:

Verification successful

Removal of gender and age fields verified.

The gender and age fields have been successfully removed from the UserCreateRequest and are not referenced elsewhere in the user-related classes or DTOs. This aligns with the updated data model requirements.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the removal of `gender` and `age` fields across the codebase.

# Test: Search for the removed fields. Expect: No occurrences.
rg --type java "@PositiveOrZero\\s+Integer age|String gender"

Length of output: 62


Script:

#!/bin/bash
# Description: Verify the removal of `gender` and `age` references across the codebase.

# Search for any occurrences of `gender` and `age` in the codebase.
rg --type java "gender|age"

Length of output: 103619


Script:

#!/bin/bash
# Description: Verify the removal of `gender` and `age` references specifically within user-related classes or DTOs.

# Search for any occurrences of `gender` and `age` in user-related classes or DTOs.
rg --type java "gender|age" --glob "**/user/**/*.java"

Length of output: 8783

src/main/java/taco/klkl/global/common/response/PagedResponse.java (2)

17-22: Method update approved.

The update to the method signature and its implementation are correct. The method efficiently transforms a Page<T> to a PagedResponse<R> using the provided mapper function.


8-8: Renaming approved, verify usage.

The renaming of the record from PagedResponseDto to PagedResponse simplifies and clarifies its purpose. Ensure that all references to the old name are updated across the codebase.

Run the following script to verify the usage of PagedResponse:

Verification successful

Renaming verified and correctly applied.

The renaming of PagedResponseDto to PagedResponse has been successfully propagated throughout the codebase. All references have been updated, and the new name is being used consistently in both main and test files.

  • No occurrences of PagedResponseDto found.
  • PagedResponse is used in multiple files, confirming correct application.
Scripts executed

The following scripts were executed for the analysis:

Script:

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

# Test: Search for the old name. Expect: No occurrences.
rg --type java $'PagedResponseDto'

Length of output: 33


Script:

#!/bin/bash
# Description: Verify the usage of the new `PagedResponse` name.

# Test: Search for the new name. Expect: Occurrences in relevant files.
rg --type java $'PagedResponse'

Length of output: 5041

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

11-18: New repository interface approved.

The FollowRepository interface is well-defined with methods for managing follow relationships between users. It correctly extends JpaRepository, providing essential CRUD operations along with custom methods for specific follow interactions.

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

11-19: Utility class for like operations approved.

The LikeUtil class is well-structured for handling operations related to likes. The method findLikesByUserId correctly utilizes the LikeRepository to fetch likes based on user ID, supporting pagination with Pageable.

src/main/java/taco/klkl/domain/like/dao/LikeRepository.java (3)

14-14: Approved: New method findByUserId

The addition of the findByUserId method is correctly implemented and follows best practices for Spring Data repositories.


16-16: Approved: Method signature change

The addition of final to the parameters of deleteByProductAndUser is a good practice to ensure immutability and clarity.


18-18: Approved: Method signature change

The addition of final to the parameters of existsByProductAndUser enhances code maintainability by enforcing parameter immutability.

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

36-36: Approved: Updated method call in test

The update to the User.of method call in testFrom reflects the removal of gender and age parameters, aligning with the changes in the user model. Ensure that the User class has been updated accordingly to accept these parameters.

Run the following script to verify the User class method signature:

Verification successful

Verified: Consistent User.of Method Signature

The User.of method is correctly defined to accept two parameters, name and description, aligning with its usage across the codebase. The changes in the test file are consistent with this method signature.

  • User.of method definition found in src/main/java/taco/klkl/domain/user/domain/User.java.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `User.of` method signature in the `User` class.

# Test: Search for the `User.of` method. Expect: Only occurrences of the new signature.
ast-grep --lang java --pattern $'class User {
  $$$
  of($_, $_) {
    $$$
  }
  $$$  
}'

Length of output: 90


Script:

#!/bin/bash
# Description: Search for all `User.of` method definitions to verify their signatures.

# Test: Search for any `User.of` method definitions in the codebase.
rg --multiline --multiline-dotall 'User\.of\(' -A 5

Length of output: 6310


Script:

#!/bin/bash
# Description: Search for the definition of the `User.of` method in the `User` class.

# Test: Search for the `User.of` method definition in the codebase.
ast-grep --lang java --pattern $'class User {
  $$$
  static User of($_, $_) {
    $$$
  }
  $$$  
}'

Length of output: 102


Script:

#!/bin/bash
# Description: Perform a broader search for the `User.of` method definition.

# Test: Search for any `User.of` method definitions in the codebase.
rg --multiline --multiline-dotall 'User\s+of\s*\(' -A 10

Length of output: 834

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

17-17: Approved: New method findByUserId

The addition of the findByUserId method is correctly implemented and follows best practices for Spring Data repositories.

src/test/java/taco/klkl/domain/user/dto/request/UserRequestDtoTest.java (2)

27-27: Correct adaptation to model changes.

The test method has been updated to reflect the removal of the age parameter, aligning with the changes in the UserCreateRequest constructor.


40-40: Test simplification aligns with model updates.

The test method has been simplified to focus on the essential validation of the UserCreateRequest constructor, specifically checking for a null name.

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

21-21: Enhanced user retrieval functionality.

The introduction of getUserById enhances the service's functionality by allowing specific user retrieval based on ID, which is a more flexible approach compared to the previous getCurrentUser() method.


23-23: Valuable addition for user-product interaction.

The method getUserProductsById provides a paginated approach to retrieve products associated with a specific user, enhancing the service's capabilities in managing user-related product data.


25-25: Enhancement to user interaction model.

The method getUserLikesById allows for the retrieval of user likes in a paginated format, enriching the user interaction model within the application.


27-27: Facilitates social interactions.

The method getUserFollowingById returns a list of users that the specified user is following, thereby facilitating social interactions within the application.


31-31: Enhances social networking features.

The method createUserFollow allows users to initiate follow relationships, enhancing the social networking features of the application.


33-33: Essential for managing follow relationships.

The method removeUserFollow allows users to terminate follow relationships, which is essential for managing these interactions within the application.

src/main/java/taco/klkl/domain/like/controller/LikeController.java (1)

28-28: Semantic enhancement to API response.

The addition of the @ResponseStatus(HttpStatus.CREATED) annotation to the addLike method improves the clarity of the API's response by explicitly signaling that a resource has been successfully created.

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

Line range hint 6-20: LGTM!

The test method testUserDetailResponseDto correctly tests the UserDetailResponse DTO and ensures that all fields are accurately mapped.


41-41: LGTM, but verify related changes.

The test method testFrom has been updated to reflect the changes in the User class constructor. Ensure that all related tests across the codebase have been updated to reflect the removal of gender and age.

Run the following script to verify the removal of gender and age across related tests:

Verification successful

Verification successful: No issues found with the removal of gender and age.

The UserDetailResponseTest has been correctly updated to reflect the changes in the User class constructor. The absence of the old constructor usage confirms that the codebase has been updated accordingly. Remaining references to gender and age are unrelated to this specific change.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all related tests have been updated to reflect the removal of `gender` and `age`.

# Test: Search for the old constructor usage. Expect: No occurrences.
rg --type java -A 5 $'User.of($_, $_, $_, $_)'

Length of output: 47


Script:

#!/bin/bash
# Description: Search for any remaining references to `gender` and `age` in the context of `User` objects.

# Search for references to `gender` in Java files.
rg --type java 'gender'

# Search for references to `age` in Java files.
rg --type java 'age'

Length of output: 103634

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

64-64: Method update streamlined.

The update method in the User class has been streamlined to only include name and description. This change simplifies the user update process but requires verification to ensure it does not affect other functionalities.

Run the following script to verify the update method usage across the application:

Verification successful

Verification Successful: update Method Usage is Consistent

The update method in the User class is correctly used with the new signature of two parameters (name and description) in the UserServiceImpl.java file. This confirms that the streamlining of the method does not affect other functionalities.

  • UserServiceImpl.java: user.update(name, description)
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `update` method usage has been correctly updated across the application.

# Test: Search for the old `update` method usage. Expect: No occurrences.
rg --type java -A 5 $'update($_, $_, $_, $_)'

Length of output: 46


Script:

#!/bin/bash
# Description: Verify that the `update` method usage with two parameters is present across the application.

# Test: Search for the current `update` method usage with two parameters.
rg --type java -A 5 $'update($_, $_)'

Length of output: 38


Script:

#!/bin/bash
# Description: Search for the `User` class and list its methods to confirm the presence of the `update` method.

# Test: Search for the `User` class and its methods.
ast-grep --lang java --pattern $'class User {
  $$$
  update($_, $_) {
    $$$
  }
  $$$
}'

# Test: Search for any usage of the `update` method in the codebase.
rg --type java 'update('

Length of output: 184


Script:

#!/bin/bash
# Description: Correct the search for any usage of the `update` method in the codebase.

# Test: Search for any usage of the `update` method in the codebase with corrected regex.
rg --type java 'update\('

Length of output: 657


Script:

#!/bin/bash
# Description: Extract specific lines from `UserServiceImpl.java` where the `update` method is called.

# Test: Extract lines with `update` method calls in `UserServiceImpl.java` to verify parameter count.
rg --type java -A 2 'user.update\(' src/main/java/taco/klkl/domain/user/service/UserServiceImpl.java

Length of output: 141


64-64: Constructor updated successfully.

The constructor of the User class has been successfully updated to reflect the removal of gender and age. Ensure that all instances of User creation throughout the application are updated accordingly.

Run the following script to verify the User constructor usage across the application:

src/main/java/taco/klkl/domain/comment/domain/Comment.java (1)

Line range hint 1-40: Simplification of the Comment class.

The removal of the notifications field simplifies the Comment class. Ensure that this change does not negatively impact the handling of comments in relation to notifications and that all related functionalities have been appropriately adjusted.

Run the following script to verify that the removal of the notifications field has been appropriately handled across the application:

Verification successful

Removal of notifications field from Comment class is handled appropriately.

The removal of the notifications field from the Comment class does not negatively impact the notification functionality. Notifications are still linked to comments through the Notification class, which maintains a reference to Comment. The NotificationServiceImpl and CommentService classes ensure that notifications are created and managed correctly. Tests in the codebase verify the functionality of notifications in relation to comments.

  • Notification class maintains a reference to Comment.
  • NotificationServiceImpl handles notification creation based on comments.
  • CommentService calls notificationService.createNotificationByComment(comment) when creating comments.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the removal of the `notifications` field does not negatively impact related functionalities.

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

Length of output: 9609


Script:

#!/bin/bash
# Description: Search for references to the `Comment` class to verify how notifications are handled after the removal of the `notifications` field.

# Test: Search for occurrences of the `Comment` class. Expect: References showing how comments are used in relation to notifications.
rg --type java -A 5 'Comment'

Length of output: 100990

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

29-30: Refactoring Approved: Method Renaming and Simplification

The renaming of findCurrentUser to getCurrentUser and the refactoring to use getTestUser directly simplifies the method's usage and improves readability. This change aligns with best practices for method naming and encapsulation.


50-53: New Method Implementation Review: getTestUser

The new getTestUser method encapsulates the logic for fetching a test user by a hard-coded ID. While this is suitable for test scenarios, consider the following improvements:

  • Dynamic Test User Retrieval: If this method is used in a production environment, it might be beneficial to allow the ID to be passed as a parameter or configured externally to avoid hard-coding.
  • Error Handling: The method throws a UserNotFoundException if the user is not found, which is appropriate. Ensure that this exception is handled gracefully wherever getTestUser is called.
src/main/java/taco/klkl/domain/product/service/ProductService.java (3)

20-20: Refactoring Approved: Method Signature Change

The change from PagedResponseDto to PagedResponse in the method signature for findProductsByFilterOptionsAndSortOptions simplifies the interface and potentially aligns better with the internal data handling practices.


26-30: New Method Implementation Review: findProductsByPartialName

This new method enhances the service's capability to search for products based on partial names, which is a valuable feature for improving user search experiences. Ensure that the implementation handles edge cases such as very short partial names or special characters.


32-32: New Method Implementation Review: findMyFollowingProducts

The addition of findMyFollowingProducts allows users to retrieve products based on their following lists, which is a significant enhancement for personalized user experiences. Verify that the method efficiently handles large sets of following IDs and consider adding caching if performance issues arise.

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

33-35: Proper use of dependency injection for UserUtil.

The injection of UserUtil using @Autowired is correctly implemented, enhancing the modularity and maintainability of the test class.


39-40: Updated test method to use UserUtil.

The refactoring to use UserUtil for fetching the current user is a good practice, enhancing clarity and maintainability. Ensure all necessary user attributes are asserted in the tests to fully validate the user details.

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

Line range hint 34-36: Simplified user registration by removing gender and age.

The removal of gender and age from the UserCreateRequest simplifies the registration process. Verify that this change aligns with business requirements and does not affect other functionalities.

Run the following script to verify the impact on the user registration process:

Verification successful

Removal of gender and age from UserCreateRequest is consistent and does not affect other functionalities.

The UserCreateRequest is used across various test files and service implementations without any reference to gender or age fields, confirming that the change is well-integrated and does not introduce unintended consequences.

  • UserCreateRequest now only includes name and description.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of removing gender and age on the user registration process.

# Test: Search for the usage of `UserCreateRequest`. Expect: No unintended consequences.
rg --type java -A 5 $'UserCreateRequest'

Length of output: 11816

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

32-33: Approved: Addition of UserUtil as a mocked dependency.

The introduction of UserUtil as a mocked dependency is a good practice in unit testing, ensuring that the tests remain focused on the controller's logic without external side effects.


40-40: Approved: Simplified user model in test setup.

The changes in the setUp method to initialize the User object with only name and description are consistent with the modifications in the main codebase, ensuring that the tests remain relevant.


48-49: Approved: Enhanced test coverage in testGetMe.

The updates in the testGetMe method, including the use of userUtil.getCurrentUser() and the new mock interaction for userService.getUserById(any()), enhance the test's accuracy and coverage by ensuring correct interactions with the updated dependencies.

src/main/java/taco/klkl/domain/like/service/LikeServiceImpl.java (1)

63-63: Approved: Simplified method for fetching current user.

The change from userUtil.findCurrentUser() to userUtil.getCurrentUser() in the findCurrentUser method simplifies the approach to fetching the current user, likely reflecting an improved design in the UserUtil class.

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

37-47: Approved: Updated test method for user retrieval by ID.

The renaming of the method from testGetCurrentUser to testGetUserById and the updated logic to fetch a user by ID enhance the specificity and clarity of the test, ensuring it accurately reflects the intended functionality.


37-47: Approved: Simplified user creation in tests.

The removal of gender and age parameters in the testCreateUser method simplifies the user creation process in the tests, focusing on essential attributes and aligning with the updated user model.

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

34-35: Correct implementation of HTTP status and endpoint mapping.

The use of @ResponseStatus(HttpStatus.CREATED) correctly indicates that a resource creation is expected to occur, which aligns with the RESTful design of HTTP status codes. The @PostMapping annotation is also appropriately used for creating resources.


46-47: Proper use of annotations and method signature for product image uploads.

The method createProductImageUploadUrls is correctly annotated with @ResponseStatus(HttpStatus.CREATED), which is suitable for a creation operation. The use of @PathVariable to capture the productId is also correctly implemented, ensuring that the method can handle requests specific to a product.

src/main/java/taco/klkl/domain/comment/service/CommentService.java (1)

84-84: Enhanced realism in user context handling.

The replacement of findTestUser with getCurrentUser in the createCommentEntity method is a positive change, enhancing the realism of the application by using actual user data. Ensure that the getCurrentUser method is thoroughly tested to handle various user states and scenarios.

Consider verifying the robustness of the getCurrentUser method across different user scenarios to ensure its reliability in production.

src/main/java/taco/klkl/domain/notification/service/NotificationServiceImpl.java (4)

63-66: Improved specificity in notification fetching.

The modification to use findByComment_Product_User instead of a broader query enhances the accuracy and relevance of the notifications fetched. Ensure that the query accurately fetches notifications for the intended user to avoid any potential issues with data access or privacy.

Consider verifying the query's accuracy in different scenarios to ensure it consistently retrieves the correct notifications for the user.


74-74: Added security through user-specific validation.

The introduction of validateMyNotification in the readNotificationById method is a commendable addition, enhancing the security and integrity of the notification handling process. Ensure that this validation logic is robust and thoroughly reviewed to prevent any unauthorized access.

Consider conducting a security review to ensure that the validation logic robustly prevents unauthorized access and handles edge cases effectively.


82-86: Enhanced user-specific notification deletion.

The changes to deleteAllNotifications to delete notifications specific to the user and return the count of deleted notifications enhance the operation's relevance and user feedback. Ensure that the deletion process is secure and accurately affects only the intended user's notifications.

Consider verifying the deletion process to ensure it securely and accurately deletes only the intended notifications without affecting other users' data.


101-105: Crucial validation logic for user-specific notifications.

The introduction of validateMyNotification is essential for ensuring that notifications accessed are indeed associated with the current user, enhancing data security and integrity. Ensure that this method is thoroughly tested to confirm its accuracy in identifying user-specific notifications and handling potential exceptions.

Consider testing the validateMyNotification method in various scenarios to ensure it accurately identifies notifications belonging to the user and handles exceptions appropriately.

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

2-5: Approved: User table entries addition.

The addition of new users with IDs 2 and 3 is consistent with the PR's objectives and enhances the database's user diversity.


145-147: Approved: Comment table user ID updates.

The updates to user IDs in the comment table are necessary to maintain relational integrity with the new user data.


138-140: Approved with verification needed: Product ownership updates.

The changes in product ownership and the addition of a new product are noted. Verify that these changes align with user interaction requirements and that all related functionalities are updated accordingly.

Run the following script to verify the product ownership updates:

Verification successful

Verification successful: Product ownership updates are correct.

The product ownership updates in the product table are verified, and the changes align with the intended updates. No issues were found with the user IDs associated with the products.

  • Products have different user IDs, indicating intentional ownership updates.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify product ownership updates.

# Test: Search for product ownership updates. Expect: Only occurrences of the new ownership.
rg --type sql -A 5 $'INSERT INTO product'

Length of output: 824

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

58-65: Approved: Method to retrieve current user's products.

The implementation of getMyProducts efficiently retrieves the current user's products using pagination and is well-aligned with the PR's objectives.


67-74: Approved: Method to retrieve specified user's products.

The implementation of getUserProducts efficiently retrieves a specified user's products using pagination and ensures data integrity and security.


76-83: Approved: Method to retrieve current user's liked products.

The implementation of getMyLikes correctly retrieves the current user's liked products, enhancing user experience and security.


85-90: Approved: Method to retrieve current user's following list.

The implementation of getMyFollowing efficiently retrieves the list of users the current user is following, which is crucial for social features in the application.


92-97: Approved: Method to handle user follow requests.

The implementation of followUser uses validation and service layer operations to securely and efficiently handle user follow requests.


99-102: Approved: Method to handle user unfollow requests.

The implementation of cancelUserFollow efficiently handles user unfollow requests, ensuring that the operation is secure and aligns with user expectations.


106-107: Approved: Method to update current user's information.

The implementation of updateMe uses validation and service layer operations to securely and efficiently update the current user's information.

src/test/java/taco/klkl/domain/notification/controller/NotificationControllerTest.java (1)

57-57: Approved: Enhanced flexibility in user initialization for tests.

The change to initialize the user variable using User.of() enhances the flexibility of the test setup, allowing for dynamic specification of user attributes.

src/main/java/taco/klkl/domain/product/controller/ProductController.java (5)

99-105: Approved HTTP status and parameter immutability.

The addition of @ResponseStatus(HttpStatus.CREATED) is appropriate for the createProduct method, clearly indicating the expected response status on success. The finalization of the createRequest parameter enhances code safety by preventing modifications.


112-113: Approved parameter immutability in update operation.

Making parameters productId and updateRequest final in the updateProduct method is a good practice, ensuring that they are not inadvertently modified within the method.


121-121: Approved parameter immutability in delete operation.

The finalization of the productId parameter in the deleteProduct method is a good practice, ensuring that it remains unchanged throughout the method execution.


46-52: Approved changes with a suggestion to verify integration.

The changes to the return type and parameter immutability in findProductsByFilteringAndSorting are approved. However, ensure that these changes are well integrated with the front-end and other dependent services, especially the new pagination structure.


68-72: Approved changes with a consistency check suggestion.

The updates to findProductsByPartialNameAndSorting are consistent with other pagination-related changes. Ensure that all similar functions across the application have been updated to maintain consistency.

Verification successful

Consistent Pagination Handling Verified

The new pagination type PagedResponse<ProductSimpleResponse> is consistently used across various functions in the codebase, confirming the successful transition from the old pagination type. This ensures uniformity in pagination handling across the application.

  • Verified in UserServiceImpl, UserController, ProductServiceImpl, and ProductController.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check consistency of pagination handling across similar functions.

# Test: Search for similar functions with old pagination type. Expect: No occurrences.
rg --type java -A 5 $'PagedResponseDto'

Length of output: 38


Script:

#!/bin/bash
# Description: Check for consistent use of the new pagination type across similar functions.

# Test: Search for occurrences of the new pagination type. Expect: Consistent usage across similar functions.
rg --type java -A 5 $'PagedResponse<ProductSimpleResponse>'

Length of output: 13737

src/test/java/taco/klkl/domain/notification/service/NotificationServiceTest.java (5)

Line range hint 1-1: Approved changes in the setUp method.

The simplification of the User.of method aligns with the PR's objectives and is correctly implemented here.


127-127: Approved changes in testFindAllNotifications.

The use of userUtil.getCurrentUser() aligns with the new focus on the currently authenticated user, enhancing the test's relevance.


157-157: Approved changes in testGetBlankNotifications.

The consistent use of userUtil.getCurrentUser() across tests ensures uniformity and relevance.


201-202: Approved changes in testReadNotificationsById.

Using a specific ID (1L) instead of a dynamic one enhances the predictability and reliability of the test.

Also applies to: 209-210


181-182: Approved changes in testReadAllNotifications, verify performance.

The replacement of findAllByComment_Product_User() with findByComment_Product_User() is likely more efficient. However, ensure to verify the performance impact of this change.

Run the following script to verify the performance impact:

Also applies to: 189-190

src/main/java/taco/klkl/domain/product/service/ProductServiceImpl.java (5)

367-372: Approved: New method for product ownership validation.

The method validateMyProduct enhances security by ensuring that only the product owner can update or delete a product. The implementation is straightforward and correctly throws ProductNotFoundException if the current user is not the owner.


320-325: Approved: Utility method for creating sorted pageable objects.

The method createPageableSortedByCreatedAtDesc is a useful utility for creating pageable objects with a consistent sorting order (creation date in descending). The implementation is concise and correctly utilizes the PageRequest.of method from the Spring framework.


174-174: Approved: Security enhancement in product update method.

The inclusion of validateMyProduct in the updateProduct method is a crucial security enhancement, ensuring that only the product owner can make updates. The overall update process appears to be comprehensive.

Run the following script to verify the complete update process and integration with other parts of the application:

Verification successful

Verified: Comprehensive integration and testing of updateProduct method.

The updateProduct method is well-integrated within the application, with its usage in the ProductController and thorough testing in both ProductServiceImplTest and ProductControllerTest. The inclusion of validateMyProduct enhances security, and the existing tests ensure the method's functionality is verified.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the complete update process and its integration.

# Test: Search for method usage and related integration points. Expect: Correct integration and usage patterns.
rg --type java -A 5 $'updateProduct'

Length of output: 6393


Line range hint 78-91: Approved: Updated response type and method logic.

The method findProductsByFilterOptionsAndSortOptions has been correctly updated to return PagedResponse instead of PagedResponseDto. The logic for fetching products and creating the paginated response is well-implemented.

Run the following script to verify the integration with other parts of the application:

Verification successful

Verification Successful: Integration of Updated Method Confirmed

The method findProductsByFilterOptionsAndSortOptions has been successfully integrated with other parts of the application. The updated return type PagedResponse<ProductSimpleResponse> is consistently used across the service interface, controller, and test files.

  • ProductController.java: Method is called with the updated return type.
  • ProductService.java: Method is declared with the updated return type.
  • ProductServiceImplTest.java: Method is tested with assertions on the return value.
  • ProductControllerTest.java: Method is mocked and verified.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the updated method with other parts of the application.

# Test: Search for method usage. Expect: Only occurrences of the new return type.
rg --type java -A 5 $'findProductsByFilterOptionsAndSortOptions'

Length of output: 4072


123-134: Approved: New method for fetching followed users' products.

The method findMyFollowingProducts is a valuable addition for the "My Page" feature, allowing users to see products from those they follow. The use of a custom pageable object sorted by creation date is appropriate and well-implemented.

Run the following script to verify the integration of this new method with the user interface and other parts of the application:

Verification successful

Integration Verified: Method findMyFollowingProducts is properly integrated.

The method findMyFollowingProducts is well-integrated into the application. It is declared in the ProductService interface, implemented in ProductServiceImpl, and used in ProductController, confirming its accessibility through the API layer.

  • ProductService.java: Declaration of findMyFollowingProducts.
  • ProductServiceImpl.java: Implementation of findMyFollowingProducts.
  • ProductController.java: Usage of findMyFollowingProducts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the new method with the user interface and other parts of the application.

# Test: Search for method usage. Expect: Integration points in the user interface and other services.
rg --type java -A 5 $'findMyFollowingProducts'

Length of output: 2091

src/test/java/taco/klkl/domain/product/integration/ProductIntegrationTest.java (3)

1061-1064: Updated sorting logic in test needs review.

The testSortProductsByLikeCountDesc method now includes "ν•˜μ˜€ν•˜μ˜€ 봉지라면 핑크색" as the first product name, followed by previously expected products. This change indicates a modification in the sorting logic to prioritize this product.

  • Ensure that the new sorting behavior is intentional and aligns with the updated business rules or user preferences.
  • Verify that the product "ν•˜μ˜€ν•˜μ˜€ 봉지라면 핑크색" should indeed be the top result based on like counts, suggesting a possible update in the product's popularity or testing data.

495-501: Updated test assertions need verification.

The changes in the testGetProductsBySingleSubcategoryId method increase the expected size of the product content array from 2 to 3 and update the expected product names. This suggests a change in the underlying data or API behavior.

  • Ensure that the increase in the expected number of products is intentional and correctly reflects the new business requirements or data models.
  • Verify that the hardcoded product name "ν•˜μ˜€ν•˜μ˜€ 봉지라면 핑크색" is expected to be the first product consistently, which might indicate a change in sorting or prioritization logic in the API.

568-575: Adjustments in test assertions reflect API changes.

The testGetProductsByMultipleSubcategoryIds method now expects an increased size of the product content array from 3 to 4, and the first product's name is set to "ν•˜μ˜€ν•˜μ˜€ 봉지라면 핑크색". This adjustment likely reflects changes in the API's logic for handling multiple subcategories.

  • Confirm that the API now includes additional products in its response when multiple subcategories are specified.
  • Check if the hardcoded product name "ν•˜μ˜€ν•˜μ˜€ 봉지라면 핑크색" as the first item is part of a new sorting or filtering feature.
Verification successful

Review Comment Verified: Test Adjustments Reflect API Changes

The testGetProductsByMultipleSubcategoryIds method indeed reflects changes in the API logic for handling multiple subcategories. The test setup and assertions confirm that the API now returns an increased number of products, including a specific product name "ν•˜μ˜€ν•˜μ˜€ 봉지라면 핑크색" as the first item, indicating potential changes in sorting or filtering logic.

  • The test expects a list size of 4 products, confirming the inclusion of additional products in the response.
  • The specific ordering of products suggests a new sorting or filtering feature.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency and correctness of the product list when multiple subcategories are specified.

# Test: Search for the test method and check for consistent handling of multiple subcategories.
rg --type java -A 5 $'testGetProductsByMultipleSubcategoryIds' src/test/java/taco/klkl/domain/product/integration/ProductIntegrationTest.java

Length of output: 354


Script:

#!/bin/bash
# Search for the complete implementation of the testGetProductsByMultipleSubcategoryIds method.
ast-grep --lang java --pattern $'public void testGetProductsByMultipleSubcategoryIds() {
  $$$
}' src/test/java/taco/klkl/domain/product/integration/ProductIntegrationTest.java

Length of output: 177


Script:

#!/bin/bash
# Search for changes in the API code that might affect the response when multiple subcategories are specified.
rg 'multiple subcategories' -A 10

Length of output: 35


Script:

#!/bin/bash
# Search for the complete implementation of the testGetProductsByMultipleSubcategoryIds method directly in the file.
rg 'public void testGetProductsByMultipleSubcategoryIds' -A 50 src/test/java/taco/klkl/domain/product/integration/ProductIntegrationTest.java

Length of output: 1183


Script:

#!/bin/bash
# Search for keywords related to product retrieval or subcategory handling in the API code.
rg 'getProducts|subcategory' -A 10

Length of output: 312721

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

53-57: Well-implemented user retrieval method.

The method getUserById correctly retrieves a user by ID and uses effective exception handling with UserNotFoundException. This ensures robust error handling and clear feedback when the user is not found.


60-66: Effective use of pagination and utility methods.

The method getUserProductsById efficiently handles data retrieval with pagination and sorting, which is crucial for performance. The use of utility methods for sorting (createPageableSortedByCreatedAtDesc) and fetching products (findProductsByUserId) enhances code maintainability and reusability.


69-75: Efficient handling of user likes and product mapping.

The method getUserLikesById effectively retrieves user likes and associated products with pagination. The functional approach using map to transform likes into product responses is clean and efficient, promoting good coding practices.


79-85: Clear and concise implementation for fetching user followings.

The method getUserFollowingById effectively lists users that a specified user is following. It uses Java streams efficiently to transform follow relationships into the desired response format, demonstrating good use of modern Java features.


97-107: Robust implementation of user follow functionality.

The method createUserFollow effectively manages user follow relationships, including checks for duplicates to prevent redundant data. The use of @Transactional ensures that the operation is handled atomically, enhancing data integrity and consistency.


111-118: Effective management of user unfollow functionality.

The method removeUserFollow correctly manages the removal of user follow relationships, including necessary checks to ensure the relationship exists before attempting removal. The use of @Transactional ensures that the operation is handled atomically, maintaining data integrity.


149-154: Well-designed utility method for pagination and sorting.

The method createPageableSortedByCreatedAtDesc provides a standardized way to handle pagination and sorting by the createdAt field across various service methods. This promotes reusability and consistency, which are beneficial for maintaining clean and manageable code.


157-159: Effective utility method for checking follow relationships.

The method isFollowPresent efficiently checks for the existence of follow relationships between users, aiding in the prevention of duplicates. Its implementation enhances modularity and reusability, which are key aspects of maintainable code.

src/test/java/taco/klkl/domain/comment/integration/CommentIntegrationTest.java (1)

38-38: Verify the changes to product IDs in test scenarios.

The changes to productId and differentProductId need verification to ensure they align with the intended test scenarios. Please confirm that these changes are intentional and correctly reflect the test requirements.

Also applies to: 145-145, 204-204

Verification successful

Verification of product ID changes in test scenarios is successful.

The changes to productId and differentProductId in CommentIntegrationTest.java are consistent with the test scenarios. The new IDs are used in various test methods to simulate different conditions, indicating that the changes are intentional and align with the test requirements. No issues were found with the new IDs in the context of the integration tests.

  • productId is set to 101L.
  • differentProductId is set to 102L.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `productId` and `differentProductId` in test scenarios.

# Test: Search for the usage of `productId` and `differentProductId`. Expect: Only occurrences that match the new IDs.
rg --type java -A 5 $'productId|differentProductId'

Length of output: 84040

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

41-41: Verify the consistency of the response type change across the application.

The change from PagedResponseDto to PagedResponse in the import statement and test methods suggests a refactoring in the response handling mechanism. Please ensure that this change is consistently applied across the application and correctly implemented in all relevant parts.

Also applies to: 135-135, 203-203

Verification successful

Refactoring from PagedResponseDto to PagedResponse is consistent across the application.

The change from PagedResponseDto to PagedResponse has been successfully applied throughout the codebase. The usage of PagedResponse is consistent across various components, including controllers, services, and tests, with no remaining occurrences of PagedResponseDto. This indicates a thorough and complete refactoring.

  • PagedResponse is used in service interfaces and implementations.
  • PagedResponse is used in controller methods.
  • PagedResponse is used in test classes.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `PagedResponse` across the application.

# Test: Search for the usage of `PagedResponse` and `PagedResponseDto`. Expect: Only occurrences of `PagedResponse`.
rg --type java -A 5 $'PagedResponse|PagedResponseDto'

Length of output: 22188

src/test/java/taco/klkl/domain/product/service/ProductServiceImplTest.java (1)

65-65: Verify the changes to imports, test setup, and assertions in product service tests.

The changes to imports, test setup, and assertions suggest a significant update to the test structure, focusing on improved response handling and more realistic user scenarios. Please ensure that these changes are intentional and correctly reflect the intended functionalities.

Also applies to: 111-111, 215-215, 296-296, 378-378

Verification successful

Changes to imports, test setup, and assertions are consistent and intentional.

The updates to use PagedResponse, getCurrentUser, and User.of are consistent across the codebase, indicating a deliberate refactoring to improve response handling and user interaction simulation. These changes align with the intended functionalities and enhance code maintainability and test realism.

  • PagedResponse is integrated into response handling across services and controllers.
  • getCurrentUser is used for dynamic user retrieval in various services and tests.
  • User.of standardizes user initialization in both main and test classes.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `PagedResponse`, `getCurrentUser`, and updated user initialization in product service tests.

# Test: Search for the usage of `PagedResponse`, `getCurrentUser`, and user initialization. Expect: Only occurrences that match the new implementations.
rg --type java -A 5 $'PagedResponse|getCurrentUser|User.of'

Length of output: 48785

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

83-83: Verify the integration of the new user retrieval method in image upload completion.

The change from userUtil.findCurrentUser() to userUtil.getCurrentUser() in uploadCompleteUserImage suggests a shift in user retrieval logic. Ensure that the new method integrates well with the existing system and does not introduce any regressions, especially in the context of expiring old images and updating the user image.

Verification successful

Verified: The integration of the new user retrieval method is consistent and correct.

The change from findCurrentUser() to getCurrentUser() in uploadCompleteUserImage does not affect the functionality, as both methods ultimately call userUtil.getCurrentUser(). This refactoring step maintains the existing logic for expiring old images and updating the user image without introducing regressions.

Scripts executed

The following scripts were executed for the analysis:

Script:

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

# Test: Search for the method implementation and its usage. Expect: Correct implementation and usage.
rg --type java -A 5 $'getCurrentUser'

Length of output: 20828


Script:

#!/bin/bash
# Description: Search for the implementation of `findCurrentUser()` to compare with `getCurrentUser()`.

# Test: Search for the method implementation. Expect: Find the implementation details.
rg --type java -A 5 $'findCurrentUser'

Length of output: 1808

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

103-103: Verify the integration of the new user retrieval method in tests.

The change from findTestUser() to getCurrentUser() in CommentServiceTest suggests a shift in user retrieval logic. Ensure that the new method integrates well with the existing test setup and does not introduce any regressions.

Verification successful

Verification successful: The getCurrentUser() method is correctly integrated and tested.

The getCurrentUser() method in UserUtil.java is implemented to return a test user, and its usage in CommentServiceTest.java is appropriately mocked. This change is consistent with the existing logic and does not introduce any regressions. The method is widely used across the codebase, indicating its reliability and integration.

  • UserUtil.java: Implementation of getCurrentUser().
  • CommentServiceTest.java: Mocking of getCurrentUser() for testing.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `getCurrentUser()` and its usage in the test setup.

# Test: Search for the method implementation and its usage. Expect: Correct implementation and usage.
rg --type java -A 5 $'getCurrentUser'

Length of output: 20828

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.

νŒ”λ‘œμš° κΈ°λŠ₯κ³Ό μœ μ € APIκΉŒμ§€ λͺ¨λ‘ ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€! κ³ μƒν•˜μ…¨μŠ΅λ‹ˆλ‹€! :) πŸ‘

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.

μœ μ € κ΄€λ ¨ api κ΅¬ν˜„ ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€! 컀밋을 ν•˜λ‚˜ν•˜λ‚˜ 깊게 λͺ» 듀여닀보고 κ°„λ‹¨νžˆ 컀멘트 λ“œλ € μ£„μ†‘ν•˜λ„€μš”... 거의 끝을 ν–₯ν•΄ 달렀가고 μžˆλŠ”κ±° κ°™κ΅°μš”! 쑰금만 더 κ³ μƒν•˜μ‹œκ³  ν™”μ΄νŒ…μž…λ‹ˆλ‹€~

@ohhamma ohhamma merged commit 398ee9e into develop Sep 10, 2024
2 checks passed
@ohhamma ohhamma deleted the KL-166/μœ μ €-api-κ΅¬ν˜„ branch September 10, 2024 02:44
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