package mtp.polymer.com.automodel

import com.google.gson.annotations.SerializedName

data class PageInfo(
        @SerializedName("totalRow") val totalRow: Int = 0,
        @SerializedName("pageNumber") val pageNumber: Int = 1,
        @SerializedName("totalPage") val totalPage: Int = 1,
        @SerializedName("pageSize") val pageSize: Int = 0
) {
    fun nextPage(): PageInfoParam = PageInfoParam(pageNumber = pageNumber.plus(1).let { if (it > pageSize) pageSize else it }, pageSize = pageSize)

    fun hasNextPage(): Boolean = pageNumber < totalPage

    fun isFirstPage(): Boolean = pageNumber == 1
}

data class PageInfoParam(
        val isCache: Boolean = false,
        @SerializedName("pageNumber") val pageNumber: Int = 1,
        @SerializedName("pageSize") val pageSize: Int = 20
)