pagination

package
v0.9.17 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Paginator

type Paginator struct {
	// 总条数
	TotalCount int `json:"total"`

	// 当前页的数据项数量
	CurrentCount int `json:"count"`

	// 每页行数
	Limit int `json:"per_page"`

	// 当前页数
	CurrentPage int `json:"current_page"`

	// 总页数
	TotalPages int `json:"total_pages"`
}

Paginator 分页器

func Paginate

func Paginate(totalCount, currentPage, limit int) Paginator

*

 Paginate paginate by total count
	- totalCount : length of data
	- currentPage: current page number
	- limit: number of per page

func PaginateSlice

func PaginateSlice(items []interface{}, currentPage, limit int) (paginate Paginator, result []interface{})

*

  • PaginateSlice paginate by slice
  • items : data items
  • currentPage: current page number
  • limit: number of per page

func (*Paginator) GetOffset

func (p *Paginator) GetOffset() int

GetOffset 获取偏移量

Jump to

Keyboard shortcuts

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