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.
23 lines
371 B
23 lines
371 B
package tools
|
|
|
|
type Page struct {
|
|
Page uint `json:"page" form:"page"`
|
|
Limit uint `json:"limit" form:"limit"`
|
|
}
|
|
|
|
// GetStart 获取初始位置
|
|
func (p *Page) GetStart() uint {
|
|
if p.Page <= 0 {
|
|
p.Page = 1
|
|
}
|
|
return (p.Page - 1) * p.GetLimit()
|
|
}
|
|
|
|
// GetLimit 获取分页大小
|
|
func (p *Page) GetLimit() uint {
|
|
if p.Limit <= 0 {
|
|
p.Limit = 10
|
|
}
|
|
return p.Limit
|
|
}
|