-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
198f49a
:hammer: chore : add add_withdrawal_reason table migration file
ekgns33 f09dc25
:sparkles: feat : add UserWithdrawReason
ekgns33 51d96cb
:sparkles: feat : add UserWithdrawReasonRepository
ekgns33 34ea363
:sparkles: feat : add save-reason-logic to `withdraw` method
ekgns33 b76f8da
:sparkles: feat : add WithdrawRequest, mapping logic
ekgns33 e898670
:white_check_mark: test : add test for saving withdrawal reason
ekgns33 013fb24
:white_check_mark: test : fix incorrect request-input
ekgns33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/org/runimo/runimo/user/controller/request/WithdrawRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package org.runimo.runimo.user.controller.request; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.AccessLevel; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.hibernate.validator.constraints.Length; | ||
| import org.runimo.runimo.user.domain.WithdrawalReason; | ||
| import org.runimo.runimo.user.service.dto.command.WithdrawCommand; | ||
|
|
||
| @Schema(description = "회원 탈퇴 DTO") | ||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @AllArgsConstructor | ||
| public class WithdrawRequest { | ||
|
|
||
| @Schema(description = "탈퇴 이유", example = "FOUND_BETTER_SERVICE") | ||
| private String withdrawReason; | ||
| @Schema(description = "기타 항목에 적는 문자열", example = "기타 항목에 적는 문자열") | ||
| @Length(max = 255, message = "기타 항목에 적는 문자열은 255자 이하로 입력해주세요.") | ||
| private String reasonDetail; | ||
|
|
||
| public static WithdrawCommand toCommand(Long id, WithdrawRequest request) { | ||
| return new WithdrawCommand( | ||
| id, | ||
| WithdrawalReason.valueOf(request.getWithdrawReason()), | ||
| request.getReasonDetail() | ||
| ); | ||
| } | ||
ekgns33 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
49 changes: 49 additions & 0 deletions
49
src/main/java/org/runimo/runimo/user/domain/UserWithdrawReason.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package org.runimo.runimo.user.domain; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.EnumType; | ||
| import jakarta.persistence.Enumerated; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Table(name = "user_withdrawal_reason") | ||
| @Entity | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class UserWithdrawReason { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(name = "user_id", nullable = false) | ||
| private Long userId; | ||
|
|
||
| @Column(name = "reason", nullable = false) | ||
| @Enumerated(EnumType.STRING) | ||
| private WithdrawalReason reason; | ||
|
|
||
| @Column(name = "custom_reason") | ||
| private String customReason; | ||
|
|
||
| @Builder | ||
| public UserWithdrawReason(Long id, Long userId, WithdrawalReason reason, String customReason) { | ||
| this.id = id; | ||
| this.userId = userId; | ||
| this.reason = reason; | ||
| this.customReason = customReason; | ||
| validateReason(); | ||
| } | ||
|
|
||
| private void validateReason() { | ||
| if (reason != WithdrawalReason.OTHER && (customReason != null && !customReason.isEmpty())) { | ||
| throw new IllegalArgumentException("customReason는 OTHER 타입일 때만 필요합니다."); | ||
| } | ||
ekgns33 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| } | ||
18 changes: 18 additions & 0 deletions
18
src/main/java/org/runimo/runimo/user/domain/WithdrawalReason.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package org.runimo.runimo.user.domain; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Getter | ||
| @RequiredArgsConstructor | ||
| public enum WithdrawalReason { | ||
| NOT_ENOUGH_CHARACTERS("수집할 캐릭터가 부족해요"), | ||
| NO_LONGER_NEEDED("러닝 목표에 도움이 되지 않아요"), | ||
| RECORD_NOT_EXPECTED("기록 기능이 기대와 달라요"), | ||
| COMPLEX_USAGE("앱 사용이 복잡해요"), | ||
| USING_OTHER_SERVICE("다른 러닝 앱을 사용하고 있어요"), | ||
| PRIVACY_CONCERN("개인정보가 걱정돼요"), | ||
| OTHER("기타 (직접 입력)"); | ||
|
|
||
| private final String description; | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/org/runimo/runimo/user/repository/UserWithdrawReasonRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package org.runimo.runimo.user.repository; | ||
|
|
||
| import org.runimo.runimo.user.domain.UserWithdrawReason; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface UserWithdrawReasonRepository extends JpaRepository<UserWithdrawReason, Long> { | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/org/runimo/runimo/user/service/dto/command/WithdrawCommand.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package org.runimo.runimo.user.service.dto.command; | ||
|
|
||
| import org.runimo.runimo.user.domain.WithdrawalReason; | ||
|
|
||
| public record WithdrawCommand( | ||
| Long userId, | ||
| WithdrawalReason reason, | ||
| String reasonDetail | ||
| ) { | ||
|
|
||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/resources/db/migration/V20250707__add_withdraw_reason.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| create table user_withdrawal_reason | ||
| ( | ||
| `id` BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, | ||
| `user_id` BIGINT NOT NULL, | ||
| `reason` VARCHAR(32) NOT NULL, | ||
| `custom_reason` VARCHAR(255) | ||
| ); | ||
ekgns33 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/test/resources/db/migration/h2/V20250707__add_withdraw_reason.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| create table user_withdrawal_reason | ||
| ( | ||
| `id` BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, | ||
| `user_id` BIGINT NOT NULL, | ||
| `reason` VARCHAR(32) NOT NULL, | ||
| `custom_reason` VARCHAR(255) | ||
| ); | ||
ekgns33 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.