add getting of posts by page
This commit is contained in:
parent
2d5189ce0a
commit
9c1bffab41
@ -3,10 +3,13 @@ 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<Post>
|
||||
suspend fun getPostsByDates(from: DateTime? = null, to: DateTime? = null): List<Post>
|
||||
|
||||
suspend fun getPostsByPagination(pagination: Pagination): PaginationResult<Post>
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.github.insanusmokrassar.postssystem.core.utils.pagination
|
||||
|
||||
interface Pagination {
|
||||
val page: Int
|
||||
val size: Int
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.github.insanusmokrassar.postssystem.core.utils.pagination
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class PaginationRequest(
|
||||
override val page: Int,
|
||||
override val size: Int
|
||||
) : Pagination
|
@ -0,0 +1,14 @@
|
||||
package com.github.insanusmokrassar.postssystem.core.utils.pagination
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Transient
|
||||
|
||||
@Serializable
|
||||
data class PaginationResult<T>(
|
||||
override val page: Int,
|
||||
val pagesNumber: Int,
|
||||
val results: List<T>
|
||||
) : Pagination {
|
||||
@Transient
|
||||
override val size: Int = results.size
|
||||
}
|
Loading…
Reference in New Issue
Block a user