-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#88 회원탈퇴 API 구현
- Loading branch information
Showing
16 changed files
with
187 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/com/routebox/routebox/application/auth/WithdrawUseCase.kt
This file contains 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,24 @@ | ||
package com.routebox.routebox.application.auth | ||
|
||
import com.routebox.routebox.application.auth.dto.WithdrawCommand | ||
import com.routebox.routebox.domain.auth.AuthService | ||
import com.routebox.routebox.domain.user.UserService | ||
import jakarta.validation.Valid | ||
import org.springframework.stereotype.Component | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Component | ||
class WithdrawUseCase( | ||
private val userService: UserService, | ||
private val authService: AuthService, | ||
) { | ||
/** | ||
* 회원 탈퇴 | ||
* @param command | ||
*/ | ||
@Transactional | ||
operator fun invoke(@Valid command: WithdrawCommand) { | ||
val user = userService.getUserById(command.userId) | ||
authService.withdrawUser(user, command.reasonType, command.reasonDetail) | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/com/routebox/routebox/application/auth/dto/WithdrawCommand.kt
This file contains 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,9 @@ | ||
package com.routebox.routebox.application.auth.dto | ||
|
||
import com.routebox.routebox.domain.auth.WithdrawalReasonType | ||
|
||
data class WithdrawCommand( | ||
val userId: Long, | ||
val reasonType: WithdrawalReasonType, | ||
val reasonDetail: String?, | ||
) |
This file contains 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
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/com/routebox/routebox/controller/auth/dto/WithdrawRequest.kt
This file contains 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,10 @@ | ||
package com.routebox.routebox.controller.auth.dto | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class WithdrawRequest( | ||
@Schema(description = "탈퇴 사유", example = "기타") | ||
val reasonType: String, | ||
@Schema(description = "탈퇴 사유 상세", example = "기타") | ||
val reasonDetail: String?, | ||
) |
This file contains 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
35 changes: 35 additions & 0 deletions
35
src/main/kotlin/com/routebox/routebox/domain/auth/WithdrawalHistory.kt
This file contains 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,35 @@ | ||
package com.routebox.routebox.domain.auth | ||
|
||
import com.routebox.routebox.domain.common.TimeTrackedBaseEntity | ||
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 | ||
|
||
@Table(name = "withdrawal_histories") | ||
@Entity | ||
class WithdrawalHistory( | ||
id: Long = 0, | ||
userId: Long, | ||
reasonType: WithdrawalReasonType?, | ||
reasonDetail: String?, | ||
) : TimeTrackedBaseEntity() { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "withdrawal_history_id") | ||
val id: Long = id | ||
|
||
var userId: Long = userId | ||
|
||
@Enumerated(EnumType.STRING) | ||
var reasonType: WithdrawalReasonType? = reasonType | ||
private set | ||
|
||
var reasonDetail: String? = reasonDetail | ||
private set | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/com/routebox/routebox/domain/auth/WithdrawalReasonType.kt
This file contains 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,23 @@ | ||
package com.routebox.routebox.domain.auth | ||
|
||
enum class WithdrawalReasonType(val description: String) { | ||
LIMITED_ROUTE_OPTIONS("루트가 다양하지 않아서 유용하지 않음"), | ||
DIFFICULT_ROUTE_RECORDING("여행 루트를 기록하기 어려움"), | ||
APP_NOT_AS_EXPECTED("다운로드 시 기대한 내용과 앱이 다름"), | ||
LOW_SERVICE_TRUST("서비스 운영의 신뢰도가 낮음"), | ||
ETC("기타"), | ||
; | ||
|
||
companion object { | ||
fun fromString(value: String): WithdrawalReasonType { | ||
return when (value) { | ||
"LIMITED_ROUTE_OPTIONS" -> LIMITED_ROUTE_OPTIONS | ||
"DIFFICULT_ROUTE_RECORDING" -> DIFFICULT_ROUTE_RECORDING | ||
"APP_NOT_AS_EXPECTED" -> APP_NOT_AS_EXPECTED | ||
"LOW_SERVICE_TRUST" -> LOW_SERVICE_TRUST | ||
"ETC" -> ETC | ||
else -> throw IllegalArgumentException("Invalid value: $value") | ||
} | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/com/routebox/routebox/exception/user/UserWithdrawnException.kt
This file contains 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,5 @@ | ||
package com.routebox.routebox.exception.user | ||
|
||
import com.routebox.routebox.exception.CustomExceptionType | ||
import com.routebox.routebox.exception.common.ConflictException | ||
class UserWithdrawnException : ConflictException(CustomExceptionType.USER_WITHDRAWN) |
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/com/routebox/routebox/infrastructure/auth/WithdrawalHistoryRepository.kt
This file contains 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,6 @@ | ||
package com.routebox.routebox.infrastructure.auth | ||
|
||
import com.routebox.routebox.domain.auth.WithdrawalHistory | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
|
||
interface WithdrawalHistoryRepository : JpaRepository<WithdrawalHistory, Long> |
This file contains 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
This file contains 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
This file contains 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
This file contains 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