From 8b54e72aa8c9f06071b3d571e11d2d2a7b450234 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sun, 3 Mar 2024 12:31:20 +0900 Subject: [PATCH] =?UTF-8?q?[REFACTOR]=20#141=20:=20SignUpRepository,=20Sig?= =?UTF-8?q?nUpDataSource=20->=20AuthRepository,=20AuthDataSource=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=91=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/wapp/core/data/di/DataModule.kt | 8 -------- .../data/repository/auth/AuthRepository.kt | 2 ++ .../repository/auth/AuthRepositoryImpl.kt | 3 +++ .../data/repository/auth/SignUpRepository.kt | 5 ----- .../repository/auth/SignUpRepositoryImpl.kt | 11 ----------- .../auth/ValidateWapMemberCodeUseCase.kt | 1 - .../wap/wapp/core/network/di/NetworkModule.kt | 8 -------- .../network/source/auth/AuthDataSource.kt | 2 ++ .../network/source/auth/AuthDataSourceImpl.kt | 12 ++++++++++++ .../network/source/auth/SignUpDataSource.kt | 5 ----- .../source/auth/SignUpDataSourceImpl.kt | 19 ------------------- 11 files changed, 19 insertions(+), 57 deletions(-) delete mode 100644 core/data/src/main/java/com/wap/wapp/core/data/repository/auth/SignUpRepository.kt delete mode 100644 core/data/src/main/java/com/wap/wapp/core/data/repository/auth/SignUpRepositoryImpl.kt delete mode 100644 core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSource.kt delete mode 100644 core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSourceImpl.kt diff --git a/core/data/src/main/java/com/wap/wapp/core/data/di/DataModule.kt b/core/data/src/main/java/com/wap/wapp/core/data/di/DataModule.kt index 0618b34a..cdd681ec 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/di/DataModule.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/di/DataModule.kt @@ -6,8 +6,6 @@ import com.wap.wapp.core.data.repository.attendancestatus.AttendanceStatusReposi import com.wap.wapp.core.data.repository.attendancestatus.AttendanceStatusRepositoryImpl import com.wap.wapp.core.data.repository.auth.AuthRepository import com.wap.wapp.core.data.repository.auth.AuthRepositoryImpl -import com.wap.wapp.core.data.repository.auth.SignUpRepository -import com.wap.wapp.core.data.repository.auth.SignUpRepositoryImpl import com.wap.wapp.core.data.repository.event.EventRepository import com.wap.wapp.core.data.repository.event.EventRepositoryImpl import com.wap.wapp.core.data.repository.management.ManagementRepository @@ -74,10 +72,4 @@ abstract class DataModule { abstract fun bindsAttendanceStatusRepository( attendanceStatusRepositoryImpl: AttendanceStatusRepositoryImpl, ): AttendanceStatusRepository - - @Binds - @Singleton - abstract fun bindsSignUpRepository( - signUpRepositoryImpl: SignUpRepositoryImpl, - ): SignUpRepository } 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 00e51ac8..ba276f18 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 @@ -6,4 +6,6 @@ interface AuthRepository { suspend fun deleteUser(): Result suspend fun isUserSignIn(): Result + + suspend fun validationWapCode(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 3e855fcb..4ca9e1ed 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 @@ -11,4 +11,7 @@ class AuthRepositoryImpl @Inject constructor( override suspend fun deleteUser(): Result = authDataSource.deleteUser() override suspend fun isUserSignIn(): Result = authDataSource.isUserSignIn() + + override suspend fun validationWapCode(code: String): Result = + authDataSource.validationWapCode(code) } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/SignUpRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/SignUpRepository.kt deleted file mode 100644 index 110e43b8..00000000 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/SignUpRepository.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.wap.wapp.core.data.repository.auth - -interface SignUpRepository { - suspend fun validationWapCode(code: String): Result -} diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/SignUpRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/SignUpRepositoryImpl.kt deleted file mode 100644 index a417a14c..00000000 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/SignUpRepositoryImpl.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.wap.wapp.core.data.repository.auth - -import com.wap.wapp.core.network.source.auth.SignUpDataSource -import javax.inject.Inject - -class SignUpRepositoryImpl @Inject constructor( - private val signUpDataSource: SignUpDataSource, -) : SignUpRepository { - override suspend fun validationWapCode(code: String): Result = - signUpDataSource.validationWapCode(code) -} 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/ValidateWapMemberCodeUseCase.kt index e3450ddb..58bb8913 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/ValidateWapMemberCodeUseCase.kt @@ -1,6 +1,5 @@ package com.wap.wapp.core.domain.usecase.auth -import com.wap.wapp.core.data.repository.auth.SignUpRepository import com.wap.wapp.core.domain.model.CodeValidation import javax.inject.Inject diff --git a/core/network/src/main/java/com/wap/wapp/core/network/di/NetworkModule.kt b/core/network/src/main/java/com/wap/wapp/core/network/di/NetworkModule.kt index e6aeaab2..b5ce3ec8 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/di/NetworkModule.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/di/NetworkModule.kt @@ -6,8 +6,6 @@ import com.wap.wapp.core.network.source.attendancestatus.AttendanceStatusDataSou import com.wap.wapp.core.network.source.attendancestatus.AttendanceStatusDataSourceImpl import com.wap.wapp.core.network.source.auth.AuthDataSource import com.wap.wapp.core.network.source.auth.AuthDataSourceImpl -import com.wap.wapp.core.network.source.auth.SignUpDataSource -import com.wap.wapp.core.network.source.auth.SignUpDataSourceImpl import com.wap.wapp.core.network.source.event.EventDataSource import com.wap.wapp.core.network.source.event.EventDataSourceImpl import com.wap.wapp.core.network.source.management.ManagementDataSource @@ -75,10 +73,4 @@ abstract class NetworkModule { abstract fun bindsAttendanceStatusDataSource( attendanceStatueDataSourceImpl: AttendanceStatusDataSourceImpl, ): AttendanceStatusDataSource - - @Binds - @Singleton - abstract fun bindsSignUpDataSource( - signUpDataSourceImpl: SignUpDataSourceImpl, - ): SignUpDataSource } 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 9e859b0e..e5e2b3ce 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 @@ -6,4 +6,6 @@ interface AuthDataSource { suspend fun deleteUser(): Result suspend fun isUserSignIn(): Result + + suspend fun validationWapCode(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 5b4489ed..14aa4ec9 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 @@ -2,6 +2,8 @@ package com.wap.wapp.core.network.source.auth import com.google.firebase.auth.FirebaseAuth import com.google.firebase.auth.FirebaseAuth.AuthStateListener +import com.google.firebase.firestore.FirebaseFirestore +import com.wap.wapp.core.network.constant.CODES_COLLECTION import com.wap.wapp.core.network.utils.await import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.suspendCancellableCoroutine @@ -9,6 +11,7 @@ import javax.inject.Inject class AuthDataSourceImpl @Inject constructor( private val firebaseAuth: FirebaseAuth, + private val firebaseFirestore: FirebaseFirestore, ) : AuthDataSource { override suspend fun signOut(): Result = runCatching { firebaseAuth.signOut() @@ -45,4 +48,13 @@ class AuthDataSourceImpl @Inject constructor( } } } + + override suspend fun validationWapCode(code: String): Result = runCatching { + val result = firebaseFirestore.collection(CODES_COLLECTION) + .whereEqualTo("user", code) + .get() + .await() + + result.isEmpty.not() + } } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSource.kt deleted file mode 100644 index b0e6a71e..00000000 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSource.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.wap.wapp.core.network.source.auth - -interface SignUpDataSource { - suspend fun validationWapCode(code: String): Result -} diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSourceImpl.kt deleted file mode 100644 index eb32fa1b..00000000 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSourceImpl.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.wap.wapp.core.network.source.auth - -import com.google.firebase.firestore.FirebaseFirestore -import com.wap.wapp.core.network.constant.CODES_COLLECTION -import com.wap.wapp.core.network.utils.await -import javax.inject.Inject - -class SignUpDataSourceImpl @Inject constructor( - private val firebaseFirestore: FirebaseFirestore, -) : SignUpDataSource { - override suspend fun validationWapCode(code: String): Result = runCatching { - val result = firebaseFirestore.collection(CODES_COLLECTION) - .whereEqualTo("user", code) - .get() - .await() - - result.isEmpty.not() - } -}