File tree Expand file tree Collapse file tree 4 files changed +37
-10
lines changed
data/src/main/java/com/whyranoid/data Expand file tree Collapse file tree 4 files changed +37
-10
lines changed Original file line number Diff line number Diff line change 1
1
package com.whyranoid.data.di
2
2
3
+ import com.whyranoid.data.post.PostDataSource
4
+ import com.whyranoid.data.post.PostDataSourceImpl
3
5
import com.whyranoid.data.post.PostRepositoryImpl
4
6
import com.whyranoid.domain.repository.PostRepository
5
7
import dagger.Binds
@@ -11,6 +13,9 @@ import dagger.hilt.components.SingletonComponent
11
13
@InstallIn(SingletonComponent ::class )
12
14
abstract class PostModule {
13
15
16
+ @Binds
17
+ abstract fun bindPostDataSource (postDataSourceImpl : PostDataSourceImpl ): PostDataSource
18
+
14
19
@Binds
15
20
abstract fun bindPostRepository (postRepositoryImpl : PostRepositoryImpl ): PostRepository
16
21
}
Original file line number Diff line number Diff line change
1
+ package com.whyranoid.data.post
2
+
3
+ import com.whyranoid.domain.model.Post
4
+ import kotlinx.coroutines.flow.Flow
5
+
6
+ interface PostDataSource {
7
+
8
+ fun getAllPostFlow (): Flow <List <Post >>
9
+
10
+ fun getMyPostFlow (uid : String ): Flow <List <Post >>
11
+
12
+ suspend fun createRecruitPost (
13
+ authorUid : String ,
14
+ groupUid : String
15
+ ): Boolean
16
+
17
+ suspend fun createRunningPost (
18
+ authorUid : String ,
19
+ runningHistoryId : String ,
20
+ content : String
21
+ ): Result <Boolean >
22
+ }
Original file line number Diff line number Diff line change @@ -27,10 +27,10 @@ import kotlin.coroutines.resume
27
27
28
28
class PostDataSourceImpl @Inject constructor(
29
29
private val db : FirebaseFirestore
30
- ) {
30
+ ) : PostDataSource {
31
31
32
32
// TODO : 조금 더 간결하게 처리 필요.
33
- fun getAllPostFlow (): Flow <List <Post >> =
33
+ override fun getAllPostFlow (): Flow <List <Post >> =
34
34
callbackFlow {
35
35
db.collection(CollectionId .POST_COLLECTION )
36
36
.orderBy(UPDATED_AT , Query .Direction .DESCENDING )
@@ -122,7 +122,7 @@ class PostDataSourceImpl @Inject constructor(
122
122
awaitClose()
123
123
}
124
124
125
- fun getMyPostFlow (uid : String ): Flow <List <Post >> =
125
+ override fun getMyPostFlow (uid : String ): Flow <List <Post >> =
126
126
callbackFlow {
127
127
db.collection(CollectionId .POST_COLLECTION )
128
128
.whereEqualTo(AUTHOR_ID , uid)
@@ -215,7 +215,7 @@ class PostDataSourceImpl @Inject constructor(
215
215
awaitClose()
216
216
}
217
217
218
- suspend fun createRecruitPost (
218
+ override suspend fun createRecruitPost (
219
219
authorUid : String ,
220
220
groupUid : String
221
221
): Boolean {
@@ -240,7 +240,7 @@ class PostDataSourceImpl @Inject constructor(
240
240
}
241
241
}
242
242
243
- suspend fun createRunningPost (
243
+ override suspend fun createRunningPost (
244
244
authorUid : String ,
245
245
runningHistoryId : String ,
246
246
content : String
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import kotlinx.coroutines.flow.Flow
6
6
import javax.inject.Inject
7
7
8
8
class PostRepositoryImpl @Inject constructor(
9
- private val postDataSourceImpl : PostDataSourceImpl
9
+ private val postDataSource : PostDataSource
10
10
) : PostRepository {
11
11
12
12
// TODO : 페이징처리하기
@@ -15,26 +15,26 @@ class PostRepositoryImpl @Inject constructor(
15
15
}
16
16
17
17
override fun getAllPostFlow (): Flow <List <Post >> {
18
- return postDataSourceImpl .getAllPostFlow()
18
+ return postDataSource .getAllPostFlow()
19
19
}
20
20
21
21
override fun getMyPostFlow (uid : String ): Flow <List <Post >> {
22
- return postDataSourceImpl .getMyPostFlow(uid)
22
+ return postDataSource .getMyPostFlow(uid)
23
23
}
24
24
25
25
override suspend fun createRunningPost (
26
26
authorUid : String ,
27
27
runningHistoryId : String ,
28
28
content : String
29
29
): Result <Boolean > {
30
- return postDataSourceImpl .createRunningPost(authorUid, runningHistoryId, content)
30
+ return postDataSource .createRunningPost(authorUid, runningHistoryId, content)
31
31
}
32
32
33
33
override suspend fun createRecruitPost (
34
34
authorUid : String ,
35
35
groupUid : String
36
36
): Boolean {
37
- return postDataSourceImpl .createRecruitPost(authorUid, groupUid)
37
+ return postDataSource .createRecruitPost(authorUid, groupUid)
38
38
}
39
39
40
40
override suspend fun deletePost (postId : String ): Boolean {
You can’t perform that action at this time.
0 commit comments