From ac6b183c4405b975e020fae6d497b32a9234a29b Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 21 Oct 2023 14:19:42 +0900 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20#32=20:=20=EB=A7=A4=EB=8B=88?= =?UTF-8?q?=EC=A0=80=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 --- .../repository/manage/ManageRepository.kt | 5 +++++ .../repository/manage/ManageRepositoryImpl.kt | 12 ++++++++++++ .../network/source/manage/ManageDataSource.kt | 5 +++++ .../source/manage/ManageDataSourceImpl.kt | 19 +++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt create mode 100644 core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt create mode 100644 core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt create mode 100644 core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt new file mode 100644 index 00000000..3d192078 --- /dev/null +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt @@ -0,0 +1,5 @@ +package com.wap.wapp.core.data.repository.manage + +interface ManageRepository { + suspend fun getManager(userId: String): Result +} diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt new file mode 100644 index 00000000..3b44b9ab --- /dev/null +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt @@ -0,0 +1,12 @@ +package com.wap.wapp.core.data.repository.manage + +import com.wap.wapp.core.network.source.manage.ManageDataSource +import javax.inject.Inject + +class ManageRepositoryImpl @Inject constructor( + private val manageDataSource: ManageDataSource, +) : ManageRepository { + override suspend fun getManager(userId: String): Result { + return manageDataSource.getManager(userId) + } +} diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt new file mode 100644 index 00000000..06da4a7f --- /dev/null +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt @@ -0,0 +1,5 @@ +package com.wap.wapp.core.network.source.manage + +interface ManageDataSource { + suspend fun getManager(userId: String): Result +} diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt new file mode 100644 index 00000000..cdf771ad --- /dev/null +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt @@ -0,0 +1,19 @@ +package com.wap.wapp.core.network.source.manage + +import com.google.firebase.firestore.FirebaseFirestore +import com.wap.wapp.core.network.constant.MANAGER_COLLECTION +import com.wap.wapp.core.network.utils.await +import javax.inject.Inject + +class ManageDataSourceImpl @Inject constructor( + private val firebaseFirestore: FirebaseFirestore, +) : ManageDataSource { + override suspend fun getManager(userId: String): Result { + return runCatching { + firebaseFirestore.collection(MANAGER_COLLECTION) + .document(userId) + .get() + .await() + } + } +}