Documentation ¶
Index ¶
- Constants
- Variables
- func BuildFilterCond(filterMap map[string]string, db *gorm.DB, filter Filter) *gorm.DB
- func BuildOrderCond(orderKeyMap map[string]string, q *gorm.DB, order map[string]string) *gorm.DB
- func FmtCondVal(cond FilterCond, val interface{}) interface{}
- func FmtValPlaceholder(cond FilterCond) interface{}
- func IsValidQueryField(field string) bool
- type DelData
- type DetailData
- type Filter
- type FilterCond
- type FilterItem
- type FullLimitListData
- type IDData
- type ListData
- type NullableDetailData
- type RespJsonExtra
- type RetJSON
- type SearchData
Constants ¶
View Source
const ( PrimaryField = "id" CreateTimeField = "ctime" UpdateTimeField = "utime" DeleteTimeField = "dtime" )
View Source
const ( SceneDefault = "default" NotLimit = 0 )
Variables ¶
View Source
var ( // CondMapDbCond 条件映射 数据库条件 CondMapDbCond = map[FilterCond]string{ CondEq: "=", CondLt: "<", CondElt: "<=", CondGt: ">", CondEgt: ">=", CondNeq: "<>", CondBetweenValue: "BETWEEN", CondEqString: "=", CondLike: "LIKE", CondNotLike: "NOT LIKE", CondNeqString: "<>", CondBefore: "<", CondAfter: ">", CondBetweenTime: "BETWEEN", CondIn: "IN", CondNotIn: "NOT IN", } )
Functions ¶
func BuildFilterCond ¶
func BuildOrderCond ¶
func FmtCondVal ¶
func FmtCondVal(cond FilterCond, val interface{}) interface{}
func FmtValPlaceholder ¶
func FmtValPlaceholder(cond FilterCond) interface{}
Types ¶
type DetailData ¶
type DetailData struct { ID int `json:"id" binding:"required"` Scene string `json:"scene" binding:""` Extra map[string]interface{} `json:"extra" binding:""` }
func (*DetailData) GetScene ¶
func (d *DetailData) GetScene() string
type Filter ¶
type Filter = map[string]FilterItem
type FilterCond ¶
type FilterCond string
const ( // 筛选条件 CondUndefined FilterCond = "undefined" // 数值 CondEq FilterCond = "eq" CondLt FilterCond = "lt" CondElt FilterCond = "elt" CondGt FilterCond = "gt" CondEgt FilterCond = "egt" CondNeq FilterCond = "neq" CondBetweenValue FilterCond = "betweenValue" // 字符串 CondEqString FilterCond = "eqString" CondLike FilterCond = "like" CondNotLike FilterCond = "notLike" CondNeqString FilterCond = "neqString" // 时间 CondBefore FilterCond = "before" CondAfter FilterCond = "after" CondBetweenTime FilterCond = "betweenTime" // 数组 CondIn FilterCond = "in" CondNotIn FilterCond = "notIn" // 内部使用 CondRaw FilterCond = "raw" // order OrderAsc = "asc" OrderDesc = "desc" )
type FilterItem ¶
type FilterItem struct { Condition FilterCond Val interface{} }
type FullLimitListData ¶
type ListData ¶
type NullableDetailData ¶
type NullableDetailData struct { ID *int `json:"id" binding:"omitempty"` Scene string `json:"scene" binding:"omitempty"` Extra map[string]interface{} `json:"extra" binding:"omitempty"` }
func (*NullableDetailData) GetScene ¶
func (d *NullableDetailData) GetScene() string
type RespJsonExtra ¶
type RetJSON ¶
type RetJSON struct { Code int `json:"code" example:"0"` Data interface{} `json:"data,omitempty"` Msg string `json:"msg,omitempty" example:"提示信息"` Count *int `json:"count,omitempty"` Page int `json:"page,omitempty"` Limit int `json:"limit,omitempty"` Extra *RespJsonExtra `json:"extra,omitempty"` }
通用返回json 所有的接口均返回此对象
type SearchData ¶
Click to show internal directories.
Click to hide internal directories.