From 9c542c0d45966c224940f7ca57f8949d9647fcba Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sun, 3 Mar 2024 13:09:56 +0900 Subject: [PATCH] =?UTF-8?q?[REFACTOR]=20#141=20:=20validate=20->=20check?= =?UTF-8?q?=EB=A1=9C=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EB=B0=8F=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/core/data/repository/auth/AuthRepository.kt | 2 +- .../wapp/core/data/repository/auth/AuthRepositoryImpl.kt | 4 ++-- .../data/repository/management/ManagementRepository.kt | 2 +- .../data/repository/management/ManagementRepositoryImpl.kt | 4 ++-- ...teWapMemberCodeUseCase.kt => CheckMemberCodeUseCase.kt} | 7 ++++--- ...agementCodeUseCase.kt => CheckManagementCodeUseCase.kt} | 4 ++-- .../wap/wapp/core/network/source/auth/AuthDataSource.kt | 2 +- .../wapp/core/network/source/auth/AuthDataSourceImpl.kt | 2 +- .../core/network/source/management/ManagementDataSource.kt | 2 +- .../network/source/management/ManagementDataSourceImpl.kt | 2 +- .../com/wap/wapp/feature/auth/signup/SignUpViewModel.kt | 6 +++--- .../management/validation/ManagementValidationViewModel.kt | 6 +++--- 12 files changed, 22 insertions(+), 21 deletions(-) rename core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/{ValidateWapMemberCodeUseCase.kt => CheckMemberCodeUseCase.kt} (69%) rename core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/{ValidateManagementCodeUseCase.kt => CheckManagementCodeUseCase.kt} (89%) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/AuthRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/AuthRepository.kt index daecb5050..ac988f856 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/AuthRepository.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/AuthRepository.kt @@ -7,5 +7,5 @@ interface AuthRepository { suspend fun isUserSignIn(): Result - suspend fun validateMemberCode(code: String): Result + suspend fun checkMemberCode(code: String): Result } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/AuthRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/AuthRepositoryImpl.kt index 635eda707..d79a21bab 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/AuthRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/AuthRepositoryImpl.kt @@ -12,6 +12,6 @@ class AuthRepositoryImpl @Inject constructor( override suspend fun isUserSignIn(): Result = authDataSource.isUserSignIn() - override suspend fun validateMemberCode(code: String): Result = - authDataSource.validateMemberCode(code) + override suspend fun checkMemberCode(code: String): Result = + authDataSource.checkMemberCode(code) } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/management/ManagementRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/management/ManagementRepository.kt index 7d7cec07b..8c6141546 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/management/ManagementRepository.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/management/ManagementRepository.kt @@ -5,7 +5,7 @@ interface ManagementRepository { suspend fun postManager(userId: String): Result - suspend fun getManagementCode(code: String): Result + suspend fun checkManagementCode(code: String): Result suspend fun deleteManager(userId: String): Result } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/management/ManagementRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/management/ManagementRepositoryImpl.kt index eb7d4b328..440ae1566 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/management/ManagementRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/management/ManagementRepositoryImpl.kt @@ -12,8 +12,8 @@ class ManagementRepositoryImpl @Inject constructor( override suspend fun postManager(userId: String): Result = managementDataSource.postManager(userId) - override suspend fun getManagementCode(code: String): Result = - managementDataSource.getManagementCode(code) + override suspend fun checkManagementCode(code: String): Result = + managementDataSource.checkManagementCode(code) override suspend fun deleteManager(userId: String): Result = managementDataSource.deleteManager(userId) diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/ValidateWapMemberCodeUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/CheckMemberCodeUseCase.kt similarity index 69% rename from core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/ValidateWapMemberCodeUseCase.kt rename to core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/CheckMemberCodeUseCase.kt index 58bb8913f..0dcf0d647 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/ValidateWapMemberCodeUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/CheckMemberCodeUseCase.kt @@ -1,13 +1,14 @@ package com.wap.wapp.core.domain.usecase.auth +import com.wap.wapp.core.data.repository.auth.AuthRepository import com.wap.wapp.core.domain.model.CodeValidation import javax.inject.Inject -class ValidateWapMemberCodeUseCase @Inject constructor( - private val signUpRepository: SignUpRepository, +class CheckMemberCodeUseCase @Inject constructor( + private val authRepository: AuthRepository, ) { suspend operator fun invoke(code: String): Result = runCatching { - signUpRepository.validationWapCode(code).fold( + authRepository.checkMemberCode(code).fold( onSuccess = { isValid -> if (isValid) { return@fold CodeValidation.VALID diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/ValidateManagementCodeUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/CheckManagementCodeUseCase.kt similarity index 89% rename from core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/ValidateManagementCodeUseCase.kt rename to core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/CheckManagementCodeUseCase.kt index d9a52fcb9..999cdd644 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/ValidateManagementCodeUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/CheckManagementCodeUseCase.kt @@ -7,12 +7,12 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class ValidateManagementCodeUseCase @Inject constructor( +class CheckManagementCodeUseCase @Inject constructor( private val managementRepository: ManagementRepository, private val userRepository: UserRepository, ) { suspend operator fun invoke(code: String): Result = runCatching { - managementRepository.getManagementCode(code) + managementRepository.checkManagementCode(code) .onSuccess { isValid -> if (isValid.not()) { // 코드가 틀렸을 경우 return@runCatching CodeValidation.INVALID diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/auth/AuthDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/auth/AuthDataSource.kt index 48ef7f0bf..06bd34157 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/auth/AuthDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/auth/AuthDataSource.kt @@ -7,5 +7,5 @@ interface AuthDataSource { suspend fun isUserSignIn(): Result - suspend fun validateMemberCode(code: String): Result + suspend fun checkMemberCode(code: String): Result } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/auth/AuthDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/auth/AuthDataSourceImpl.kt index cc5f46d19..84def2902 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/auth/AuthDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/auth/AuthDataSourceImpl.kt @@ -49,7 +49,7 @@ class AuthDataSourceImpl @Inject constructor( } } - override suspend fun validateMemberCode(code: String): Result = runCatching { + override suspend fun checkMemberCode(code: String): Result = runCatching { val result = firebaseFirestore.collection(CODES_COLLECTION) .whereEqualTo("user", code) .get() diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/management/ManagementDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/management/ManagementDataSource.kt index 210825677..866f164b1 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/management/ManagementDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/management/ManagementDataSource.kt @@ -5,7 +5,7 @@ interface ManagementDataSource { suspend fun postManager(userId: String): Result - suspend fun getManagementCode(code: String): Result + suspend fun checkManagementCode(code: String): Result suspend fun deleteManager(userId: String): Result } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/management/ManagementDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/management/ManagementDataSourceImpl.kt index 9437382d3..feb8599ef 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/management/ManagementDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/management/ManagementDataSourceImpl.kt @@ -29,7 +29,7 @@ class ManagementDataSourceImpl @Inject constructor( .await() } - override suspend fun getManagementCode(code: String): Result = runCatching { + override suspend fun checkManagementCode(code: String): Result = runCatching { val result = firebaseFirestore.collection(CODES_COLLECTION) .whereEqualTo("management", code) .get() diff --git a/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpViewModel.kt b/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpViewModel.kt index 6a85625c4..07698f9d3 100644 --- a/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpViewModel.kt +++ b/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpViewModel.kt @@ -3,7 +3,7 @@ package com.wap.wapp.feature.auth.signup import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.domain.model.CodeValidation -import com.wap.wapp.core.domain.usecase.auth.ValidateWapMemberCodeUseCase +import com.wap.wapp.core.domain.usecase.auth.CheckMemberCodeUseCase import com.wap.wapp.core.domain.usecase.user.PostUserProfileUseCase import com.wap.wapp.feature.auth.R import dagger.hilt.android.lifecycle.HiltViewModel @@ -19,7 +19,7 @@ import javax.inject.Inject @HiltViewModel class SignUpViewModel @Inject constructor( private val postUserProfileUseCase: PostUserProfileUseCase, - private val validateWapMemberCodeUseCase: ValidateWapMemberCodeUseCase, + private val checkMemberCodeUseCase: CheckMemberCodeUseCase, ) : ViewModel() { private val _signUpEventFlow = MutableSharedFlow() val signUpEventFlow: SharedFlow = _signUpEventFlow.asSharedFlow() @@ -58,7 +58,7 @@ class SignUpViewModel @Inject constructor( } fun validateMemberCode() = viewModelScope.launch { - validateWapMemberCodeUseCase(_memberCode.value).onSuccess { + checkMemberCodeUseCase(_memberCode.value).onSuccess { when (it) { CodeValidation.VALID -> _signUpEventFlow.emit(SignUpEvent.ValidateMemberCodeSuccess) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/validation/ManagementValidationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/validation/ManagementValidationViewModel.kt index 02a880556..ac4a099ea 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/validation/ManagementValidationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/validation/ManagementValidationViewModel.kt @@ -3,7 +3,7 @@ package com.wap.wapp.feature.management.validation import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.domain.model.CodeValidation -import com.wap.wapp.core.domain.usecase.management.ValidateManagementCodeUseCase +import com.wap.wapp.core.domain.usecase.management.CheckManagementCodeUseCase import com.wap.wapp.feature.management.R import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow @@ -13,7 +13,7 @@ import javax.inject.Inject @HiltViewModel class ManagementValidationViewModel @Inject constructor( - private val validateManagementCodeUseCase: ValidateManagementCodeUseCase, + private val checkManagementCodeUseCase: CheckManagementCodeUseCase, ) : ViewModel() { private val _managementCodeUiState: MutableStateFlow = MutableStateFlow(ManagementCodeUiState.Init) @@ -32,7 +32,7 @@ class ManagementValidationViewModel @Inject constructor( fun validateManagementCode() { viewModelScope.launch { - validateManagementCodeUseCase(_managementCode.value) + checkManagementCodeUseCase(_managementCode.value) .onSuccess { when (it) { CodeValidation.VALID -> {