-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat/add-withdrawal-reason] - 회원 탈퇴 사유 추가 #109
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
Conversation
WalkthroughA user withdrawal reason feature was implemented. This includes new API DTOs and validation, a database table for storing withdrawal reasons, service and domain logic for handling reasons, and corresponding repository and migration scripts. Tests were added and updated to cover new validation rules and request structures. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant UserWithdrawController
participant WithdrawService
participant UserWithdrawReasonRepository
participant UserRepository
Client->>UserWithdrawController: DELETE /user/withdraw (with WithdrawRequest)
UserWithdrawController->>WithdrawService: withdraw(WithdrawCommand)
WithdrawService->>UserWithdrawReasonRepository: save(UserWithdrawReason)
WithdrawService->>UserRepository: delete user data
WithdrawService-->>UserWithdrawController: complete
UserWithdrawController-->>Client: 204 No Content
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds the ability for users to specify a withdrawal reason (including a custom “other” reason) by introducing DB tables, domain models, controller and service changes, plus acceptance tests.
- Create
user_withdrawal_reasontable in both main and test H2 migrations - Introduce
WithdrawalReasonenum,UserWithdrawReasonentity, repository, andWithdrawCommandDTO - Update controller, service, and tests to pass and validate the new reason fields
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/resources/db/migration/h2/V20250707__add_withdraw_reason.sql | Add test DB table for withdrawal reasons |
| src/main/resources/db/migration/V20250707__add_withdraw_reason.sql | Add production DB table for withdrawal reasons |
| src/main/java/org/runimo/runimo/user/service/dto/command/WithdrawCommand.java | Introduce WithdrawCommand record |
| src/main/java/org/runimo/runimo/user/service/WithdrawService.java | Persist withdrawal reason alongside user deletion |
| src/main/java/org/runimo/runimo/user/repository/UserWithdrawReasonRepository.java | Add JPA repository for withdrawal reasons |
| src/main/java/org/runimo/runimo/user/domain/WithdrawalReason.java | Define enum of possible withdrawal reasons |
| src/main/java/org/runimo/runimo/user/domain/UserWithdrawReason.java | Implement entity and business validation |
| src/main/java/org/runimo/runimo/user/controller/request/WithdrawRequest.java | Extend request DTO with reason fields and conversion |
| src/main/java/org/runimo/runimo/user/controller/UserWithdrawController.java | Accept and forward withdrawal reason in DELETE API |
| src/test/java/org/runimo/runimo/user/api/UserWithdrawAcceptanceTest.java | Add tests for valid/invalid withdrawal-reason flows |
Comments suppressed due to low confidence (3)
src/main/java/org/runimo/runimo/user/controller/request/WithdrawRequest.java:18
- The example value
FOUND_BETTER_SERVICEdoes not match anyWithdrawalReasonconstant. Update the example to a valid enum name.
@Schema(description = "탈퇴 이유", example = "FOUND_BETTER_SERVICE")
src/main/java/org/runimo/runimo/user/domain/UserWithdrawReason.java:45
- Throwing a raw
IllegalArgumentExceptionwill result in a 500 unless you handle it. Introduce a@ControllerAdviceto map this to a 400 Bad Request for clearer API semantics.
throw new IllegalArgumentException("customReason는 OTHER 타입일 때만 필요합니다.");
src/test/java/org/runimo/runimo/user/api/UserWithdrawAcceptanceTest.java
Outdated
Show resolved
Hide resolved
src/main/java/org/runimo/runimo/user/controller/request/WithdrawRequest.java
Show resolved
Hide resolved
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: 3
🧹 Nitpick comments (2)
src/test/java/org/runimo/runimo/user/api/UserWithdrawAcceptanceTest.java (1)
88-127: Consider adding test for invalid withdrawal reason enum values.While the current tests cover validation constraints, consider adding a test case for invalid withdrawal reason enum values to ensure proper error handling.
Add a test case like:
@Test @Sql(scripts = "/sql/user_mypage_test_data.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD) void 유효하지_않은_탈퇴_사유_에러() throws JsonProcessingException { WithdrawRequest request = new WithdrawRequest( "INVALID_REASON", "" ); given() .header("Authorization", token) .contentType(ContentType.JSON) .body(objectMapper.writeValueAsString(request)) .when() .delete("/api/v1/users") .then() .statusCode(400); }src/main/java/org/runimo/runimo/user/domain/UserWithdrawReason.java (1)
24-25: Consider adding audit timestamp and foreign key relationship.While the current implementation captures the essential data, consider enhancing the entity for better audit capabilities and data integrity.
Consider adding:
- Audit timestamps (created_at)
- Foreign key relationship to User (though this might be intentionally omitted for audit purposes)
@Column(name = "user_id", nullable = false) private Long userId; +@Column(name = "created_at", nullable = false) +private LocalDateTime createdAt; +@PrePersist +protected void onCreate() { + createdAt = LocalDateTime.now(); +}This would provide better audit trail capabilities for withdrawal reasons.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
src/main/java/org/runimo/runimo/user/controller/UserWithdrawController.java(2 hunks)src/main/java/org/runimo/runimo/user/controller/request/WithdrawRequest.java(1 hunks)src/main/java/org/runimo/runimo/user/domain/UserWithdrawReason.java(1 hunks)src/main/java/org/runimo/runimo/user/domain/WithdrawalReason.java(1 hunks)src/main/java/org/runimo/runimo/user/repository/UserWithdrawReasonRepository.java(1 hunks)src/main/java/org/runimo/runimo/user/service/WithdrawService.java(3 hunks)src/main/java/org/runimo/runimo/user/service/dto/command/WithdrawCommand.java(1 hunks)src/main/resources/db/migration/V20250707__add_withdraw_reason.sql(1 hunks)src/test/java/org/runimo/runimo/user/api/UserWithdrawAcceptanceTest.java(5 hunks)src/test/resources/db/migration/h2/V20250707__add_withdraw_reason.sql(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build and analyze
🔇 Additional comments (12)
src/main/java/org/runimo/runimo/user/service/dto/command/WithdrawCommand.java (1)
5-9: LGTM! Clean command object design.The record structure is well-designed for encapsulating withdrawal command data. The separation of concerns is appropriate with validation likely handled at the request DTO level.
src/main/java/org/runimo/runimo/user/repository/UserWithdrawReasonRepository.java (1)
6-6: LGTM! Standard JPA repository implementation.The repository interface follows Spring Data JPA conventions appropriately.
src/main/java/org/runimo/runimo/user/controller/UserWithdrawController.java (2)
7-7: LGTM! Proper validation annotation added.Good addition of the
@Validannotation for request validation.
31-36: LGTM! Clean controller method design.The updated method signature properly handles both the user ID and withdrawal request body with appropriate validation. The conversion to command object maintains good separation of concerns.
src/main/java/org/runimo/runimo/user/service/WithdrawService.java (2)
34-46: LGTM! Well-structured withdrawal flow with proper reason tracking.The refactored
withdrawmethod maintains the existing withdrawal logic while properly integrating the new reason tracking feature. The separation of concerns with the helper method is good practice.
65-71: LGTM! Clean helper method implementation.The
createUserWithdrawReasonmethod is well-implemented with proper builder pattern usage and clear parameter mapping from the command object.src/main/java/org/runimo/runimo/user/controller/request/WithdrawRequest.java (1)
18-22: LGTM! Proper validation annotations applied.The field definitions are well-structured with appropriate Swagger documentation and validation constraints. The
@Lengthannotation correctly limits the reason detail to 255 characters.src/test/java/org/runimo/runimo/user/api/UserWithdrawAcceptanceTest.java (2)
55-86: LGTM! Well-updated test with proper new request structure.The existing test has been properly updated to use the new
WithdrawRequeststructure while maintaining the same validation logic. The test flow is clear and comprehensive.
88-127: LGTM! Comprehensive validation test coverage.The new validation tests properly cover the business rules:
- Detailed reasons are only allowed for "OTHER" withdrawal reasons
- Reason details must not exceed 255 characters
The test data and assertions are appropriate for these scenarios.
src/main/java/org/runimo/runimo/user/domain/WithdrawalReason.java (1)
1-18: LGTM! Well-defined withdrawal reason enum.The enum is properly structured with clear Korean descriptions and appropriate constant names. The inclusion of the "OTHER" option aligns well with the custom reason functionality in the domain model.
src/main/java/org/runimo/runimo/user/domain/UserWithdrawReason.java (2)
15-32: LGTM! Well-structured JPA entity with proper annotations.The entity is correctly mapped with appropriate JPA annotations. The column mappings are clear and the enum is properly stored as STRING type for readability.
34-47: LGTM! Excellent validation logic implementation.The validation in the constructor ensures data integrity by enforcing the business rule that custom reasons are only allowed when the withdrawal reason is "OTHER". The validation method is clear and provides a descriptive error message.
src/main/java/org/runimo/runimo/user/controller/request/WithdrawRequest.java
Show resolved
Hide resolved
|



작업 내용
Summary by CodeRabbit
New Features
Bug Fixes
Tests