Conversation
WalkthroughThis update refactors the handling of record identifiers across the running record and rewards modules, shifting from internal numeric IDs to public UUID-based string IDs throughout the API, DTOs, services, and tests. It updates method signatures, request/response objects, and validation annotations to consistently use public IDs. The update also modifies the record update process to accept and propagate the public ID, adjusts domain logic to support new update methods, and enhances API documentation with OpenAPI schema annotations. Corresponding changes are made to acceptance and service tests to reflect the new identifier type and update workflows. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant RecordController
participant RecordCommandService
participant RunningRecord
Client->>RecordController: PATCH /records/{recordId} (RecordUpdateRequest)
RecordController->>RecordCommandService: updateRecord(editorId, recordPublicId, request)
RecordCommandService->>RunningRecord: updateTitle(editorId, title)
RecordCommandService->>RunningRecord: updateDescription(editorId, description)
RecordCommandService->>RunningRecord: updateImageUrl(editorId, imgUrl)
RecordCommandService-->>RecordController: void
RecordController-->>Client: 200 OK
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (16)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (15)
🪧 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
src/main/java/org/runimo/runimo/records/service/usecases/dtos/RecordDetailViewResponse.java (1)
31-41: 🛠️ Refactor suggestion
⚠️ Potential issue
imgUrlis never populated – DTO returnsnullto the clientThe
from()factory sets every field exceptimgUrl, so the API will always respond withimgUrl = nulleven when the underlying entity holds a value. This is an easy thing to miss because the build still succeeds – Lombok’s@Builderjust leaves the field unset..segmentPaceList(runningRecord.getPacePerKm()) + .imgUrl(runningRecord.getImgUrl()) // ← missing mapping .build();Please map the value (or drop the field entirely if it is no longer required) to keep the contract with clients consistent.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (14)
src/main/java/org/runimo/runimo/records/controller/RecordController.java(2 hunks)src/main/java/org/runimo/runimo/records/controller/request/RecordUpdateRequest.java(1 hunks)src/main/java/org/runimo/runimo/records/domain/RunningRecord.java(3 hunks)src/main/java/org/runimo/runimo/records/service/RecordCommandService.java(1 hunks)src/main/java/org/runimo/runimo/records/service/usecases/RecordCreateUsecaseImpl.java(1 hunks)src/main/java/org/runimo/runimo/records/service/usecases/dtos/RecordDetailViewResponse.java(1 hunks)src/main/java/org/runimo/runimo/records/service/usecases/dtos/RecordSaveResponse.java(1 hunks)src/main/java/org/runimo/runimo/records/service/usecases/dtos/RecordUpdateCommand.java(1 hunks)src/main/java/org/runimo/runimo/rewards/controller/request/RewardClaimRequest.java(1 hunks)src/main/java/org/runimo/runimo/rewards/service/RewardService.java(2 hunks)src/main/java/org/runimo/runimo/rewards/service/dto/RewardClaimCommand.java(1 hunks)src/test/java/org/runimo/runimo/records/api/RecordAcceptanceTest.java(4 hunks)src/test/java/org/runimo/runimo/rewards/api/RewardAcceptanceTest.java(6 hunks)src/test/java/org/runimo/runimo/rewards/service/RewardServiceTest.java(5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
src/main/java/org/runimo/runimo/rewards/controller/request/RewardClaimRequest.java (1)
src/main/java/org/runimo/runimo/records/service/dto/RecordSimpleView.java (1)
Schema(11-45)
src/main/java/org/runimo/runimo/records/service/usecases/dtos/RecordSaveResponse.java (1)
src/main/java/org/runimo/runimo/records/service/dto/RecordSimpleView.java (1)
Schema(11-45)
src/main/java/org/runimo/runimo/records/service/usecases/dtos/RecordDetailViewResponse.java (1)
src/main/java/org/runimo/runimo/records/service/dto/RecordSimpleView.java (1)
Schema(11-45)
src/main/java/org/runimo/runimo/records/controller/request/RecordUpdateRequest.java (1)
src/main/java/org/runimo/runimo/records/service/dto/RecordSimpleView.java (1)
Schema(11-45)
🔇 Additional comments (30)
src/main/java/org/runimo/runimo/rewards/service/dto/RewardClaimCommand.java (1)
5-5: Field type and name updated to use public ID instead of record IDThe field has been correctly updated from
Long recordIdtoString recordPublicId, aligning with the PR objective of using public IDs in entity logic. This change ensures consistency with the broader refactoring across the codebase.src/main/java/org/runimo/runimo/rewards/controller/request/RewardClaimRequest.java (1)
7-7: Updated field type and schema documentationThe type change from
LongtoStringforrecordIdis appropriate and matches the PR objective. The schema example has been correctly updated to reflect the new UUID-based identification scheme. This ensures proper API documentation and client usage.src/test/java/org/runimo/runimo/rewards/api/RewardAcceptanceTest.java (6)
73-76: Updated ID extraction and request creation to use StringThe code now correctly extracts the record ID as a String instead of an Integer, and directly passes it to the RewardClaimRequest constructor without type conversion. This aligns with the new public ID implementation.
105-108: Consistent ID handling in multiple test casesThe same pattern of String extraction and direct usage is applied here, maintaining consistency across test cases.
155-155: String ID extraction in edge case testThe extraction of the record ID as a String is correctly implemented in this edge case test.
177-177: Updated RewardClaimRequest creation with String IDThe RewardClaimRequest constructor is now correctly called with a String parameter.
210-213: Consistent String ID handling in reward point testThis test case also correctly implements the extraction and usage of the String ID.
250-253: Refactored ID handling in edge case test for minimal distanceThe extraction of record ID as a String and its usage in the RewardClaimRequest is consistently implemented in this test case as well.
src/main/java/org/runimo/runimo/records/service/usecases/dtos/RecordSaveResponse.java (1)
3-9: Added OpenAPI schema annotations and updated type to StringThese changes accomplish two important goals:
- The type change from
LongtoStringforsavedIdaligns with the public ID refactoring- The addition of OpenAPI schema annotations improves API documentation
The updated example value "UUID-String" clearly communicates the expected format to API consumers.
src/test/java/org/runimo/runimo/rewards/service/RewardServiceTest.java (8)
16-16: Added necessary UUID import for new implementation.This import addition is correct to support using UUID string identifiers for records.
54-55: Properly setting recordPublicId in test fixture.The test fixture now correctly sets a random UUID string for the
recordPublicIdfield, which aligns with the new approach of using public IDs for record identification.
71-71: Correctly updated RewardClaimCommand to use recordPublicId.The command object initialization has been properly updated to use the public ID string from the running record instead of the numeric ID.
73-73: Updated mock to use findByPublicId instead of findById.This correctly reflects the change in the service implementation to look up records by their public ID rather than internal ID.
88-89: Command creation properly uses record's public ID.The command object is correctly initialized with the public ID from the record rather than its internal ID.
91-91: Mock setup correctly uses findByPublicId.The mock is properly configured to respond to the new repository method for finding records by public ID.
105-105: Command now uses public ID in test for non-first-record scenario.The test correctly uses the record's public ID when constructing the command for the non-first-record scenario.
107-107: Mock setup consistent with service implementation changes.The mock configuration is properly updated to reflect the service's use of
findByPublicIdinstead offindById.src/main/java/org/runimo/runimo/rewards/service/RewardService.java (2)
32-32: Service now retrieves records by public ID.The service implementation has been correctly updated to retrieve records using their public ID instead of internal ID, which aligns with the API's changes to use public identifiers.
64-64: Updated record comparison to use public IDs.The validation method now correctly compares the record public IDs instead of internal IDs, ensuring consistent handling of record identifiers throughout the service layer.
src/main/java/org/runimo/runimo/records/service/usecases/RecordCreateUsecaseImpl.java (1)
36-36: Return response initialized with record's public ID.The implementation now correctly returns a
RecordSaveResponseinitialized with the public ID from the saved record. This change aligns with the broader refactoring to use public IDs as primary external identifiers.src/test/java/org/runimo/runimo/records/api/RecordAcceptanceTest.java (4)
8-8: Added import for JSON exception handling.This import is needed to support the new test for record updates that uses JSON serialization.
20-20: Added import for RecordUpdateRequest.This import is necessary for the new test that verifies record update functionality.
134-134: Updated assertion to check for non-null record ID.The test now correctly verifies that the returned record ID is not null, rather than assuming it's a numeric value. This aligns with the change to use string-based public IDs.
287-322: Added comprehensive tests for pagination error handling and record updates.These tests are valuable additions that validate:
- Error handling for invalid pagination parameters
- The record update functionality using public IDs in the request path
These tests help ensure the robustness of the API changes and provide coverage for the new update endpoint functionality.
src/main/java/org/runimo/runimo/records/service/usecases/dtos/RecordUpdateCommand.java (1)
3-14: LGTM - Appropriate validations for required fieldsThe changes correctly implement validation constraints on required fields while keeping description and imgUrl optional. This aligns well with the PR objective of transitioning to public IDs.
src/main/java/org/runimo/runimo/records/service/RecordCommandService.java (2)
19-21: Return type change improves code flowReturning the RunningRecord entity directly from the repository save operation simplifies the code and provides more flexibility for callers.
29-33: Explicit field updates improve clarity and maintainabilityThe explicit calls to field-specific update methods (updateTitle, updateDescription, updateImageUrl) make the code more readable and clearly define the permitted update operations. This aligns well with the PR objective of restricting updates to only title, description, and img_url fields.
src/main/java/org/runimo/runimo/records/controller/RecordController.java (2)
9-9: Proper validation for path variableThe @NotNull annotation appropriately ensures that the recordId path variable is provided in requests.
Also applies to: 94-94
97-97: Successfully integrated public ID into update flowThe controller now correctly passes the string-based public ID to the command builder, aligning with the PR objective of using public_id in the API.
src/main/java/org/runimo/runimo/records/controller/request/RecordUpdateRequest.java (1)
11-14: Schema annotations added correctly for new fieldsThe new fields description and imgUrl are properly documented with appropriate Swagger annotations.
e7da1d5 to
c8844fe
Compare
작업내역
API 변경
public_id를 클라이언트에서 사용하도록 api-spec을 변경했습니다.PATCH /api/v1/records/{id}에서 title, description 외의 정보들도 수정하던 로직을 수정했습니다.title,description,img_url만 수정합니다.엔티티 수정
RunningRecord엔티티에서public_id를 생성자에서 직접할당하던 로직을 수정했습니다.@PrePersist를 활용하여 영속성 컨텍스트에 등록될때, 세팅됩니다.엔티티에
description,img_url필드가 빠져있어 추가했습니다.테스트코드를 수정했습니다.
/api/v1/records/**/api/v1/rewards/runningsSummary by CodeRabbit
New Features
Improvements
Bug Fixes
Tests