com.tianyisoft.database.util.Page.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of querybuilder Show documentation
Show all versions of querybuilder Show documentation
A query builder from laravel
The newest version!
package com.tianyisoft.database.util
import kotlin.math.ceil
class Page: java.io.Serializable {
var data: List = ArrayList()
var meta: Meta = Meta()
companion object {
private const val serialVersionUID: Long = 198912190701L
@JvmStatic
fun new(page: Int, pageSize: Int, total: Long, data: List): Page {
val p = Page()
p.data = data
with(p.meta) {
current = page
size = pageSize
this.total = total
pages = ceil(total / pageSize.toDouble()).toInt()
}
return p
}
@JvmStatic
@JvmOverloads
fun empty(page: Int = 1, pageSize: Int = 15): Page {
return new(page, pageSize, 0, ArrayList())
}
}
}