paginator

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MPL-2.0 Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultPaginator = Paginator{
		Page:     1,
		PageSize: defaultPageSize,
		Offset:   0,
	}
)

Functions

func GetStartEndPosition

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

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

func Paginate

func Paginate[T any](sliceVars []T, pageSize int64) [][]T

Paginate 分页

Types

type Page

type Page struct {
	Start int64
	End   int64
}

func CalculatePages

func CalculatePages(total, pageSize int64) []Page

CalculatePages 根据总数量和每页多少个计算Page数组

type Paginator

type Paginator struct {
	Page     uint64 // 第几页
	PageSize uint64 // 每页的大小
	Offset   uint64 // 偏移起始值
}

func New

func New(page, pageSize int64) Paginator

New 获取分页器

func (Paginator) GetMySQLLimitClause

func (p Paginator) GetMySQLLimitClause() string

GetMySQLLimitClause 获取MySQL的limit子句

type UtilsPaginator

type UtilsPaginator interface {
	GetMySQLLimitClause() string
}

Jump to

Keyboard shortcuts

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