models

package
v0.0.0-...-f0d4a1f Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// proxy 支持的hints
	HintsReadWrite = "/*#mode=READWRITE*/"
	HintsReadOnly  = "/*#mode=READONLY*/"
)
View Source
const (
	DeletedNo  = iota //未删除
	DeletedYes        //已删除
)

删除状态字段

Variables

This section is empty.

Functions

func BuildWhere

func BuildWhere(db *gorm.DB, conds []CondItem) (outDb *gorm.DB, err error)

BuildWhere 条件处理

func NormalPaginate

func NormalPaginate(page *NormalPage) func(db *gorm.DB) *gorm.DB

传统分页示例

func ScrollingPaginate

func ScrollingPaginate(page *ScrollPage) func(db *gorm.DB) *gorm.DB

func WithDeleted

func WithDeleted(db *gorm.DB) *gorm.DB

func WithNotDeleted

func WithNotDeleted(db *gorm.DB) *gorm.DB

WithNotDeleted 增加"未删除"状态过滤

Types

type CondItem

type CondItem struct {
	Index  string
	OpType string
	Data   interface{}
}

不定条件结构体 操作类型常量

func (CondItem) Check

func (cond CondItem) Check() (err error)

参数校验

type CrudModel

type CrudModel struct {
	CreatedAt time.Time      `json:"createdAt" gorm:"comment:创建时间"`
	UpdatedAt time.Time      `json:"updatedAt" gorm:"comment:最后更新时间"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index;comment:删除时间"`
}

type NormalPage

type NormalPage struct {
	No      int    // 当前第几页
	Size    int    // 每页大小
	OrderBy string `json:"orderBy"` // 排序规则
}

type Option

type Option struct {
	IsNeedCnt  bool `json:"isNeedCnt"`
	IsNeedPage bool `json:"isNeedPage"`
}

type ScrollPage

type ScrollPage struct {
	Start int // 当前页开始标示
	Size  int // 每页大小
}

瀑布流分页示例

type WhereScopes

type WhereScopes struct {
	Scopes []func(db *gorm.DB) *gorm.DB
}

func (*WhereScopes) Group

func (wc *WhereScopes) Group(groupBy string) *WhereScopes

func (*WhereScopes) Order

func (wc *WhereScopes) Order(orderBy string) *WhereScopes

func (*WhereScopes) Page

func (wc *WhereScopes) Page(normalPage *NormalPage) *WhereScopes

func (*WhereScopes) Preload

func (wc *WhereScopes) Preload(query string, args ...interface{}) *WhereScopes

func (*WhereScopes) Scope

func (wc *WhereScopes) Scope(f func(db *gorm.DB) *gorm.DB) *WhereScopes

func (*WhereScopes) Unscoped

func (wc *WhereScopes) Unscoped() *WhereScopes

func (*WhereScopes) Where

func (wc *WhereScopes) Where(query interface{}, args ...interface{}) *WhereScopes

Jump to

Keyboard shortcuts

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