mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-08-20 08:14:14 +08:00
Update pagination.go
This commit is contained in:
parent
0d0582c37c
commit
a97eb0adb1
@ -132,3 +132,29 @@ func (p *Pagination) getLang() string {
|
|||||||
}
|
}
|
||||||
return ulang
|
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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user