pagination

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PaginationRequest

type PaginationRequest struct {
	Page    int    `form:"page" schema:"page" binding:"required" validate:"min=1"`
	PerPage int    `form:"per_page" schema:"per_page" binding:"required" validate:"min=10"`
	OrderBy string `form:"order_by" schema:"order_by" validate:"omitempty"`
}

type PaginationResponse

type PaginationResponse struct {
	LastPage int   `json:"last_page" mapstructure:"last_page" validate:"required"`
	Total    int64 `json:"total" mapstructure:"total" validate:"required"`
}

type Paginator

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

func NewPaginator

func NewPaginator(
	db *gorm.DB,
	whereConditionMap WhereConditionMap,
	orders map[string]string,
	page int,
	perPage int,
) Paginator

func (*Paginator) AddWhereConditions

func (p *Paginator) AddWhereConditions(wm map[string]any) *Paginator

func (*Paginator) CloneDB

func (p *Paginator) CloneDB() *gorm.DB

func (*Paginator) Execute

func (p *Paginator) Execute(data any) *gorm.DB

func (*Paginator) GetTotalAndLastPage

func (p *Paginator) GetTotalAndLastPage() (int64, int)

func (*Paginator) OrderBy

func (p *Paginator) OrderBy(orderBy string) *Paginator

type WhereConditionMap

type WhereConditionMap map[string]func(db *gorm.DB, value any)

Jump to

Keyboard shortcuts

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