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