From 71c7880582be2991b65bbf9579813e6e487697ee Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 20 Sep 2019 13:21:24 +0600 Subject: [PATCH] rewrite posts api to be result of write and read posts apis --- .../postssystem/core/api/PostsAPI.kt | 14 +------------- .../postssystem/core/api/ReadPostsAPI.kt | 15 +++++++++++++++ .../api/{MutablePostsAPI.kt => WritePostsAPI.kt} | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/ReadPostsAPI.kt rename src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/{MutablePostsAPI.kt => WritePostsAPI.kt} (94%) diff --git a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/PostsAPI.kt b/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/PostsAPI.kt index df7633f5..229d791e 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/PostsAPI.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/PostsAPI.kt @@ -1,15 +1,3 @@ package com.github.insanusmokrassar.postssystem.core.api -import com.github.insanusmokrassar.postssystem.core.post.Post -import com.github.insanusmokrassar.postssystem.core.post.PostId -import com.github.insanusmokrassar.postssystem.core.content.ContentId -import com.github.insanusmokrassar.postssystem.core.utils.pagination.* -import org.joda.time.DateTime - -interface PostsAPI { - suspend fun getPostById(id: PostId): Post? - suspend fun getPostsByContent(id: ContentId): List - suspend fun getPostsByDates(from: DateTime? = null, to: DateTime? = null): List - - suspend fun getPostsByPagination(pagination: Pagination): PaginationResult -} \ No newline at end of file +interface PostsAPI : ReadPostsAPI, WritePostsAPI diff --git a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/ReadPostsAPI.kt b/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/ReadPostsAPI.kt new file mode 100644 index 00000000..33da29af --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/ReadPostsAPI.kt @@ -0,0 +1,15 @@ +package com.github.insanusmokrassar.postssystem.core.api + +import com.github.insanusmokrassar.postssystem.core.post.Post +import com.github.insanusmokrassar.postssystem.core.post.PostId +import com.github.insanusmokrassar.postssystem.core.content.ContentId +import com.github.insanusmokrassar.postssystem.core.utils.pagination.* +import org.joda.time.DateTime + +interface ReadPostsAPI { + suspend fun getPostById(id: PostId): Post? + suspend fun getPostsByContent(id: ContentId): List + suspend fun getPostsByDates(from: DateTime? = null, to: DateTime? = null): List + + suspend fun getPostsByPagination(pagination: Pagination): PaginationResult +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/MutablePostsAPI.kt b/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/WritePostsAPI.kt similarity index 94% rename from src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/MutablePostsAPI.kt rename to src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/WritePostsAPI.kt index 847c527f..cde400d9 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/MutablePostsAPI.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/WritePostsAPI.kt @@ -3,7 +3,7 @@ package com.github.insanusmokrassar.postssystem.core.api import com.github.insanusmokrassar.postssystem.core.post.* import kotlinx.coroutines.flow.Flow -interface MutablePostsAPI { +interface WritePostsAPI { val postCreatedFlow: Flow val postDeletedFlow: Flow val postUpdatedFlow: Flow