2024-07-05 14:41:35 +08:00
|
|
|
package utils
|
|
|
|
|
|
|
|
type paginate struct{}
|
|
|
|
|
|
|
|
func Paginate() paginate {
|
|
|
|
return paginate{}
|
|
|
|
}
|
|
|
|
|
2024-08-09 11:45:32 +08:00
|
|
|
// Generate
|
|
|
|
// @description: 生成页码
|
|
|
|
// @receiver paginate
|
|
|
|
// @param count
|
|
|
|
// @param size
|
|
|
|
// @return int
|
2024-07-05 14:41:35 +08:00
|
|
|
func (paginate) Generate(count int64, size int) int {
|
|
|
|
totalPage := 0
|
|
|
|
if count > 0 {
|
|
|
|
upPage := 0
|
|
|
|
if int(count)%size > 0 {
|
|
|
|
upPage = 1
|
|
|
|
}
|
|
|
|
totalPage = (int(count) / size) + upPage
|
|
|
|
}
|
|
|
|
return totalPage
|
|
|
|
}
|