2020-11-25 08:08:45 +00:00
|
|
|
package dev.inmo.postssystem.core.post.repo
|
2019-10-16 17:46:15 +00:00
|
|
|
|
2020-11-25 08:08:45 +00:00
|
|
|
import dev.inmo.postssystem.core.MAX_DATE
|
|
|
|
import dev.inmo.postssystem.core.MIN_DATE
|
|
|
|
import dev.inmo.postssystem.core.content.ContentId
|
|
|
|
import dev.inmo.postssystem.core.post.PostId
|
|
|
|
import dev.inmo.postssystem.core.post.RegisteredPost
|
2019-11-05 05:26:42 +00:00
|
|
|
import com.soywiz.klock.DateTime
|
2020-11-25 07:53:15 +00:00
|
|
|
import dev.inmo.micro_utils.pagination.*
|
2019-10-16 17:46:15 +00:00
|
|
|
|
2019-11-02 18:32:51 +00:00
|
|
|
/**
|
|
|
|
* Simple read API by different properties
|
|
|
|
*/
|
2020-07-30 09:28:11 +00:00
|
|
|
interface ReadPostsRepo {
|
2019-11-11 03:21:23 +00:00
|
|
|
/**
|
|
|
|
* @return [Set] of [PostId]s which can be used to get data using [getPostById]
|
|
|
|
*/
|
|
|
|
suspend fun getPostsIds(): Set<PostId>
|
|
|
|
|
2019-11-02 18:32:51 +00:00
|
|
|
/**
|
|
|
|
* @return [RegisteredPost] if it is available by [id]
|
|
|
|
*/
|
2019-10-19 10:58:49 +00:00
|
|
|
suspend fun getPostById(id: PostId): RegisteredPost?
|
2019-11-02 18:32:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return all [RegisteredPost]s which contains content with specified content [id]
|
|
|
|
*/
|
2019-10-19 10:58:49 +00:00
|
|
|
suspend fun getPostsByContent(id: ContentId): List<RegisteredPost>
|
2019-11-02 18:32:51 +00:00
|
|
|
|
|
|
|
/**
|
2019-11-11 04:02:37 +00:00
|
|
|
* @return all [RegisteredPost]s which was registered between [from] and [to]. Range will be used INCLUSIVE, line \[[from], [to]\]
|
2019-11-02 18:32:51 +00:00
|
|
|
*/
|
2020-08-11 16:15:07 +00:00
|
|
|
suspend fun getPostsByCreatingDates(
|
|
|
|
from: DateTime = MIN_DATE,
|
|
|
|
to: DateTime = MAX_DATE,
|
|
|
|
pagination: Pagination = FirstPagePagination()
|
|
|
|
): PaginationResult<RegisteredPost>
|
2019-10-16 17:46:15 +00:00
|
|
|
|
2019-11-02 18:32:51 +00:00
|
|
|
/**
|
|
|
|
* @return all posts by pages basing on their creation date
|
|
|
|
*/
|
2019-11-24 19:15:31 +00:00
|
|
|
suspend fun getPostsByPagination(pagination: Pagination): PaginationResult<RegisteredPost>
|
2019-11-04 14:54:08 +00:00
|
|
|
}
|
|
|
|
|
2020-07-30 09:28:11 +00:00
|
|
|
suspend fun ReadPostsRepo.getPostsByCreatingDates(
|
2019-11-04 14:54:08 +00:00
|
|
|
from: DateTime? = null,
|
2020-08-11 16:15:07 +00:00
|
|
|
to: DateTime? = null,
|
|
|
|
pagination: Pagination = FirstPagePagination()
|
2019-11-11 04:02:37 +00:00
|
|
|
) = getPostsByCreatingDates(
|
2019-11-04 14:54:08 +00:00
|
|
|
from ?: MIN_DATE,
|
2020-08-11 16:15:07 +00:00
|
|
|
to ?: MAX_DATE,
|
|
|
|
pagination
|
2019-11-04 14:54:08 +00:00
|
|
|
)
|