From eac14e7ed6a7619bf5924ffecc8392cb72041b94 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Thu, 18 Jul 2024 04:16:27 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT/#116]=20=EA=B3=84=EC=A0=95=ED=83=88?= =?UTF-8?q?=ED=87=B4=20=EC=84=9C=EB=B2=84=ED=86=B5=EC=8B=A0=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/MyPageDataSource.kt | 2 ++ .../datasourceimpl/MyPageDataSourceImpl.kt | 2 ++ .../repositoryimpl/MyPageRepositoryImpl.kt | 5 +++++ .../com/terning/data/service/MyPageService.kt | 4 ++++ .../domain/repository/MyPageRepository.kt | 2 ++ .../com/terning/feature/mypage/MyPageRoute.kt | 2 +- .../terning/feature/mypage/MyPageViewModel.kt | 19 ++++++++++++++++++- 7 files changed, 34 insertions(+), 2 deletions(-) diff --git a/data/src/main/java/com/terning/data/datasource/MyPageDataSource.kt b/data/src/main/java/com/terning/data/datasource/MyPageDataSource.kt index aec35848d..b92bb80a5 100644 --- a/data/src/main/java/com/terning/data/datasource/MyPageDataSource.kt +++ b/data/src/main/java/com/terning/data/datasource/MyPageDataSource.kt @@ -4,4 +4,6 @@ import com.terning.data.dto.NonDataBaseResponse interface MyPageDataSource { suspend fun postLogout(): NonDataBaseResponse + + suspend fun deleteQuit(): NonDataBaseResponse } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/MyPageDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/MyPageDataSourceImpl.kt index d884be7fc..f70adf162 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/MyPageDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/MyPageDataSourceImpl.kt @@ -9,4 +9,6 @@ class MyPageDataSourceImpl @Inject constructor( private val myPageService: MyPageService ) : MyPageDataSource { override suspend fun postLogout(): NonDataBaseResponse = myPageService.postLogout() + + override suspend fun deleteQuit(): NonDataBaseResponse = myPageService.deleteQuit() } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/repositoryimpl/MyPageRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/MyPageRepositoryImpl.kt index 580294a1d..447f7de68 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/MyPageRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/MyPageRepositoryImpl.kt @@ -11,4 +11,9 @@ class MyPageRepositoryImpl @Inject constructor( runCatching { myPageDataSource.postLogout() } + + override suspend fun deleteQuit(): Result = + runCatching{ + myPageDataSource.deleteQuit() + } } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/service/MyPageService.kt b/data/src/main/java/com/terning/data/service/MyPageService.kt index 9c73cd98c..6d5da1fc2 100644 --- a/data/src/main/java/com/terning/data/service/MyPageService.kt +++ b/data/src/main/java/com/terning/data/service/MyPageService.kt @@ -1,9 +1,13 @@ package com.terning.data.service import com.terning.data.dto.NonDataBaseResponse +import retrofit2.http.DELETE import retrofit2.http.POST interface MyPageService { @POST("api/v1/auth/logout") suspend fun postLogout(): NonDataBaseResponse + + @DELETE("api/v1/auth/withdraw") + suspend fun deleteQuit(): NonDataBaseResponse } \ No newline at end of file diff --git a/domain/src/main/java/com/terning/domain/repository/MyPageRepository.kt b/domain/src/main/java/com/terning/domain/repository/MyPageRepository.kt index 3e2ac65c7..2419f1b63 100644 --- a/domain/src/main/java/com/terning/domain/repository/MyPageRepository.kt +++ b/domain/src/main/java/com/terning/domain/repository/MyPageRepository.kt @@ -2,4 +2,6 @@ package com.terning.domain.repository interface MyPageRepository { suspend fun postLogout() : Result + + suspend fun deleteQuit() : Result } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt b/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt index 41173af9a..31ac78a82 100644 --- a/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt +++ b/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt @@ -59,7 +59,7 @@ fun MyPageRoute( MyPageQuitBottomSheet( onDismiss = { showQuitBottomSheet = false }, onQuitClick = { - viewModel.patchQuit() + viewModel.quitKakao() } ) } diff --git a/feature/src/main/java/com/terning/feature/mypage/MyPageViewModel.kt b/feature/src/main/java/com/terning/feature/mypage/MyPageViewModel.kt index fdcbf8c50..b1eff6c6b 100644 --- a/feature/src/main/java/com/terning/feature/mypage/MyPageViewModel.kt +++ b/feature/src/main/java/com/terning/feature/mypage/MyPageViewModel.kt @@ -60,7 +60,24 @@ class MyPageViewModel @Inject constructor( } } - fun patchQuit() { + fun quitKakao() { + UserApiClient.instance.unlink { error -> + if (error == null) { + deleteQuit() + } else { + _state.value = _state.value.copy(isSuccess = UiState.Failure(error.toString())) + } + } + } + private fun deleteQuit() { + viewModelScope.launch { + myPageRepository.deleteQuit().onSuccess { + tokenRepository.clearInfo() + _state.value = _state.value.copy(isSuccess = UiState.Success(true)) + }.onFailure { + _state.value = _state.value.copy(isSuccess = UiState.Failure(it.toString())) + } + } } } \ No newline at end of file