paginator

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JoinTableField

type JoinTableField struct {
	Table, Field string
}

type OnJoins

type OnJoins struct {
	LeftTableField, RightTableField JoinTableField // LeftTableField:如:主表.ID  RightTableField:如:关联表.主表ID
}

type Page

type Page struct {
	List        interface{} `json:"list"`         // 查询的列表
	CurrentPage int         `json:"current_page"` // 当前页
	Total       int64       `json:"total"`        // 查询记录总数
	LastPage    int         `json:"last_page"`    // 最后一页
	PerPage     int         `json:"per_page"`     // 每页条数
}

type PageBuilder

type PageBuilder struct {
	DB       *gorm.DB
	Model    interface{} // model struct
	Preloads []string    // 预加载
	Fields   []string    // 查询字段
}

func NewBuilder

func NewBuilder() *PageBuilder

func (*PageBuilder) NewDB

func (pb *PageBuilder) NewDB() *gorm.DB

NewDB 对接原生查询方式

func (*PageBuilder) Pagination

func (pb *PageBuilder) Pagination(dst interface{}, currentPage, pageSize int) (Page, error)

Pagination 分页查询

func (*PageBuilder) ParsePage

func (pb *PageBuilder) ParsePage(currentPage, pageSize int) Page

ParsePage 分页超限设置和格式化

func (*PageBuilder) WithCondition

func (pb *PageBuilder) WithCondition(query interface{}, args ...interface{}) *PageBuilder

WithCondition 查询条件

func (*PageBuilder) WithDB

func (pb *PageBuilder) WithDB(db *gorm.DB) *PageBuilder

WithDB db连接

func (*PageBuilder) WithField

func (pb *PageBuilder) WithField(fields []string) *PageBuilder

WithField 查询单表的字段 和 过滤字段 不能与WithFields方法同用

func (*PageBuilder) WithFields

func (pb *PageBuilder) WithFields(model interface{}, table string, fields []string) *PageBuilder

WithFields 单多表字段查询字段(或过滤某些字段不查询 最后一个参数默认为select(不传或者传),如传omit为过滤前面传输的字段)

func (*PageBuilder) WithJoins

func (pb *PageBuilder) WithJoins(joinType string, joinFields []OnJoins) *PageBuilder

WithJoins join查询

func (*PageBuilder) WithModel

func (pb *PageBuilder) WithModel(model interface{}) *PageBuilder

WithModel 查询的model struct

func (*PageBuilder) WithMultiFields

func (pb *PageBuilder) WithMultiFields(fields []SelectTableField) *PageBuilder

WithMultiFields 多表多字段查询

func (*PageBuilder) WithOrderBy

func (pb *PageBuilder) WithOrderBy(orderBy interface{}) *PageBuilder

WithOrderBy 排序

func (*PageBuilder) WithPreload

func (pb *PageBuilder) WithPreload(query string, args ...interface{}) *PageBuilder

WithPreload 关联查询主动预加载(可传条件)

func (*PageBuilder) WithPreloads

func (pb *PageBuilder) WithPreloads(querys []string) *PageBuilder

WithPreloads 多表关联查询主动预加载(无条件)

type SelectTableField

type SelectTableField struct {
	Model interface{}
	Table string
	Field []string
}

Jump to

Keyboard shortcuts

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