Skip to content

Commit b51019f

Browse files
committed
✨ 그룹 이름 중복확인 로직 추가
1 parent 40007b3 commit b51019f

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

data/src/main/java/com/whyranoid/data/group/GroupDataSource.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import kotlinx.coroutines.channels.awaitClose
2020
import kotlinx.coroutines.flow.Flow
2121
import kotlinx.coroutines.flow.callbackFlow
2222
import kotlinx.coroutines.suspendCancellableCoroutine
23+
import kotlinx.coroutines.tasks.await
2324
import java.util.UUID
2425
import javax.inject.Inject
2526
import kotlin.coroutines.resume
@@ -152,4 +153,13 @@ class GroupDataSource @Inject constructor(
152153
}
153154
awaitClose()
154155
}
156+
157+
suspend fun isDuplicatedGroupName(groupName: String): Boolean {
158+
return db.collection(GROUPS_COLLECTION)
159+
.whereEqualTo(GROUP_NAME, groupName)
160+
.get()
161+
.await()
162+
.isEmpty
163+
.not()
164+
}
155165
}

data/src/main/java/com/whyranoid/data/group/GroupRepositoryImpl.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,8 @@ class GroupRepositoryImpl @Inject constructor(
5858
): Boolean {
5959
return groupDataSource.createGroup(groupName, introduce, rules, uid)
6060
}
61+
62+
override suspend fun isDuplicatedGroupName(groupName: String): Boolean {
63+
return groupDataSource.isDuplicatedGroupName(groupName)
64+
}
6165
}

domain/src/main/java/com/whyranoid/domain/repository/GroupRepository.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ interface GroupRepository {
4040
rules: List<String>,
4141
uid: String
4242
): Boolean
43+
44+
suspend fun isDuplicatedGroupName(groupName: String): Boolean
4345
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.whyranoid.domain.usecase
2+
3+
import com.whyranoid.domain.repository.GroupRepository
4+
import javax.inject.Inject
5+
6+
class CheckIsDuplicatedGroupNameUseCase @Inject constructor(
7+
private val groupRepository: GroupRepository
8+
) {
9+
10+
suspend operator fun invoke(groupName: String): Boolean {
11+
return groupRepository.isDuplicatedGroupName(groupName)
12+
}
13+
}

0 commit comments

Comments
 (0)