pager

package
v0.0.0-...-35a45e1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2019 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Help

func Help(pageNum, pageSize int, rowsSlicePtr interface{}, rowElement interface{}, session *xorm.Session) (total int64, err error)

Help xorm 分页 pageNum: 当前页码,从1开始 pageSize: 每页条数 rowsSlicePtr: 要求传入一个slice的指针类型 &[]model.User,否则出现错误 rowElement: slice里面的单个元素,会将其中的非0值元素作为查询条件 session: 为带有查询条件的session 可以携带一些特殊的查询条件 rowElement 无法做到的,如:like 等 默认分页大小20,如果查询总数为0则不会继续往后查询 会赋值传入的slice为查询结果,并返回查询总数total,或执行中出现的error错误

Types

type PageModel

type PageModel struct {
	PageNum      int         `json:"page_num"`
	PageSize     int         `json:"page_size"`
	TotalPages   int64       `json:"total_pages"`
	TotalRecords int64       `json:"total_records"`
	Records      interface{} `json:"records"`
}

PageModel 分页模型

func NewPageModel

func NewPageModel(pageNum, pageSize int, totalRecords int64, records interface{}) *PageModel

NewPageModel 构造分页对象 pageNum: 当前页码,从1开始 pageSize: 每页条数,默认条数20 totalRecords: 总条数 records: 分页数据,必须为slice,不能为nil或者其他对象,可以是空的slice

Jump to

Keyboard shortcuts

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