示例1,查询
示例2,分页
func Paginate(r *ghttp.Request) func(m *gdb.Model) *gdb.Model {
return func(m *gdb.Model) *gdb.Model {
type Pagination struct {
Page int
Size int
_ = r.Parse(&pagination)
switch {
case pagination.Size > 100:
pagination.Size = 100
}
return m.Page(pagination.Page, pagination.Size)
}
}