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.
service/lib/bean/page.go

32 lines
543 B

2 years ago
package bean
type Page struct {
Page int `json:"page"` // 分页
Limit int `json:"limit"` // 分页大小
}
// GetPage @Title 获取页数
func (p *Page) GetPage() int {
if p.Page > 0 {
return p.Page
}
return 1
}
// GetLimit @Title 获取分页大小
func (p *Page) GetLimit() int {
if p.Limit <= 0 {
return 15
}
return p.Limit
}
// GetStart @Title 获取开始坐标
func (p *Page) GetStart() int {
return (p.GetPage() - 1) * p.GetLimit()
}
func (p *Page) HasPage(total int64) bool {
return total > int64(p.GetStart())
}