2017-04-30 22:02:49 +00:00
|
|
|
package base
|
|
|
|
|
|
|
|
import (
|
2017-09-16 09:58:33 +00:00
|
|
|
"github.com/ouqiang/gocron/models"
|
|
|
|
"gopkg.in/macaron.v1"
|
2017-04-30 22:02:49 +00:00
|
|
|
)
|
|
|
|
|
2017-10-01 13:49:46 +00:00
|
|
|
// ParsePageAndPageSize 解析查询参数中的页数和每页数量
|
2017-09-16 09:58:33 +00:00
|
|
|
func ParsePageAndPageSize(ctx *macaron.Context, params models.CommonMap) {
|
|
|
|
page := ctx.QueryInt("page")
|
|
|
|
pageSize := ctx.QueryInt("page_size")
|
|
|
|
if page <= 0 {
|
|
|
|
page = 1
|
|
|
|
}
|
|
|
|
if pageSize <= 0 {
|
|
|
|
pageSize = models.PageSize
|
|
|
|
}
|
2017-04-30 22:02:49 +00:00
|
|
|
|
2017-09-16 09:58:33 +00:00
|
|
|
params["Page"] = page
|
|
|
|
params["PageSize"] = pageSize
|
|
|
|
}
|