Documentation
¶
Index ¶
- func Bind(handlerFn interface{}) gin.HandlerFunc
- func Mixed(c *gin.Context, operator ...Operator)
- type Bit
- type Conditions
- type Crud
- func (x *Crud) Add(c *gin.Context) interface{}
- func (x *Crud) Delete(c *gin.Context) interface{}
- func (x *Crud) Edit(c *gin.Context) interface{}
- func (x *Crud) Get(c *gin.Context) interface{}
- func (x *Crud) GetMixed(c *gin.Context) *mixed
- func (x *Crud) Lists(c *gin.Context) interface{}
- func (x *Crud) OriginLists(c *gin.Context) interface{}
- type CrudOption
- type DeleteBody
- type EditBody
- type GetBody
- type ListsBody
- type Operator
- type Orders
- type OriginListsBody
- type Pagination
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bind ¶
func Bind(handlerFn interface{}) gin.HandlerFunc
Bind The binding routing function returns the result uniformly
Params:
handlerFn: func(c *gin.Context) interface{}
Mapped return:
(string) => 200 {"error":0,"msg":<this string value>}
(error) => 200 {"error":1,"msg":<this error msg, for example err.Error()>}
(default) => 200 {"error":0,"data":<interface{}>}
Custom error code: c.Set("code", 1000)
Types ¶
type Bit ¶
type Bit struct {
// contains filtered or unexported fields
}
Bit a tools
func (*Bit) Crud ¶
func (x *Bit) Crud(model interface{}, options ...CrudOption) *Crud
Crud create CRUD functions
Params: model: model name options: crud option
type Conditions ¶
type Conditions [][]interface{}
Conditions array condition definition
func (Conditions) GetConditions ¶
func (c Conditions) GetConditions() Conditions
GetConditions get array condition definition
type Crud ¶
type Crud struct {
// contains filtered or unexported fields
}
func (*Crud) OriginLists ¶
OriginLists general definition of list request
type CrudOption ¶
type CrudOption func(*Crud)
CrudOption crud option
func SetOrders ¶
func SetOrders(orders Orders) CrudOption
SetOrders set global ordering
Params: orders: map[string]string
type DeleteBody ¶
type DeleteBody struct {
Id interface{} `json:"id" binding:"required_without=Conditions"`
Conditions `json:"where" binding:"required_without=Id,gte=0,dive,len=3,dive,required"`
}
DeleteBody general definition of delete body
type EditBody ¶
type EditBody struct {
Id interface{} `json:"id" binding:"required_without=Conditions"`
Conditions `json:"where" binding:"required_without=Id,gte=0,dive,len=3,dive,required"`
Switch *bool `json:"switch"`
}
EditBody general definition of edit body
type GetBody ¶
type GetBody struct {
Id interface{} `json:"id" binding:"required_without=Conditions"`
Conditions `json:"where" binding:"required_without=Id,gte=0,dive,len=3,dive,required"`
Orders `json:"order" binding:"omitempty,gte=0,dive,keys,endkeys,oneof=asc desc,required"`
}
GetBody general definition of get body
type ListsBody ¶
type ListsBody struct {
Pagination `json:"page" binding:"required"`
Conditions `json:"where" binding:"omitempty,gte=0,dive,len=3,dive,required"`
Orders `json:"order" binding:"omitempty,gte=0,dive,keys,endkeys,oneof=asc desc,required"`
}
ListsBody general definition of page body
type Operator ¶
type Operator func(*mixed)
Operator mixed operations
func SetBody ¶
func SetBody(body interface{}) Operator
SetBody define the custom request body
Scenes: OriginLists,Lists,Get,Delete: they need to embed OriginListsBody, ListsBody, GetBody, DeleteBody Add,Edit: useless
type OriginListsBody ¶
type OriginListsBody struct {
Conditions `json:"where" binding:"omitempty,gte=0,dive,len=3,dive,required"`
Orders `json:"order" binding:"omitempty,gte=0,dive,keys,endkeys,oneof=asc desc,required"`
}
OriginListsBody general definition of list body
type Pagination ¶
type Pagination struct {
Index int `json:"index" binding:"gt=0,number,required"`
Limit int `json:"limit" binding:"gt=0,number,required"`
}
Pagination page properties
Index: page number Limit: number of pages
func (Pagination) GetPagination ¶
func (x Pagination) GetPagination() Pagination
GetPagination get page properties
Click to show internal directories.
Click to hide internal directories.