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) } func (p *Page) GetStart() int { return (p.GetPage() - 1) * p.GetLimit() }