-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(KL-130): change Product update http method #34
The head ref may contain hidden characters: "KL-130/\uC0C1\uD488-\uC815\uBCF4-\uC218\uC815-\uB85C\uC9C1-\uBCC0\uACBD"
refactor(KL-130): change Product update http method #34
Conversation
- μν μ 보 μμ μ patch λμ put λ©μλ μ¬μ© - μμ² dtoλ₯Ό ProductCreateUpdateRequestDtoλ‘ ν΅μΌ - μν νλμ nullable, optional λͺ μμ μΌλ‘ μΆκ° - μν serviceμμ λ°ννλ μμΈ λͺ μμ μΌλ‘ μμ±
- μν pk νλ productIdμμ idλ‘ μμ
WalkthroughThe recent changes streamline the product management functionality within the application by consolidating the data transfer objects for product creation and updates into a single Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ProductController
participant ProductService
participant ProductRepository
Client->>ProductController: Create/Update Product Request
ProductController->>ProductService: createProduct(createRequest)
ProductService->>ProductRepository: save(product)
ProductRepository-->>ProductService: Product saved
ProductService-->>ProductController: Return Product Detail
ProductController-->>Client: Return Response
Assessment against linked issues
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
@coderabbitai review |
Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
src/main/java/taco/klkl/domain/product/dto/request/ProductCreateUpdateRequestDto.java (1)
21-21
: Update method name for consistencyThe method name
testValidProductCreateRequestDto
inProductCreateUpdateRequestDtoTest.java
should be updated totestValidProductCreateUpdateRequestDto
for consistency with the new record name.
src/test/java/taco/klkl/domain/product/dto/request/ProductCreateUpdateRequestDtoTest.java
: Update method nametestValidProductCreateRequestDto
totestValidProductCreateUpdateRequestDto
.Analysis chain
LGTM! Ensure consistency across the codebase.
The change from
ProductCreateRequestDto
toProductCreateUpdateRequestDto
is approved.Verify that all instances of
ProductCreateRequestDto
have been updated toProductCreateUpdateRequestDto
across the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all instances of `ProductCreateRequestDto` have been updated to `ProductCreateUpdateRequestDto`. # Test: Search for the old record name usage. Expect: No occurrences of `ProductCreateRequestDto`. rg --type java 'ProductCreateRequestDto'Length of output: 173
Script:
#!/bin/bash # Description: Check the context of the occurrence of `ProductCreateRequestDto` in the test file. # Search for the old record name usage with context lines to understand its usage. rg --type java 'ProductCreateRequestDto' -A 5 -B 5Length of output: 1359
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (13)
- src/main/java/taco/klkl/domain/product/controller/ProductController.java (3 hunks)
- src/main/java/taco/klkl/domain/product/domain/Product.java (3 hunks)
- src/main/java/taco/klkl/domain/product/dto/request/ProductCreateUpdateRequestDto.java (1 hunks)
- src/main/java/taco/klkl/domain/product/dto/response/ProductDetailResponseDto.java (1 hunks)
- src/main/java/taco/klkl/domain/product/dto/response/ProductSimpleResponseDto.java (1 hunks)
- src/main/java/taco/klkl/domain/product/service/ProductService.java (3 hunks)
- src/test/java/taco/klkl/domain/product/controller/ProductControllerTest.java (8 hunks)
- src/test/java/taco/klkl/domain/product/domain/ProductTest.java (1 hunks)
- src/test/java/taco/klkl/domain/product/dto/request/ProductCreateUpdateRequestDtoTest.java (27 hunks)
- src/test/java/taco/klkl/domain/product/dto/response/ProductDetailResponseDtoTest.java (1 hunks)
- src/test/java/taco/klkl/domain/product/dto/response/ProductSimpleResponseDtoTest.java (1 hunks)
- src/test/java/taco/klkl/domain/product/integration/ProductIntegrationTest.java (12 hunks)
- src/test/java/taco/klkl/domain/product/service/ProductServiceTest.java (8 hunks)
Files skipped from review due to trivial changes (1)
- src/test/java/taco/klkl/domain/product/domain/ProductTest.java
Additional comments not posted (53)
src/main/java/taco/klkl/domain/product/dto/response/ProductSimpleResponseDto.java (1)
24-24
: LGTM! Ensure consistency across the codebase.The change from
product.getProductId()
toproduct.getId()
is approved.Verify that all instances of
product.getProductId()
have been updated toproduct.getId()
across the codebase.Verification successful
Verification successful.
The update from
product.getProductId()
toproduct.getId()
has been consistently applied across the codebase.
- Instances of
product.getId()
found in:
src/test/java/taco/klkl/domain/product/dto/response/ProductDetailResponseDtoTest.java
src/main/java/taco/klkl/domain/product/dto/response/ProductSimpleResponseDto.java
src/main/java/taco/klkl/domain/product/dto/response/ProductDetailResponseDto.java
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all instances of `product.getProductId()` have been updated to `product.getId()`. # Test: Search for the old method usage. Expect: No occurrences of `product.getProductId()`. rg --type java 'product.getProductId()'Length of output: 41
Script:
#!/bin/bash # Description: Verify all instances of `product.getProductId()` have been updated to `product.getId()`. # Search for the old method usage. Expect: No occurrences of `product.getProductId()`. rg --type java 'product.getProductId()' # Search for the new method usage to ensure it is being used correctly. rg --type java 'product.getId()'Length of output: 413
src/main/java/taco/klkl/domain/product/dto/response/ProductDetailResponseDto.java (1)
38-38
: LGTM! Ensure consistency across the codebase.The change from
product.getProductId()
toproduct.getId()
is approved.Verify that all instances of
product.getProductId()
have been updated toproduct.getId()
across the codebase.Verification successful
Verification successful.
The transition from
product.getProductId()
toproduct.getId()
has been consistently applied across the codebase.
src/test/java/taco/klkl/domain/product/dto/response/ProductDetailResponseDtoTest.java
src/main/java/taco/klkl/domain/product/dto/response/ProductSimpleResponseDto.java
src/main/java/taco/klkl/domain/product/dto/response/ProductDetailResponseDto.java
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all instances of `product.getProductId()` have been updated to `product.getId()`. # Test: Search for the old method usage. Expect: No occurrences of `product.getProductId()`. rg --type java 'product.getProductId()'Length of output: 41
Script:
#!/bin/bash # Description: Verify all instances of `product.getId()` to ensure the transition from `product.getProductId()` was made correctly. # Test: Search for the new method usage. Expect: Multiple occurrences of `product.getId()`. rg --type java 'product.getId()'Length of output: 371
src/test/java/taco/klkl/domain/product/dto/response/ProductSimpleResponseDtoTest.java (1)
25-25
: LGTM!The change from
getProductId()
togetId()
aligns with the refactoring of theProduct
class. The test logic remains correct.src/main/java/taco/klkl/domain/product/controller/ProductController.java (4)
13-13
: LGTM!The import of
PutMapping
is necessary for the updated HTTP method in the controller.
24-24
: LGTM!The import of
ProductCreateUpdateRequestDto
is necessary for the consolidated DTO used in the controller methods.
60-60
: LGTM!Updating the parameter type to
ProductCreateUpdateRequestDto
consolidates the request data structure, simplifying the code and improving maintainability.
65-65
: LGTM!Changing the HTTP method to
PUT
aligns with RESTful principles. Updating the parameter type toProductCreateUpdateRequestDto
consolidates the request data structure, simplifying the code and improving maintainability.Also applies to: 69-69
src/test/java/taco/klkl/domain/product/dto/response/ProductDetailResponseDtoTest.java (1)
35-35
: LGTM!The change from
getProductId()
togetId()
aligns with the refactoring of theProduct
class. The test logic remains correct.src/main/java/taco/klkl/domain/product/domain/Product.java (6)
35-35
: LGTM! Simplified identifier naming.The renaming of
productId
toid
simplifies the identifier naming convention.
37-41
: LGTM! Enforced non-null constraint for user association.The
@ManyToOne(optional = false)
and@JoinColumn(nullable = false)
annotations enforce that aProduct
cannot exist without a correspondingUser
, improving data integrity.
87-91
: LGTM! Enforced non-null constraint for city association.The
@ManyToOne(optional = false)
and@JoinColumn(nullable = false)
annotations enforce that aProduct
cannot exist without a correspondingCity
, improving data integrity.
94-98
: LGTM! Enforced non-null constraint for subcategory association.The
@ManyToOne(optional = false)
and@JoinColumn(nullable = false)
annotations enforce that aProduct
cannot exist without a correspondingSubcategory
, improving data integrity.
101-105
: LGTM! Enforced non-null constraint for currency association.The
@ManyToOne(optional = false)
and@JoinColumn(nullable = false)
annotations enforce that aProduct
cannot exist without a correspondingCurrency
, improving data integrity.
162-168
: LGTM! Simplified update method.The
update
method has been streamlined by removing conditional checks for null values and directly assigning parameters to fields, simplifying the method and reducing boilerplate code.src/main/java/taco/klkl/domain/product/service/ProductService.java (8)
47-47
: LGTM! Improved error handling in getProductById method.The
getProductById
method now explicitly declares that it can throw aProductNotFoundException
, improving error handling transparency.
54-55
: LGTM! Consolidated request DTOs in createProduct method.The
createProduct
method now usesProductCreateUpdateRequestDto
, reducing redundancy and simplifying the method signature.
61-65
: LGTM! Consolidated request DTOs and improved error handling in updateProduct method.The
updateProduct
method now usesProductCreateUpdateRequestDto
and explicitly declares that it can throw aProductNotFoundException
, improving error handling transparency.
76-92
: LGTM! Consolidated request DTOs in createProductEntity method.The
createProductEntity
method now usesProductCreateUpdateRequestDto
, reducing redundancy and simplifying the method signature.
94-108
: LGTM! Encapsulated update logic in updateProductEntity method.The
updateProductEntity
method encapsulates the logic for updating a product, enhancing code organization and readability.
110-111
: LGTM! Improved error handling in getCityEntity method.The
getCityEntity
method now explicitly declares that it can throw aCityNotFoundException
, improving robustness by enforcing error handling.
114-115
: LGTM! Improved error handling in getSubcategoryEntity method.The
getSubcategoryEntity
method now explicitly declares that it can throw aSubcategoryNotFoundException
, improving robustness by enforcing error handling.
118-119
: LGTM! Improved error handling in getCurrencyEntity method.The
getCurrencyEntity
method now explicitly declares that it can throw aCurrencyNotFoundException
, improving robustness by enforcing error handling.src/test/java/taco/klkl/domain/product/service/ProductServiceTest.java (7)
27-27
: LGTM! Consolidated request DTO imports.The import statements have been updated to use
ProductCreateUpdateRequestDto
, reducing redundancy.
27-27
: LGTM! Consolidated request DTO imports.The import statements have been updated to use
ProductCreateUpdateRequestDto
, reducing redundancy.
82-82
: LGTM! Updated mock product ID retrieval.The
setUp
method now retrieves the mock product's ID usinggetId()
instead ofgetProductId()
, reflecting the updated method signature of theProduct
class.
109-109
: LGTM! Updated assertion in testGetAllProducts method.The
testGetAllProducts
method now validates against the updated method signature, ensuring that the test remains valid and functional after the refactor.
124-124
: LGTM! Updated assertion in testGetProductById method.The
testGetProductById
method now validates against the updated method signature, ensuring that the test remains valid and functional after the refactor.
Line range hint
143-158
:
LGTM! Updated testCreateProduct method.The
testCreateProduct
method now usesProductCreateUpdateRequestDto
, streamlining the creation process and ensuring consistency in method calls.
Line range hint
179-201
:
LGTM! Updated testUpdateProduct method.The
testUpdateProduct
method now usesProductCreateUpdateRequestDto
, streamlining the update process and ensuring consistency in method calls.src/test/java/taco/klkl/domain/product/integration/ProductIntegrationTest.java (6)
19-19
: Import statement forProductCreateUpdateRequestDto
is correct.The import statement is necessary for the usage of the consolidated DTO in the tests.
Line range hint
42-51
: Correct usage ofProductCreateUpdateRequestDto
intestGetProductById
.The method correctly uses the consolidated DTO to create and retrieve a product.
Line range hint
75-100
: Correct usage ofProductCreateUpdateRequestDto
intestCreateProduct
.The method correctly uses the consolidated DTO to create a product.
Line range hint
108-137
: Correct usage ofProductCreateUpdateRequestDto
intestGetAllProducts
.The method correctly uses the consolidated DTO to create and retrieve multiple products.
Line range hint
145-167
: Correct usage ofProductCreateUpdateRequestDto
and HTTPPUT
intestUpdateProduct
.The method correctly uses the consolidated DTO and aligns with RESTful principles by using
PUT
for updates.
Line range hint
188-197
: Correct usage ofProductCreateUpdateRequestDto
intestDeleteProduct
.The method correctly uses the consolidated DTO to create and delete a product.
src/test/java/taco/klkl/domain/product/dto/request/ProductCreateUpdateRequestDtoTest.java (11)
20-20
: Class name update toProductCreateUpdateRequestDtoTest
is correct.The class name update is necessary to reflect the new DTO name.
Line range hint
31-43
: Correct update to testProductCreateUpdateRequestDto
intestValidProductCreateRequestDto
.The method correctly tests the validation of the consolidated DTO.
Line range hint
50-60
: Correct update to testProductCreateUpdateRequestDto
intestNullProductName
.The method correctly tests the validation of the consolidated DTO.
Line range hint
71-81
: Correct update to testProductCreateUpdateRequestDto
intestEmptyProductName
.The method correctly tests the validation of the consolidated DTO.
Line range hint
94-104
: Correct update to testProductCreateUpdateRequestDto
intestProductNameOverMaxLength
.The method correctly tests the validation of the consolidated DTO.
Line range hint
112-122
: Correct update to testProductCreateUpdateRequestDto
intestNullProductDescription
.The method correctly tests the validation of the consolidated DTO.
Line range hint
133-143
: Correct update to testProductCreateUpdateRequestDto
intestEmptyProductDescription
.The method correctly tests the validation of the consolidated DTO.
Line range hint
156-166
: Correct update to testProductCreateUpdateRequestDto
intestProductDescriptionOverMaxLength
.The method correctly tests the validation of the consolidated DTO.
Line range hint
174-184
: Correct update to testProductCreateUpdateRequestDto
intestNullAddress
.The method correctly tests the validation of the consolidated DTO.
Line range hint
195-205
: Correct update to testProductCreateUpdateRequestDto
intestEmptyAddress
.The method correctly tests the validation of the consolidated DTO.
Line range hint
214-224
: Correct update to testProductCreateUpdateRequestDto
intestAddressUnderMaxLength
.The method correctly tests the validation of the consolidated DTO.
src/test/java/taco/klkl/domain/product/controller/ProductControllerTest.java (7)
28-28
: Import statement forProductCreateUpdateRequestDto
is correct.The import statement is necessary for the usage of the consolidated DTO in the tests.
Line range hint
174-204
: Correct usage ofProductCreateUpdateRequestDto
intestCreateProduct
.The method correctly uses the consolidated DTO to create a product.
Line range hint
212-244
: Correct usage ofProductCreateUpdateRequestDto
and HTTPPUT
intestUpdateProduct
.The method correctly uses the consolidated DTO and aligns with RESTful principles by using
PUT
for updates.
Line range hint
48-48
: No changes related to DTO consolidation or HTTP method update.The method retrieves all products with default paging.
82-82
: No changes related to DTO consolidation or HTTP method update.The method retrieves all products with custom paging.
Line range hint
116-116
: No changes related to DTO consolidation or HTTP method update.The method retrieves a product by its ID.
Line range hint
251-251
: No changes related to DTO consolidation or HTTP method update.The method deletes a product by its ID.
9fe7c75
into
KL-71/μν-λͺ©λ‘-μ‘°ν-api-ꡬν
π μ°κ΄λ μ΄μ
π μμ λ΄μ©
PUT
μ μ¬μ©νλλ‘ μμ productId
μμid
λ‘ λ³κ²½π³ μμ λΈλμΉλͺ
KL-130/μν-μ 보-μμ -λ‘μ§-λ³κ²½
πΈ μ€ν¬λ¦°μ· (μ ν)
π¬ 리뷰 μꡬμ¬ν (μ ν)
Summary by CodeRabbit
New Features
ProductCreateUpdateRequestDto
.Bug Fixes
Tests