create comment.toOutput()
This commit is contained in:
16
src/main/kotlin/fr/dcproject/common/response/Paginated.kt
Normal file
16
src/main/kotlin/fr/dcproject/common/response/Paginated.kt
Normal file
@@ -0,0 +1,16 @@
|
||||
package fr.dcproject.common.response
|
||||
|
||||
import fr.dcproject.common.entity.EntityI
|
||||
import fr.postgresjson.connexion.Paginated
|
||||
|
||||
fun <E : EntityI> Paginated<E>.toOutput(setup: (E) -> Any): Any {
|
||||
return object {
|
||||
val count = this@toOutput.count
|
||||
val currentPage = this@toOutput.count
|
||||
val limit = this@toOutput.limit
|
||||
val offset = this@toOutput.offset
|
||||
val total = this@toOutput.total
|
||||
val totalPages = this@toOutput.totalPages
|
||||
val result = this@toOutput.result.map { setup(it) }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user