示例1,查询

    示例2,分页

    1. func Paginate(r *ghttp.Request) func(m *gdb.Model) *gdb.Model {
    2. return func(m *gdb.Model) *gdb.Model {
    3. type Pagination struct {
    4. Page int
    5. Size int
    6. _ = r.Parse(&pagination)
    7. switch {
    8. case pagination.Size > 100:
    9. pagination.Size = 100
    10. }
    11. return m.Page(pagination.Page, pagination.Size)
    12. }
    13. }