Documentation ¶
Overview ¶
Package fire /**/ 对 gorm.DB 的补充封装,实现更爽快得使用。属于基础层服务代码。
Index ¶
- Constants
- func Camel2Case(name string) string
- func FormatColumn(column string) (res string)
- func If(isA bool, a, b interface{}) interface{}
- func UpdateArithmetic(column string, value interface{}, art ArithmeticType) (m map[string]interface{})
- type Allow
- type ArithmeticType
- type CompareType
- type Fire
- func (d *Fire) Allow(param Param, allow Allow) *Fire
- func (d *Fire) Close() (err error)
- func (d *Fire) CrudAll(model interface{}, callListData interface{}) (err error)
- func (d *Fire) CrudAllPage(model interface{}, callListData interface{}, page ...Page) (pageResult PageResult, err error)
- func (d *Fire) CrudAllPagePreloadAll(model interface{}, callListData interface{}, page ...Page) (pageResult PageResult, err error)
- func (d *Fire) CrudAllPagePreloadJoin(model interface{}, callListData interface{}, page ...Page) (pageResult PageResult, err error)
- func (d *Fire) CrudAllPreloadAll(model interface{}, callListData interface{}) (err error)
- func (d *Fire) CrudAllPreloadJoin(model interface{}, callListData interface{}) (err error)
- func (d *Fire) CrudCount(model interface{}) (count int64, err error)
- func (d *Fire) CrudCreate(model interface{}, batchSize ...int) (err error)
- func (d *Fire) CrudDelete(model interface{}) (err error)
- func (d *Fire) CrudOne(model interface{}, callData interface{}) (err error)
- func (d *Fire) CrudOnePreloadAll(model interface{}, callData interface{}) (err error)
- func (d *Fire) CrudOnePreloadJoin(model interface{}, callData interface{}) (err error)
- func (d *Fire) CrudSum(model interface{}, column string) (sum float32, err error)
- func (d *Fire) CrudUpdate(model interface{}, updates ...interface{}) (err error)
- func (d *Fire) CrudUpdatePrimaryKey(model interface{}, updates ...interface{}) (err error)
- func (d *Fire) IsExists(model interface{}) bool
- func (d *Fire) OrderByColumn(column string, order OrderType, many ...bool) *Fire
- func (d *Fire) PreloadAll() *Fire
- func (d *Fire) PreloadJoin(model interface{}) *Fire
- func (d *Fire) WhereCompare(column string, value interface{}, compare ...CompareType) *Fire
- func (d *Fire) WhereIn(column string, value interface{}, isNot ...bool) *Fire
- func (d *Fire) WhereLike(column string, value interface{}) *Fire
- func (d *Fire) WhereRange(column string, start interface{}, end interface{}) *Fire
- type M
- type OrderType
- type Page
- type PageParam
- type PageResult
- type Param
- type Params
- type Sort
- type TimeFieldsEditModel
- type TimeFieldsModel
Constants ¶
const DefaultPageSize = 20
Variables ¶
This section is empty.
Functions ¶
func Camel2Case ¶ added in v2.1.2
func FormatColumn ¶
func UpdateArithmetic ¶
func UpdateArithmetic(column string, value interface{}, art ArithmeticType) (m map[string]interface{})
UpdateArithmetic field = field ArithmeticType Number # field = field + 1
Types ¶
type Allow ¶
type Allow struct { // where Where []string Range []string In []string Like []string // order Sorts []string }
func (*Allow) AllowParams ¶
AllowParams allow params
type ArithmeticType ¶
type ArithmeticType string
const ( ArithmeticIncrease ArithmeticType = "+" ArithmeticReduce ArithmeticType = "-" ArithmeticMultiply ArithmeticType = "*" ArithmeticExcept ArithmeticType = "/" )
type CompareType ¶
type CompareType string
const ( CompareEqual CompareType = "=" CompareAboutEqual CompareType = ">=" CompareAbout CompareType = ">" CompareLessEqual CompareType = "<=" CompareLess CompareType = "<" )
type Fire ¶ added in v2.1.0
func NewInstance ¶
func (*Fire) CrudAllPage ¶ added in v2.1.0
func (d *Fire) CrudAllPage(model interface{}, callListData interface{}, page ...Page) (pageResult PageResult, err error)
func (*Fire) CrudAllPagePreloadAll ¶ added in v2.1.0
func (d *Fire) CrudAllPagePreloadAll(model interface{}, callListData interface{}, page ...Page) (pageResult PageResult, err error)
func (*Fire) CrudAllPagePreloadJoin ¶ added in v2.1.0
func (d *Fire) CrudAllPagePreloadJoin(model interface{}, callListData interface{}, page ...Page) (pageResult PageResult, err error)
func (*Fire) CrudAllPreloadAll ¶ added in v2.1.0
func (*Fire) CrudAllPreloadJoin ¶ added in v2.1.0
func (*Fire) CrudCreate ¶ added in v2.1.0
CrudCreate model support Array,Slice,Struct every struct support tag `gormCreate` validator.Struct()
func (*Fire) CrudDelete ¶ added in v2.1.0
func (*Fire) CrudOnePreloadAll ¶ added in v2.1.0
func (*Fire) CrudOnePreloadJoin ¶ added in v2.1.0
func (*Fire) CrudUpdate ¶ added in v2.1.0
CrudUpdate updates support (M or map[string]interface{}) and struct support gorm.Db.Select() and gorm.Db.Omit() TODO: struct only update non-zero fields
func (*Fire) CrudUpdatePrimaryKey ¶ added in v2.1.0
CrudUpdatePrimaryKey Make sure that all primary keys are not zero when updating
func (*Fire) OrderByColumn ¶ added in v2.1.0
func (*Fire) PreloadAll ¶ added in v2.1.0
PreloadAll TODO:Multiple SQL, gorm bonding data, so query conditions other than the main table are not supported
func (*Fire) PreloadJoin ¶ added in v2.1.0
PreloadJoin TODO:Single SQL, mysql bonding data, so the conditions of all query tables are supported. use Join you need to pay attention to performance
func (*Fire) WhereCompare ¶ added in v2.1.0
func (d *Fire) WhereCompare(column string, value interface{}, compare ...CompareType) *Fire
WhereCompare column CompareEqual ? # column = ?
func (*Fire) WhereRange ¶ added in v2.1.0
WhereRange column >= start ANd column <= end
type Page ¶
type Page struct { Current int `json:"current" form:"current"` PageSize int `json:"pageSize" form:"pageSize"` }
func (*Page) DefaultSize ¶ added in v2.1.3
type Param ¶
type Param struct { Params Params `form:"params" json:"params"` Sort Sort `form:"sort" json:"sort" binding:"omitempty,max=1,dive,keys,required,endkeys,eq=ascend|eq=descend"` }
Param 筛选、排序参数
type TimeFieldsEditModel ¶ added in v2.1.2
type TimeFieldsEditModel struct { // 13位毫秒时间戳 CreatedAt int64 `gorm:"column:created_at;autoCreateTime:milli;type:bigint(13);unsigned;comment:创建时间" json:"createdAt"` // 13位毫秒时间戳,兼容用户一秒内多次点击 UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime:milli;type:bigint(13);unsigned;comment:修改时间" json:"updatedAt"` }
type TimeFieldsModel ¶
type TimeFieldsModel struct { TimeFieldsEditModel // 软删除,默认为0,删除时设置当前10位秒数时间戳 DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at;type:bigint(13);unsigned;comment:删除时间" json:"deletedAt"` }