potato/pkg/util/pagination.go

18 lines
283 B
Go

package util
import (
"github.com/com"
"github.com/viletyy/potato/pkg/setting"
"github.com/gin-gonic/gin"
)
func GetPage(c *gin.Context) int {
result := 0
page, _ := com.StrTo(c.Query("page")).Int()
if page > 0 {
result = (page - 1) * setting.PageSize
}
return result
}