21 lines
348 B
Go
Raw Normal View History

2022-06-26 19:09:28 +08:00
package common
type PageReq struct {
2022-08-14 23:46:30 +08:00
Page int `json:"page_index" form:"page"`
PerPage int `json:"page_size" form:"per_page"`
2022-06-26 19:09:28 +08:00
}
2022-06-27 19:51:23 +08:00
2022-07-12 18:41:16 +08:00
const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1
2022-06-27 19:51:23 +08:00
func (p *PageReq) Validate() {
2022-08-14 23:46:30 +08:00
if p.Page < 1 {
p.Page = 1
2022-06-27 19:51:23 +08:00
}
2022-08-14 23:46:30 +08:00
if p.PerPage < 1 {
p.PerPage = MaxInt
2022-06-27 19:51:23 +08:00
}
}