pageutil

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check added in v0.0.3

func Check(pageIndex, pageSize int) error

检查页码参数是否有错误

func GetOffset added in v0.0.3

func GetOffset(pageIndex, pageSize int) (offset int)

GetOffset 根据页码和分页大小获取查询偏移量 offset

func GetValidPage added in v0.0.3

func GetValidPage(pageIndex, pageSize, defaultSize int) (page int, size int)

GetValidPage 获取有效的页码和分页大小

func SlicePage added in v0.0.3

func SlicePage(total, pageIndex, pageSize int) (start, end int, exist bool)

SlicePage 按分页大小分页,获取长度为 total 的切片 pageIndex 页的开始位置的结束位置;exist 表示分页位置是否存在

Types

type Page added in v0.0.3

type Page struct {
	Index int `json:"index" form:"page_index"` // 页码
	Size  int `json:"size" form:"page_size"`   // 分页大小
	Total int `json:"total"`                   // 符合条件的总记录数(仅用于响应结构中)
}

Page page

func New

func New(pageIndex, pageSize int) *Page

New 返回一个 *Page

func (*Page) Check added in v0.0.3

func (p *Page) Check() error

Check 检查 Page 的参数

func (*Page) Offset added in v0.0.3

func (p *Page) Offset() int

Offset 获取分页偏移量

func (*Page) SetValidVal added in v0.0.3

func (p *Page) SetValidVal(defaultSize int)

SetValidVal 设置Page参数的有效值

Jump to

Keyboard shortcuts

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