pagination

package
v0.0.0-...-96f2668 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PAGE          = 1
	PAGE_SIZE     = 10
	MAX_PAGE_SIZE = 1000
)

Variables

This section is empty.

Functions

func GetPageOffset

func GetPageOffset(page, pageSize int32) int

func OrderByUnmarshal

func OrderByUnmarshal(o map[string]bool) map[string]bool

func QueryUnmarshal

func QueryUnmarshal(q map[string]string) map[string]string

Types

type Option

type Option func(*Pagination)

func WithNopaging

func WithNopaging() Option

func WithOrderBy

func WithOrderBy(o map[string]bool) Option

func WithPage

func WithPage(page int32) Option

func WithPageSize

func WithPageSize(size int32) Option

func WithQuery

func WithQuery(q map[string]interface{}) Option

type OrderBy

type OrderBy struct {
	Column string
	Desc   bool
}

type Pagination

type Pagination struct {
	// 当前页
	Page int32
	// 每一页的行数
	PageSize int32
	// 查询参数
	Query map[string]interface{}
	// 排序
	OrderBy map[string]bool
	// 是否不分页
	Nopaging bool
}

func NewPagination

func NewPagination(opts ...Option) *Pagination

type PaginationHandler

type PaginationHandler interface {
	GetPage() int32
	GetPageSize() int32
	GetPageOffset() int
	Reset() error
}

type Query

type Query struct {
	Key       string
	Condition string
	Args      []interface{}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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