码农笔录博客源码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 line
680 B

6 年之前
package utils
import (
"strconv"
"fmt"
)
6 年之前
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)
6 年之前
tp := count / pageSize
if count%pageSize > 0 {
tp += 1
}
6 年之前
fmt.Println("tp:", tp, "num", pageNo)
if tp < pageNo {
pageNo = tp
6 年之前
}
6 年之前
if pageNo == 0 {
pageNo = 1
tp = 1
}
fmt.Println("tp:", tp, "num", pageNo)
return &Page{PageNo: pageNo, PageSize: pageSize, TotalPage: tp, TotalCount: count, FirstPage: pageNo == 1, LastPage: pageNo == tp}
6 年之前
}