Update pagination.go

pull/779/head
wangbin13 2022-03-06 14:18:24 +08:00
parent 0d0582c37c
commit a97eb0adb1
1 changed files with 26 additions and 0 deletions

View File

@ -132,3 +132,29 @@ func (p *Pagination) getLang() string {
}
return ulang
}
type Page struct {
PageNo int `json:"PageNo"`
PageSize int `json:"PageSize"`
TotalPage int `json:"TotalPage"`
TotalCount int `json:"TotalCount"`
FirstPage bool `json:"FirstPage"`
LastPage bool `json:"LastPage"`
List interface{} `json:"List"`
}
func PageUtil(count int, pageNo int, pageSize int, list interface{}) Page {
tp := count / pageSize
if count%pageSize > 0 {
tp = count/pageSize + 1
}
return Page {
PageNo: pageNo,
PageSize: pageSize,
TotalPage: tp,
TotalCount: count,
FirstPage: pageNo == 1,
LastPage: pageNo == tp,
List: list,
}
}