dbpage

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcPageCount

func CalcPageCount(total, pageSize int) int

CalcPageCount 计算页码数

func CalcPageOffset

func CalcPageOffset(pageIndex, pageSize int) int

CalcPageOffset 计算页码记录偏移量, 页码从1开妈

func GetQueryPage

func GetQueryPage(query *gorm.DB, pageIndex, pageSize int) *gorm.DB

GetQueryPage 查询分页

func SetDefaultPageSize

func SetDefaultPageSize(size int)

SetDefaultPageSize 设置默认分页大小

func SetMaxPageSize

func SetMaxPageSize(size int)

SetMaxPageSize 设置最大返回行数

func SetMinPageIndex

func SetMinPageIndex(pi int)

SetMinPageIndex 设置页码开始

func ValidListParam

func ValidListParam(count *int)

func ValidPageParam

func ValidPageParam(pageIndex *int, pageSize *int)

Types

type DataPage

type DataPage struct {
	Total     int         `json:"total"`
	PageCount int         `json:"pc"`
	PageIndex int         `json:"pi"`
	PageSize  int         `json:"ps"`
	Rows      interface{} `json:"rows"`
}

func New

func New() *DataPage

func New4

func New4(total, pageCount, pageIndex, pageSize int) *DataPage

func New5

func New5(total, pageCount, pageIndex, pageSize int, rows interface{}) *DataPage

func (*DataPage) UpdatePageCount

func (dp *DataPage) UpdatePageCount(total, pageSize int)

UpdatePageCount 更新页码数

type DataPageT

type DataPageT[T any] struct {
	Total     int `json:"total"`
	PageCount int `json:"pc"`
	PageIndex int `json:"pi"`
	PageSize  int `json:"ps"`
	Rows      []T `json:"rows"`
}

func NewT

func NewT[T any]() *DataPageT[T]

func (*DataPageT[T]) Set

func (dpt *DataPageT[T]) Set(total, pageIndex, pageSize int, rows []T) *DataPageT[T]

func (*DataPageT[T]) SetRow

func (dpt *DataPageT[T]) SetRow(rows []T) *DataPageT[T]

Jump to

Keyboard shortcuts

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