Documentation ¶
Index ¶
- type JoinTableField
- type OnJoins
- type Page
- type PageBuilder
- func (pb *PageBuilder) NewDB() *gorm.DB
- func (pb *PageBuilder) Pagination(dst interface{}, currentPage, pageSize int) (Page, error)
- func (pb *PageBuilder) ParsePage(currentPage, pageSize int) Page
- func (pb *PageBuilder) WithCondition(query interface{}, args ...interface{}) *PageBuilder
- func (pb *PageBuilder) WithDB(db *gorm.DB) *PageBuilder
- func (pb *PageBuilder) WithField(fields []string) *PageBuilder
- func (pb *PageBuilder) WithFields(model interface{}, table string, fields []string) *PageBuilder
- func (pb *PageBuilder) WithJoins(joinType string, joinFields []OnJoins) *PageBuilder
- func (pb *PageBuilder) WithModel(model interface{}) *PageBuilder
- func (pb *PageBuilder) WithMultiFields(fields []SelectTableField) *PageBuilder
- func (pb *PageBuilder) WithOrderBy(orderBy interface{}) *PageBuilder
- func (pb *PageBuilder) WithPreload(query string, args ...interface{}) *PageBuilder
- func (pb *PageBuilder) WithPreloads(querys []string) *PageBuilder
- type SelectTableField
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 PageBuilder ¶
type PageBuilder struct { DB *gorm.DB Model interface{} // model struct Preloads []string // 预加载 Fields []string // 查询字段 }
func NewBuilder ¶
func NewBuilder() *PageBuilder
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) 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 ¶
Click to show internal directories.
Click to hide internal directories.