您最多选择25个主题
主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Page struct {
|
|
|
|
PageNo int
|
|
|
|
PageSize int
|
|
|
|
TotalPage int
|
|
|
|
TotalCount int
|
|
|
|
FirstPage bool
|
|
|
|
LastPage bool
|
|
|
|
List interface{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func PageUtil(count64 int64, pageNo int, pageSize int) *Page {
|
|
|
|
string := strconv.FormatInt(count64, 10)
|
|
|
|
count, _ := strconv.Atoi(string)
|
|
|
|
tp := count / pageSize
|
|
|
|
if count%pageSize > 0 {
|
|
|
|
tp += 1
|
|
|
|
}
|
|
|
|
if tp < pageNo {
|
|
|
|
pageNo = tp
|
|
|
|
}
|
|
|
|
if pageNo == 0 {
|
|
|
|
pageNo = 1
|
|
|
|
tp = 1
|
|
|
|
}
|
|
|
|
return &Page{PageNo: pageNo, PageSize: pageSize, TotalPage: tp, TotalCount: count, FirstPage: pageNo == 1, LastPage: pageNo == tp}
|
|
|
|
}
|