Documentation
¶
Index ¶
Constants ¶
View Source
const ( Eq = "eq" Neq = "neq" Gt = "gt" Gte = "gte" Lt = "lt" Lte = "lte" Like = "like" )
View Source
const ( AND string = "and" OR string = "or" )
Variables ¶
View Source
var ( // ErrNotFound 空记录 ErrNotFound = gorm.ErrRecordNotFound )
Functions ¶
Types ¶
type Column ¶
type Column struct {
Name string `json:"name"` // 列名
Exp string `json:"exp"` // 表达式,值为空时默认为=,有=、!=、>、>=、<、<=、like七种类型
Value interface{} `json:"value"` // 列值
Logic string `json:"logic"` // 逻辑类型,值为空时默认为and,有&(and)、||(or)两种类型
}
Column 表的列查询信息
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Page 页
type Params ¶
type Params struct {
Page int `form:"page" binding:"gte=0" json:"page"`
Size int `form:"size" binding:"gt=0" json:"size"`
Sort string `form:"sort" binding:"" json:"sort,omitempty"`
Columns []Column `json:"columns,omitempty"` // 非必须
}
Params 查询原始参数
func (*Params) ConvertToGormConditions ¶
ConvertToGormConditions 根据参数Columns转换成符合gorm规则参数 无论是一列还是多列查询,忽略最后一列的逻辑类型
Click to show internal directories.
Click to hide internal directories.