pagination

package
v0.0.1-202202091022 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: MPL-2.0 Imports: 2 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultPageSize = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type Pagination

type Pagination struct {
	// contains filtered or unexported fields
}

func New

func New(page, pageSize int64, args ...int64) *Pagination

New pagination args[0] is default page size

func (*Pagination) GetSQLClause

func (p *Pagination) GetSQLClause(total int64) string

GetSQLClause 获取翻页SQL查询语句

1. 假如前端没有传过来last_pk, 那么返回值是 last_pk, LIMIT子句(LIMIT offset, pageSize) e,g: 0, "LIMIT 20, 10" => 在数据库查询时可能会被组装成 WHERE pk > 0 ... LIMIT 20, 10

2. 假如前端传过来了last_pk, 那么返回值是 last_pk, LIMIT子句(LIMIT pageSize) e,g: 123,"LIMIT 10" => 在数据库查询时可能会被组装成 WHERE pk > 123 ... LIMIT 10

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