From 25c6f36fb09e679ced931c83e45dfed5c59c411a Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 10 Oct 2023 15:57:37 +0900 Subject: [PATCH 01/19] =?UTF-8?q?[CHORE]=20#15=20:=20Internet=20Permission?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4aae73fa..7a8fccfd 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ - + - \ No newline at end of file + From abe6884dfd671c508b7ef4ee74cf055c87198800 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 10 Oct 2023 15:58:42 +0900 Subject: [PATCH 02/19] [CHORE] #15 : File Rename FirebaseUtils -> SuspendCoroutine --- .../core/network/utils/{FirebaseUtils.kt => SuspendCoroutine.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename core/network/src/main/java/com/wap/wapp/core/network/utils/{FirebaseUtils.kt => SuspendCoroutine.kt} (100%) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/utils/FirebaseUtils.kt b/core/network/src/main/java/com/wap/wapp/core/network/utils/SuspendCoroutine.kt similarity index 100% rename from core/network/src/main/java/com/wap/wapp/core/network/utils/FirebaseUtils.kt rename to core/network/src/main/java/com/wap/wapp/core/network/utils/SuspendCoroutine.kt From a88ba0de579c99f7af553849d2ff3c251c8fba92 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 10 Oct 2023 15:59:30 +0900 Subject: [PATCH 03/19] =?UTF-8?q?[FEATURE]=20#15=20:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=20=EC=A1=B0=ED=9A=8C=20Response,=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=20=EB=93=B1=EB=A1=9D=20Request=20=EB=AA=A8=EB=8D=B8?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/network/model/auth/SignUpRequest.kt | 8 -------- .../network/model/user/UserProfileRequest.kt | 15 +++++++++++++++ .../network/model/user/UserProfileResponse.kt | 18 +++++++++++++++++- 3 files changed, 32 insertions(+), 9 deletions(-) delete mode 100644 core/network/src/main/java/com/wap/wapp/core/network/model/auth/SignUpRequest.kt create mode 100644 core/network/src/main/java/com/wap/wapp/core/network/model/user/UserProfileRequest.kt diff --git a/core/network/src/main/java/com/wap/wapp/core/network/model/auth/SignUpRequest.kt b/core/network/src/main/java/com/wap/wapp/core/network/model/auth/SignUpRequest.kt deleted file mode 100644 index ea92c9a2..00000000 --- a/core/network/src/main/java/com/wap/wapp/core/network/model/auth/SignUpRequest.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.wap.wapp.core.network.model.auth - -data class SignUpRequest( - val userId: String, - val userName: String, - val studentId: String, - val registeredAt: String, -) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/model/user/UserProfileRequest.kt b/core/network/src/main/java/com/wap/wapp/core/network/model/user/UserProfileRequest.kt new file mode 100644 index 00000000..59968fd6 --- /dev/null +++ b/core/network/src/main/java/com/wap/wapp/core/network/model/user/UserProfileRequest.kt @@ -0,0 +1,15 @@ +package com.wap.wapp.core.network.model.user + +data class UserProfileRequest( + val userId: String, + val userName: String, + val studentId: String, + val registeredAt: String, +) { + constructor() : this( + "", + "", + "", + "", + ) +} diff --git a/core/network/src/main/java/com/wap/wapp/core/network/model/user/UserProfileResponse.kt b/core/network/src/main/java/com/wap/wapp/core/network/model/user/UserProfileResponse.kt index 9d77518b..deb0f61f 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/model/user/UserProfileResponse.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/model/user/UserProfileResponse.kt @@ -1,8 +1,24 @@ package com.wap.wapp.core.network.model.user +import com.wap.wapp.core.model.user.UserProfile + data class UserProfileResponse( val userId: String, val userName: String, val studentId: String, val registeredAt: String, -) +) { + constructor() : this( + "", + "", + "", + "", + ) + + fun toDomain(): UserProfile = UserProfile( + userId = userId, + userName = userName, + studentId = studentId, + registeredAt = registeredAt, + ) +} From d797c8d39426298bf4e6c51a7c2f52d0bb97c2ba Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 10 Oct 2023 15:59:41 +0900 Subject: [PATCH 04/19] =?UTF-8?q?[FEATURE]=20#15=20:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=20Profile=20Domain=20Model=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/wap/wapp/core/model/user/UserProfile.kt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 core/model/src/main/java/com/wap/wapp/core/model/user/UserProfile.kt diff --git a/core/model/src/main/java/com/wap/wapp/core/model/user/UserProfile.kt b/core/model/src/main/java/com/wap/wapp/core/model/user/UserProfile.kt new file mode 100644 index 00000000..dfa5cd61 --- /dev/null +++ b/core/model/src/main/java/com/wap/wapp/core/model/user/UserProfile.kt @@ -0,0 +1,8 @@ +package com.wap.wapp.core.model.user + +data class UserProfile( + val userId: String, + val userName: String, + val studentId: String, + val registeredAt: String, +) From 862c900718e574fcd2da2dcbcf8ace46cc058d2b Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 10 Oct 2023 16:00:49 +0900 Subject: [PATCH 05/19] =?UTF-8?q?[FEATURE]=20#15=20:=20=EC=B5=9C=EC=B4=88?= =?UTF-8?q?=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EC=9D=B4=EB=84=98=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/wap/wapp/core/domain/model/AuthState.kt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/model/AuthState.kt diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/model/AuthState.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/model/AuthState.kt new file mode 100644 index 00000000..e603e17d --- /dev/null +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/model/AuthState.kt @@ -0,0 +1,5 @@ +package com.wap.wapp.core.domain.model + +enum class AuthState { + SIGN_IN, SIGN_UP +} From 6831237e9be25f9315b9781bc112115cb877a14d Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 10 Oct 2023 16:01:14 +0900 Subject: [PATCH 06/19] =?UTF-8?q?[CHORE]=20#15=20:=20network=20->=20model?= =?UTF-8?q?=20=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/network/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/network/build.gradle.kts b/core/network/build.gradle.kts index e9672135..ac30dff5 100644 --- a/core/network/build.gradle.kts +++ b/core/network/build.gradle.kts @@ -23,6 +23,7 @@ android { } dependencies { + implementation(project(":core:model")) implementation(platform(libs.firebase.bom)) implementation(libs.firebase.auth) implementation(libs.firebase.firestore) From 813096d6f725af9ab514eae563d8c8293866ec38 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 10 Oct 2023 16:05:37 +0900 Subject: [PATCH 07/19] =?UTF-8?q?[FEATURE]=20#15=20:=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=95=84=EC=9B=83,=20=ED=9A=8C=EC=9B=90=20=ED=83=88=ED=87=B4?= =?UTF-8?q?=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/data/repository/auth/AuthRepository.kt | 4 ++++ .../data/repository/auth/AuthRepositoryImpl.kt | 8 ++++++++ .../domain/usecase/auth/DeleteUserUseCase.kt | 11 +++++++++++ .../core/domain/usecase/auth/SignOutUseCase.kt | 11 +++++++++++ .../core/network/source/auth/AuthDataSource.kt | 4 +--- .../network/source/auth/AuthDataSourceImpl.kt | 17 ++++++++++------- 6 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/DeleteUserUseCase.kt create mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignOutUseCase.kt 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 20c718ec..1c423020 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 @@ -4,4 +4,8 @@ interface AuthRepository { suspend fun hasPendingResult(): Boolean suspend fun signIn(email: String): Result + + suspend fun signOut(): Result + + suspend fun deleteUser(): 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 01146642..e7b7815f 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 @@ -13,4 +13,12 @@ class AuthRepositoryImpl @Inject constructor( override suspend fun signIn(email: String): Result { return authDataSource.signIn(email) } + + override suspend fun signOut(): Result { + return authDataSource.signOut() + } + + override suspend fun deleteUser(): Result { + return authDataSource.deleteUser() + } } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/DeleteUserUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/DeleteUserUseCase.kt new file mode 100644 index 00000000..0df68d2d --- /dev/null +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/DeleteUserUseCase.kt @@ -0,0 +1,11 @@ +package com.wap.wapp.core.domain.usecase.auth + +import com.wap.wapp.core.data.repository.auth.AuthRepository +import javax.inject.Inject + +class DeleteUserUseCase @Inject constructor( + private val authRepository: AuthRepository, +) { + suspend operator fun invoke(): Result = + authRepository.deleteUser() +} diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignOutUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignOutUseCase.kt new file mode 100644 index 00000000..814c4cb9 --- /dev/null +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignOutUseCase.kt @@ -0,0 +1,11 @@ +package com.wap.wapp.core.domain.usecase.auth + +import com.wap.wapp.core.data.repository.auth.AuthRepository +import javax.inject.Inject + +class SignOutUseCase @Inject constructor( + private val authRepository: AuthRepository, +) { + suspend operator fun invoke(): Result = + authRepository.signOut() +} 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 8a8009bf..d728e538 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 @@ -5,9 +5,7 @@ interface AuthDataSource { suspend fun signIn(email: String): Result - suspend fun signUp(): Result - suspend fun signOut(): Result - suspend fun resign(): Result + suspend fun deleteUser(): 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 30c73bc4..09b5a1d6 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 @@ -33,15 +33,18 @@ class AuthDataSourceImpl @Inject constructor( } } - override suspend fun signUp(): Result { - TODO("Not yet implemented") - } - override suspend fun signOut(): Result { - TODO("Not yet implemented") + return runCatching { + firebaseAuth.signOut() + } } - override suspend fun resign(): Result { - TODO("Not yet implemented") + override suspend fun deleteUser(): Result { + return runCatching { + val user = checkNotNull(firebaseAuth.currentUser) + + user.delete() + .await() + } } } From cc328e64101dcbaeb956d76dca529ab06eb87863 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 10 Oct 2023 16:06:12 +0900 Subject: [PATCH 08/19] =?UTF-8?q?[CHORE]=20#15=20:=20=EA=B2=BD=EB=A1=9C=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95=20repository/di=20->=20?= =?UTF-8?q?di?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/core/data/{repository => }/di/AuthRepositoryModule.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename core/data/src/main/java/com/wap/wapp/core/data/{repository => }/di/AuthRepositoryModule.kt (92%) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/di/AuthRepositoryModule.kt b/core/data/src/main/java/com/wap/wapp/core/data/di/AuthRepositoryModule.kt similarity index 92% rename from core/data/src/main/java/com/wap/wapp/core/data/repository/di/AuthRepositoryModule.kt rename to core/data/src/main/java/com/wap/wapp/core/data/di/AuthRepositoryModule.kt index 799eddcb..4b8f157e 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/di/AuthRepositoryModule.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/di/AuthRepositoryModule.kt @@ -1,4 +1,4 @@ -package com.wap.wapp.core.data.repository.di +package com.wap.wapp.core.data.di import com.wap.wapp.core.data.repository.auth.AuthRepository import com.wap.wapp.core.data.repository.auth.AuthRepositoryImpl From f52cc7710757712c6bbe83608598b8bfe16eaa41 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 10 Oct 2023 16:06:42 +0900 Subject: [PATCH 09/19] =?UTF-8?q?[CHORE]=20#15=20:=20Firebase=20Collection?= =?UTF-8?q?=20Constant=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/wapp/core/network/constant/FirebaseConstant.kt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 core/network/src/main/java/com/wap/wapp/core/network/constant/FirebaseConstant.kt diff --git a/core/network/src/main/java/com/wap/wapp/core/network/constant/FirebaseConstant.kt b/core/network/src/main/java/com/wap/wapp/core/network/constant/FirebaseConstant.kt new file mode 100644 index 00000000..e41885d6 --- /dev/null +++ b/core/network/src/main/java/com/wap/wapp/core/network/constant/FirebaseConstant.kt @@ -0,0 +1,6 @@ +package com.wap.wapp.core.network.constant + +/* +파이어스토어 유저 컬렉션 +*/ +const val USER_COLLECTION = "users" From 0583a2099055183c480ced6fba50d72c8c811cc9 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 10 Oct 2023 16:08:29 +0900 Subject: [PATCH 10/19] =?UTF-8?q?[FEATURE]=20#15=20:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=20=EB=93=B1=EB=A1=9D=20/=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=20=EC=A1=B0=ED=9A=8C=20=EB=A1=9C=EC=A7=81=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/repository/user/UserRepository.kt | 14 ++++++ .../repository/user/UserRepositoryImpl.kt | 32 ++++++++++++++ .../network/source/user/UserDataSource.kt | 3 ++ .../network/source/user/UserDataSourceImpl.kt | 43 ++++++++++++++++++- 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 core/data/src/main/java/com/wap/wapp/core/data/repository/user/UserRepository.kt create mode 100644 core/data/src/main/java/com/wap/wapp/core/data/repository/user/UserRepositoryImpl.kt diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/user/UserRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/user/UserRepository.kt new file mode 100644 index 00000000..f5039061 --- /dev/null +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/user/UserRepository.kt @@ -0,0 +1,14 @@ +package com.wap.wapp.core.data.repository.user + +import com.wap.wapp.core.model.user.UserProfile + +interface UserRepository { + suspend fun getUserProfile(userId: String): Result + + suspend fun postUserProfile( + userId: String, + userName: String, + studentId: String, + registeredAt: String, + ): Result +} diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/user/UserRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/user/UserRepositoryImpl.kt new file mode 100644 index 00000000..0490832c --- /dev/null +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/user/UserRepositoryImpl.kt @@ -0,0 +1,32 @@ +package com.wap.wapp.core.data.repository.user + +import com.wap.wapp.core.model.user.UserProfile +import com.wap.wapp.core.network.model.user.UserProfileRequest +import com.wap.wapp.core.network.source.user.UserDataSource +import javax.inject.Inject + +class UserRepositoryImpl @Inject constructor( + private val userDataSource: UserDataSource, +) : UserRepository { + override suspend fun getUserProfile(userId: String): Result { + return userDataSource.getUserProfile(userId).mapCatching { response -> + response.toDomain() + } + } + + override suspend fun postUserProfile( + userId: String, + userName: String, + studentId: String, + registeredAt: String, + ): Result { + return userDataSource.postUserProfile( + UserProfileRequest( + userId = userId, + userName = userName, + studentId = studentId, + registeredAt = registeredAt, + ), + ) + } +} diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSource.kt index 749533b3..4b261118 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSource.kt @@ -1,7 +1,10 @@ package com.wap.wapp.core.network.source.user +import com.wap.wapp.core.network.model.user.UserProfileRequest import com.wap.wapp.core.network.model.user.UserProfileResponse interface UserDataSource { + suspend fun postUserProfile(userProfileRequest: UserProfileRequest): Result + suspend fun getUserProfile(userId: String): Result } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt index c40fc34c..093318d1 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt @@ -1,3 +1,44 @@ package com.wap.wapp.core.network.source.user -class UserDataSourceImpl +import com.google.firebase.firestore.FirebaseFirestore +import com.google.firebase.firestore.SetOptions +import com.wap.wapp.core.network.constant.USER_COLLECTION +import com.wap.wapp.core.network.model.user.UserProfileRequest +import com.wap.wapp.core.network.model.user.UserProfileResponse +import com.wap.wapp.core.network.utils.await +import javax.inject.Inject + +class UserDataSourceImpl @Inject constructor( + private val firebaseFirestore: FirebaseFirestore, +) : UserDataSource { + override suspend fun postUserProfile( + userProfileRequest: UserProfileRequest, + ): Result { + return runCatching { + val userId = userProfileRequest.userId + val setOption = SetOptions.merge() + + firebaseFirestore.collection(USER_COLLECTION) + .document(userId) + .set( + userProfileRequest, + setOption, + ) + .await() + } + } + + override suspend fun getUserProfile( + userId: String, + ): Result { + return runCatching { + val result = firebaseFirestore.collection(USER_COLLECTION) + .document(userId) + .get() + .await() + + val userProfile = result.toObject(UserProfileResponse::class.java) + checkNotNull(userProfile) + } + } +} From 734a5ab711ac0b5948d534c1e848c481d9376b23 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 10 Oct 2023 16:08:58 +0900 Subject: [PATCH 11/19] =?UTF-8?q?[FEATURE]=20#15=20:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=20=EB=93=B1=EB=A1=9D=20=EC=9C=A0=EC=8A=A4=EC=BC=80?= =?UTF-8?q?=EC=9D=B4=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/user/PostUserProfileUseCase.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/PostUserProfileUseCase.kt diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/PostUserProfileUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/PostUserProfileUseCase.kt new file mode 100644 index 00000000..9377f5d6 --- /dev/null +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/PostUserProfileUseCase.kt @@ -0,0 +1,22 @@ +package com.wap.wapp.core.domain.usecase.user + +import com.wap.wapp.core.data.repository.user.UserRepository +import javax.inject.Inject + +class PostUserProfileUseCase @Inject constructor( + private val userRepository: UserRepository, +) { + suspend operator fun invoke( + userId: String, + userName: String, + studentId: String, + registeredAt: String, + ): Result { + return userRepository.postUserProfile( + userId = userId, + userName = userName, + studentId = studentId, + registeredAt = registeredAt, + ) + } +} From 53bc9a91d2cc6a3ce7041ef36f7a50b9ee8bdd68 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 10 Oct 2023 16:09:11 +0900 Subject: [PATCH 12/19] =?UTF-8?q?[FEATURE]=20#15=20:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20=EC=9C=A0?= =?UTF-8?q?=EC=8A=A4=EC=BC=80=EC=9D=B4=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/core/domain/auth/SignInUseCase.kt | 13 -------- .../core/domain/usecase/auth/SignInUseCase.kt | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 13 deletions(-) delete mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/auth/SignInUseCase.kt create mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/auth/SignInUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/auth/SignInUseCase.kt deleted file mode 100644 index 5677fe94..00000000 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/auth/SignInUseCase.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.wap.wapp.core.domain.auth - -import com.wap.wapp.core.data.repository.auth.AuthRepository -import dagger.hilt.android.scopes.ActivityScoped -import javax.inject.Inject - -@ActivityScoped -class SignInUseCase @Inject constructor( - private val repository: AuthRepository, -) { - suspend operator fun invoke(email: String): Result = - repository.signIn(email) -} diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt new file mode 100644 index 00000000..dd7eea6c --- /dev/null +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt @@ -0,0 +1,33 @@ +package com.wap.wapp.core.domain.usecase.auth + +import com.wap.wapp.core.data.repository.auth.AuthRepository +import com.wap.wapp.core.data.repository.user.UserRepository +import com.wap.wapp.core.domain.model.AuthState +import com.wap.wapp.core.domain.model.AuthState.SIGN_IN +import com.wap.wapp.core.domain.model.AuthState.SIGN_UP +import dagger.hilt.android.scopes.ActivityScoped +import javax.inject.Inject + +@ActivityScoped +class SignInUseCase @Inject constructor( + private val authRepository: AuthRepository, + private val userRepository: UserRepository, +) { + suspend operator fun invoke(email: String): Result { + return runCatching { + val userId = authRepository.signIn(email) + .getOrThrow() + + userRepository.getUserProfile(userId) + .onFailure { exception -> + // 만약 사용자를 찾을 수 없는 경우, 회원가입 + val userNotFoundException = IllegalStateException() + if (exception == userNotFoundException) { + return Result.success(SIGN_UP) + } + } + // 사용자를 찾은 경우, 로그인 + SIGN_IN + } + } +} From 8f5c8969ff4d771b1cd60ae9c9f0811c2bfc39f5 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 10 Oct 2023 16:09:49 +0900 Subject: [PATCH 13/19] =?UTF-8?q?[FEATURE]=20#15=20:=20data=20module=20?= =?UTF-8?q?=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=A3=BC=EC=9E=85=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/wapp/core/data/di/DataModule.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 core/data/src/main/java/com/wap/wapp/core/data/di/DataModule.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 new file mode 100644 index 00000000..2ebbd53d --- /dev/null +++ b/core/data/src/main/java/com/wap/wapp/core/data/di/DataModule.kt @@ -0,0 +1,19 @@ +package com.wap.wapp.core.data.di + +import com.wap.wapp.core.data.repository.user.UserRepository +import com.wap.wapp.core.data.repository.user.UserRepositoryImpl +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +abstract class DataModule { + @Binds + @Singleton + abstract fun providesUserRepository( + userRepositoryImpl: UserRepositoryImpl, + ): UserRepository +} From ac34d9d38f949994cf1a2c95d716fbe225579222 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 10 Oct 2023 16:10:47 +0900 Subject: [PATCH 14/19] =?UTF-8?q?[CHORE]=20#15=20:=20idea=20project=20info?= =?UTF-8?q?=20=EC=9E=90=EB=A3=8C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/codeStyles/Project.xml | 117 +++++++++++++++++++++++++++ .idea/codeStyles/codeStyleConfig.xml | 5 ++ .idea/dictionaries/jaino.xml | 3 + 3 files changed, 125 insertions(+) create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/dictionaries/jaino.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 00000000..4bec4ea8 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,117 @@ + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 00000000..a55e7a17 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/dictionaries/jaino.xml b/.idea/dictionaries/jaino.xml new file mode 100644 index 00000000..8bf92705 --- /dev/null +++ b/.idea/dictionaries/jaino.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file From 9d05983fc612e52e4ab080feb8b8e044f6102408 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Wed, 11 Oct 2023 12:57:24 +0900 Subject: [PATCH 15/19] =?UTF-8?q?[REFACTOR]=20#15=20:=20SignInUseCase=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95=20-=20Result.fold=20?= =?UTF-8?q?=ED=99=9C=EC=9A=A9=EC=9C=BC=EB=A1=9C=20=EC=84=B1=EA=B3=B5=20?= =?UTF-8?q?=EC=BC=80=EC=9D=B4=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20=EB=B0=8F=20=EC=8B=A4=ED=8C=A8=20=EC=BC=80=EC=9D=B4?= =?UTF-8?q?=EC=8A=A4=20=EC=97=90=EB=9F=AC=20=EB=8D=98=EC=A7=80=EB=8A=94=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/domain/usecase/auth/SignInUseCase.kt | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt index dd7eea6c..c3ca0b45 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt @@ -19,15 +19,20 @@ class SignInUseCase @Inject constructor( .getOrThrow() userRepository.getUserProfile(userId) - .onFailure { exception -> - // 만약 사용자를 찾을 수 없는 경우, 회원가입 - val userNotFoundException = IllegalStateException() - if (exception == userNotFoundException) { - return Result.success(SIGN_UP) - } - } - // 사용자를 찾은 경우, 로그인 - SIGN_IN + .fold( + onFailure = { exception -> + // + val userNotFoundException = IllegalStateException() + if (exception == userNotFoundException) { + SIGN_UP + } + // 이외의 예외라면, + throw (exception) + }, + onSuccess = { + SIGN_IN + }, + ) } } } From b8047375637a79bcc44a88a44af39f200112f8f2 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Wed, 11 Oct 2023 12:58:25 +0900 Subject: [PATCH 16/19] =?UTF-8?q?[REFACTOR]=20#15=20:=20SignInUseCase=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95=20-=20Result.fold=20?= =?UTF-8?q?=ED=99=9C=EC=9A=A9=EC=9C=BC=EB=A1=9C=20=EC=84=B1=EA=B3=B5=20?= =?UTF-8?q?=EC=BC=80=EC=9D=B4=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20=EB=B0=8F=20=EC=8B=A4=ED=8C=A8=20=EC=BC=80=EC=9D=B4?= =?UTF-8?q?=EC=8A=A4=20=EC=97=90=EB=9F=AC=20=EB=8D=98=EC=A7=80=EB=8A=94=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt index c3ca0b45..04df5309 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt @@ -21,7 +21,7 @@ class SignInUseCase @Inject constructor( userRepository.getUserProfile(userId) .fold( onFailure = { exception -> - // + // 사용자를 조회할 수 없는 예외인 경우 val userNotFoundException = IllegalStateException() if (exception == userNotFoundException) { SIGN_UP From 2ea8d7b761b5efba64cb25db4116af61c1907534 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Wed, 11 Oct 2023 13:09:05 +0900 Subject: [PATCH 17/19] =?UTF-8?q?[STYLE]=20#15=20:=20Request=20Model=20?= =?UTF-8?q?=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EB=84=A4=EC=9D=B4?= =?UTF-8?q?=EB=B0=8D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/wapp/core/network/source/user/UserDataSource.kt | 2 +- .../wap/wapp/core/network/source/user/UserDataSourceImpl.kt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSource.kt index 4b261118..da459e3a 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSource.kt @@ -4,7 +4,7 @@ import com.wap.wapp.core.network.model.user.UserProfileRequest import com.wap.wapp.core.network.model.user.UserProfileResponse interface UserDataSource { - suspend fun postUserProfile(userProfileRequest: UserProfileRequest): Result + suspend fun postUserProfile(userProfile: UserProfileRequest): Result suspend fun getUserProfile(userId: String): Result } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt index 093318d1..a77fca66 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt @@ -12,16 +12,16 @@ class UserDataSourceImpl @Inject constructor( private val firebaseFirestore: FirebaseFirestore, ) : UserDataSource { override suspend fun postUserProfile( - userProfileRequest: UserProfileRequest, + userProfile: UserProfileRequest, ): Result { return runCatching { - val userId = userProfileRequest.userId + val userId = userProfile.userId val setOption = SetOptions.merge() firebaseFirestore.collection(USER_COLLECTION) .document(userId) .set( - userProfileRequest, + userProfile, setOption, ) .await() From b3b893707868c673dbeb48ad2adcb532b43408f4 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Wed, 11 Oct 2023 13:17:45 +0900 Subject: [PATCH 18/19] =?UTF-8?q?[STYLE]=20#15=20:=20Request=20Model=20?= =?UTF-8?q?=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EB=84=A4=EC=9D=B4?= =?UTF-8?q?=EB=B0=8D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/wapp/core/network/source/user/UserDataSource.kt | 2 +- .../wap/wapp/core/network/source/user/UserDataSourceImpl.kt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSource.kt index da459e3a..4b261118 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSource.kt @@ -4,7 +4,7 @@ import com.wap.wapp.core.network.model.user.UserProfileRequest import com.wap.wapp.core.network.model.user.UserProfileResponse interface UserDataSource { - suspend fun postUserProfile(userProfile: UserProfileRequest): Result + suspend fun postUserProfile(userProfileRequest: UserProfileRequest): Result suspend fun getUserProfile(userId: String): Result } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt index a77fca66..093318d1 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt @@ -12,16 +12,16 @@ class UserDataSourceImpl @Inject constructor( private val firebaseFirestore: FirebaseFirestore, ) : UserDataSource { override suspend fun postUserProfile( - userProfile: UserProfileRequest, + userProfileRequest: UserProfileRequest, ): Result { return runCatching { - val userId = userProfile.userId + val userId = userProfileRequest.userId val setOption = SetOptions.merge() firebaseFirestore.collection(USER_COLLECTION) .document(userId) .set( - userProfile, + userProfileRequest, setOption, ) .await() From 1c75ae297f30495e7db5256cf9f105c6e3439579 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Wed, 11 Oct 2023 13:45:11 +0900 Subject: [PATCH 19/19] =?UTF-8?q?[CHORE]=20#15=20:=20usecase=20-=20Singlet?= =?UTF-8?q?on=20Annotation=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/wapp/core/domain/usecase/auth/DeleteUserUseCase.kt | 2 ++ .../com/wap/wapp/core/domain/usecase/auth/SignOutUseCase.kt | 2 ++ .../wap/wapp/core/domain/usecase/user/PostUserProfileUseCase.kt | 2 ++ 3 files changed, 6 insertions(+) diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/DeleteUserUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/DeleteUserUseCase.kt index 0df68d2d..3c08f196 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/DeleteUserUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/DeleteUserUseCase.kt @@ -2,7 +2,9 @@ package com.wap.wapp.core.domain.usecase.auth import com.wap.wapp.core.data.repository.auth.AuthRepository import javax.inject.Inject +import javax.inject.Singleton +@Singleton class DeleteUserUseCase @Inject constructor( private val authRepository: AuthRepository, ) { diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignOutUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignOutUseCase.kt index 814c4cb9..eae7758b 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignOutUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignOutUseCase.kt @@ -2,7 +2,9 @@ package com.wap.wapp.core.domain.usecase.auth import com.wap.wapp.core.data.repository.auth.AuthRepository import javax.inject.Inject +import javax.inject.Singleton +@Singleton class SignOutUseCase @Inject constructor( private val authRepository: AuthRepository, ) { diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/PostUserProfileUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/PostUserProfileUseCase.kt index 9377f5d6..136b9ddc 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/PostUserProfileUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/PostUserProfileUseCase.kt @@ -2,7 +2,9 @@ package com.wap.wapp.core.domain.usecase.user import com.wap.wapp.core.data.repository.user.UserRepository import javax.inject.Inject +import javax.inject.Singleton +@Singleton class PostUserProfileUseCase @Inject constructor( private val userRepository: UserRepository, ) {