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
519 B
23 lines
519 B
5 years ago
|
package lib
|
||
|
|
||
|
import "live/app/lib/config"
|
||
|
|
||
|
type Page struct {
|
||
|
Page int `json:"page" form:"page"` // 分页
|
||
|
Limit int `json:"limit" form:"limit"` // 分页大小
|
||
|
}
|
||
|
|
||
|
func (p *Page) GetPage() int {
|
||
|
if p.Page > 0 {
|
||
|
return p.Page
|
||
|
}
|
||
|
return 1
|
||
|
}
|
||
|
|
||
|
func (p *Page) GetLimit() int {
|
||
|
if p.Limit >= config.Config.Section("page").Key("minLimit").MustInt(1) || p.Limit < config.Config.Section("page").Key("maxLimit").MustInt(100) {
|
||
|
return p.Limit
|
||
|
}
|
||
|
return config.Config.Section("page").Key("defaultLimit").MustInt(15)
|
||
|
}
|