-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#219 UserRepository내 메서드 반환 타입 flow제거, 구현 메서드 공란으로 변경
- Loading branch information
Showing
23 changed files
with
111 additions
and
249 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
2 changes: 2 additions & 0 deletions
2
.../data/src/main/java/com/android/mediproject/core/data/session/AccountSessionRepository.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
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
31 changes: 8 additions & 23 deletions
31
core/data/src/main/java/com/android/mediproject/core/data/user/UserRepositoryImpl.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 |
---|---|---|
@@ -1,39 +1,24 @@ | ||
package com.android.mediproject.core.data.user | ||
|
||
import android.util.Log | ||
import com.android.mediproject.core.model.requestparameters.ChangeNicknameParameter | ||
import com.android.mediproject.core.model.requestparameters.ChangePasswordParameter | ||
import com.android.mediproject.core.model.user.remote.ChangeNicknameResponse | ||
import com.android.mediproject.core.model.user.remote.ChangePasswordResponse | ||
import com.android.mediproject.core.model.user.remote.WithdrawalResponse | ||
import com.android.mediproject.core.network.datasource.user.UserDataSource | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.channelFlow | ||
import kotlinx.coroutines.flow.collectLatest | ||
import kotlinx.coroutines.flow.map | ||
import javax.inject.Inject | ||
|
||
class UserRepositoryImpl @Inject constructor(private val userDataSource: UserDataSource) : | ||
UserRepository { | ||
override suspend fun changeNickname(changeNicknameParameter: ChangeNicknameParameter): Flow<Result<ChangeNicknameResponse>> = | ||
channelFlow { | ||
userDataSource.changeNickname(changeNicknameParameter).map { result -> | ||
result.fold(onSuccess = { Result.success(it) }, onFailure = { Result.failure(it) }) | ||
}.collectLatest { trySend(it) } | ||
} | ||
override suspend fun withdrawal(): Result<WithdrawalResponse> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun changePassword(changePasswordParameter: ChangePasswordParameter): Flow<Result<ChangePasswordResponse>> = | ||
channelFlow { | ||
userDataSource.changePassword(changePasswordParameter).map { result -> | ||
result.fold(onSuccess = { Result.success(it) }, onFailure = { Result.failure(it) }) | ||
}.collectLatest { trySend(it) } | ||
} | ||
override suspend fun changeNickname(changeNicknameParameter: ChangeNicknameParameter): Result<ChangeNicknameResponse> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun withdrawal(): Flow<Result<WithdrawalResponse>> = channelFlow { | ||
Log.d("wap", "UserRepository : withdrawal()") | ||
userDataSource.withdrawal().map { result -> | ||
Log.d("wap", "UserRepository : withdrawal()$result") | ||
result.fold(onSuccess = { Result.success(it) }, onFailure = { Result.failure(it) }) | ||
}.collectLatest { trySend(it) } | ||
override suspend fun changePassword(changePasswordParameter: ChangePasswordParameter): Result<ChangePasswordResponse> { | ||
TODO("Not yet implemented") | ||
} | ||
} |
65 changes: 20 additions & 45 deletions
65
core/domain/src/main/java/com/android/mediproject/core/domain/EditUserAccountUseCase.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 |
---|---|---|
@@ -1,64 +1,39 @@ | ||
package com.android.mediproject.core.domain | ||
|
||
import android.util.Log | ||
import com.android.mediproject.core.data.sign.SignRepository | ||
import com.android.mediproject.core.data.user.UserRepository | ||
import com.android.mediproject.core.datastore.AppDataStore | ||
import com.android.mediproject.core.model.requestparameters.ChangeNicknameParameter | ||
import com.android.mediproject.core.model.requestparameters.ChangePasswordParameter | ||
import kotlinx.coroutines.flow.channelFlow | ||
import kotlinx.coroutines.flow.collectLatest | ||
import kotlinx.coroutines.flow.map | ||
import javax.inject.Inject | ||
|
||
|
||
class EditUserAccountUseCase @Inject constructor( | ||
private val appDataStore: AppDataStore, | ||
private val userRepository: UserRepository, | ||
private val getUserInfoRepository: UserInfoRepository, | ||
private val signRepository: SignRepository, | ||
) { | ||
suspend fun changeNickname(changeNicknameParameter: ChangeNicknameParameter) = channelFlow { | ||
userRepository.changeNickname(changeNicknameParameter).map { result -> | ||
result.fold( | ||
onSuccess = { | ||
appDataStore.saveNickName(changeNicknameParameter.newNickname) | ||
Result.success(it) | ||
}, | ||
onFailure = { Result.failure(it) }, | ||
) | ||
}.collectLatest { trySend(it) } | ||
} | ||
suspend fun changeNickname(changeNicknameParameter: ChangeNicknameParameter) = userRepository.changeNickname(changeNicknameParameter).fold( | ||
onSuccess = { | ||
appDataStore.saveNickName(changeNicknameParameter.newNickname) | ||
Result.success(it) | ||
}, | ||
onFailure = { Result.failure(it) }, | ||
) | ||
|
||
suspend fun changePassword(changePasswordParameter: ChangePasswordParameter) = channelFlow { | ||
val email = | ||
(getUserInfoRepository.myAccountInfo.value as AccountState.SignedIn).email.toCharArray() | ||
userRepository.changePassword( | ||
changePasswordParameter.apply { | ||
this.email = email | ||
}, | ||
).map { result -> | ||
result.fold( | ||
onSuccess = { | ||
Result.success(it) | ||
}, | ||
onFailure = { Result.failure(it) }, | ||
) | ||
}.collectLatest { trySend(it) } | ||
} | ||
suspend fun changePassword(changePasswordParameter: ChangePasswordParameter) = userRepository.changePassword( | ||
changePasswordParameter, | ||
).fold( | ||
onSuccess = { | ||
Result.success(it) | ||
}, | ||
onFailure = { Result.failure(it) }, | ||
) | ||
|
||
suspend fun withdrawal() = channelFlow { | ||
Log.d("wap", "UserUseCase : withdrawal()") | ||
userRepository.withdrawal().map { result -> | ||
Log.d("wap", "UserUseCase : withdrawal()$result") | ||
result.fold( | ||
onSuccess = { | ||
signRepository.signOut() | ||
appDataStore.clearMyAccountInfo() | ||
Result.success(it) | ||
}, | ||
onFailure = { Result.failure(it) }, | ||
) | ||
}.collectLatest { trySend(it) } | ||
suspend fun withdrawal() { | ||
userRepository.withdrawal() | ||
signRepository.signOut() | ||
appDataStore.clearMyAccountInfo() | ||
} | ||
|
||
} |
18 changes: 0 additions & 18 deletions
18
core/domain/src/main/java/com/android/mediproject/core/domain/GetAccountStateUseCase.kt
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
core/domain/src/main/java/com/android/mediproject/core/domain/GetTokenUseCase.kt
This file was deleted.
Oops, something went wrong.
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
23 changes: 0 additions & 23 deletions
23
core/domain/src/main/java/com/android/mediproject/core/domain/SignUseCase.kt
This file was deleted.
Oops, something went wrong.
30 changes: 3 additions & 27 deletions
30
...main/java/com/android/mediproject/core/model/requestparameters/ChangePasswordParameter.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 |
---|---|---|
@@ -1,29 +1,5 @@ | ||
package com.android.mediproject.core.model.requestparameters | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ChangePasswordParameter( | ||
val newPassword: CharArray | ||
) { | ||
|
||
var email: CharArray = CharArray(0) | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as ChangePasswordParameter | ||
|
||
if (!newPassword.contentEquals(other.newPassword)) return false | ||
if (!email.contentEquals(other.email)) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = newPassword.contentHashCode() | ||
result = 31 * result + email.contentHashCode() | ||
return result | ||
} | ||
|
||
} | ||
class ChangePasswordParameter( | ||
val newPassword: ByteArray, | ||
) |
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
Oops, something went wrong.