page

package
v0.0.0-...-9d33de4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option struct {
	//Data      interface{} `json:"data"`       // 数据
	Total     int    `json:"total"`      // 总条数
	TotalPage int    `json:"total_page"` // 总页数
	NextPage  int    `json:"next_page"`  // 上一页
	PrevPage  int    `json:"prev_page"`  // 下一页
	Offset    int    `json:"-"`          // 偏移
	Limit     int    `json:"-"`          // 条数
	Order     string `json:"-"`          // 排序规则
}

分页操作

func PageHelperOption

func PageHelperOption(condition *gorm.DB, model interface{}, page *Page) (result *Option, err error)

返回分页option属性,

type Page

type Page struct {
	PageNum int    `json:"page" valid:"Min(0)"` // 页数
	Size    int    `json:"size" valid:"Min(1)"` // 条数
	OrderBy string `json:"order_by"`            // 排序字段
	Sorter  string `json:"sorter"`              // 升序, 降序

}

分页

func BindPage

func BindPage(context *gin.Context) (p *Page)

从gin.Context绑定Page

func NewDefaultPage

func NewDefaultPage(page, size int) *Page

新建默认分页

func NewPage

func NewPage(page, size int, orderBy, sorter string) *Page

新建分页

type Result

type Result struct {
	*Page
	Data interface{} `json:"data"` // 数据
	*Option
}

分页结果

func PageHelper

func PageHelper(condition *gorm.DB, model interface{}, page *Page) (result *Result, err error)

单表查询分页工具函数

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL