This commit is contained in:
Ashang
2022-04-04 16:01:36 +08:00
commit 20c576b9bc
72 changed files with 4680 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
package page
import "math"
const (
DefaultPageSize = 10
MaxPageSize = 100
DefaultPage = 1
)
type Pagination struct {
CurrentPage int `json:"current_page"` // 当前页码
PerPage int `json:"per_page"` // 当前页行数
TotalPage int `json:"total_page"` // 总页码
Total int64 `json:"total"` // 总行数
}
func GetPagination(page, pageSize int, total int64) Pagination {
return Pagination{
Total: total,
CurrentPage: page,
PerPage: pageSize,
TotalPage: int(math.Ceil(float64(total) / float64(pageSize))),
}
}