pagination

package
v1.0.65 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MPL-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultPageSize = 10
)

Variables

This section is empty.

Functions

func CalculatePages

func CalculatePages(total, pageSize int64) [][]int64

CalculatePages 计算页面,获取带有起始值的页面的数组 @return 返回一个二维数组, 第一维是多少页,第二维是每页[]int64{start, end} e,g: 假设11个数的列表,分页pageSize是5,那么返回的是:

[]int64{
   []int64{0, 5},
   []int64{5, 10},
   []int64{10, 11},
}

func GetLimitClause added in v1.0.57

func GetLimitClause(listParam *protobuf.ListParam) string

GetLimitClause 从protobuf.ListParam生成limit语句

func GetStartEndPosition

func GetStartEndPosition(page, pageSize, total int64) (int64, int64)

GetStartEndPosition 如果是按列表slice进行翻页的话, 计算slice的起始index

Types

type Pagination

type Pagination struct {
	Page     uint64 // 第几页
	PageSize uint64 // 每页几项
	Offset   uint64 // 偏移起始值
}

func New

func New(page, pageSize int64) *Pagination

func NewWithParam added in v1.0.57

func NewWithParam(listParam *protobuf.ListParam) *Pagination

func (*Pagination) GetLimitClause

func (p *Pagination) GetLimitClause() string

GetLimitClause 获取limit sql子句

func (*Pagination) Paging

func (p *Pagination) Paging(data interface{}) (int64, []interface{})

Paging 分页 @return total @return []interface{} 分页后的数据

Jump to

Keyboard shortcuts

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