Documentation ¶
Index ¶
- Variables
- func GenDoc(profile *Profile, routePrefixs *RoutePrefixs, apis ...string) *[]Doc
- type API
- func (ai *API) ALL(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
- func (ai *API) Create(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
- func (ai *API) Delete(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
- func (ai *API) Feature(name string) *API
- func (ai *API) FeatureWithOpts(opts *Opts) *API
- func (ai *API) List(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
- func (ai *API) One(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
- func (ai *API) Update(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
- type Config
- type CreateHook
- type DeleteHook
- type Doc
- type Example
- type Fields
- type FieldsParameter
- type GORM
- func (e *GORM) Conf(conf *Config) *GORM
- func (e *GORM) Docs() *[]Doc
- func (e *GORM) Init(init func(*GORM)) *GORM
- func (e *GORM) Model(name string) *gorm.DB
- func (e *GORM) Plugin(r *gin.RouterGroup) *GORM
- func (e *GORM) Profile(name string) *Profile
- func (e *GORM) Register(profile *Profile) *GORM
- func (e *GORM) Var(name string) interface{}
- func (e *GORM) Vars(name string) interface{}
- type Hook
- type ListHook
- type Model
- type OneHook
- type Opts
- type Parameter
- type Profile
- type Query
- type RouteHooks
- type RoutePrefixs
- type UpdateHook
Constants ¶
This section is empty.
Variables ¶
var FailureHandler = func(c *gin.Context) { c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{ "message": "Access Denied, you don't have permission", }) }
FailureHandler handlerss
Functions ¶
Types ¶
type API ¶
type API struct { Opts *Opts // contains filtered or unexported fields }
API type defined
func (*API) ALL ¶
func (ai *API) ALL(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
ALL hook auto generate api
func (*API) Create ¶
func (ai *API) Create(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
Create hook auto generate api
func (*API) Delete ¶
func (ai *API) Delete(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
Delete hook auto generate api
func (*API) FeatureWithOpts ¶
FeatureWithOpts defined feature api with opts
func (*API) List ¶
func (ai *API) List(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
List hook auto generate api
func (*API) One ¶
func (ai *API) One(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
One hook auto generate api
func (*API) Update ¶
func (ai *API) Update(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
Update hook auto generate api
type Config ¶
type Config struct { AutoMigrate bool `json:"automigrate" yaml:"automigrate"` DBType string `json:"dbType" yaml:"dbType"` URL string `json:"url" yaml:"url"` }
Config defined GORM Config
type CreateHook ¶
type CreateHook struct { Pre func(*gin.Context) Post func(*gin.Context) Auth func(*gin.Context) bool Form func(form) form }
CreateHook defined create hook opts
type DeleteHook ¶
type DeleteHook struct { Pre func(*gin.Context) Post func(*gin.Context) Auth func(*gin.Context) bool Form func(form) form Cond func(map[string]interface{}, *gin.Context, struct{ Name string }) map[string]interface{} }
DeleteHook defined delete hook opts
type Doc ¶
type Doc struct { Type string `json:"type" yaml:"type"` URL string `json:"url" yaml:"url"` Title string `json:"title" yaml:"title"` Name string `json:"name" yaml:"name"` Group string `json:"group" yaml:"group"` Desc string `json:"description" yaml:"description"` Version string `json:"version" yaml:"version"` GroupTitle string `json:"groupTitle" yaml:"groupTitle"` Parameter Parameter `json:"parameter" yaml:"parameter"` }
Doc defined model api doc
type Example ¶
type Example struct { Title string `json:"title" yaml:"title"` Content string `json:"content" yaml:"content"` Type string `json:"type" yaml:"type"` }
Example defined model api doc
type Fields ¶
type Fields struct {
FieldsParameter []FieldsParameter `json:"Parameter" yaml:"Parameter"`
}
Fields defined model api doc
type FieldsParameter ¶
type FieldsParameter struct { Tags reflect.StructTag `json:"-" yaml:"-"` Group string `json:"group" yaml:"group"` Type string `json:"type" yaml:"type"` Optional bool `json:"optional" yaml:"optional"` Field string `json:"field" yaml:"field"` Desc string `json:"description" yaml:"description"` }
FieldsParameter defined model api doc
type GORM ¶
GORM Type Defined
func (*GORM) Plugin ¶
func (e *GORM) Plugin(r *gin.RouterGroup) *GORM
Plugin defined plugin for bulrush
type Hook ¶
type Hook struct {
// contains filtered or unexported fields
}
Hook for API
func (*Hook) RouteHooks ¶
func (h *Hook) RouteHooks(hooks *RouteHooks) *Hook
RouteHooks defined RouteHooks
type ListHook ¶
type ListHook struct { Pre func(*gin.Context) Post func(*gin.Context) Auth func(*gin.Context) bool Cond func(map[string]interface{}, *gin.Context, struct{ Name string }) map[string]interface{} }
ListHook defined list hook opts
type Model ¶
type Model struct { ID uint `gorm:"comment:'模型ID';primary_key"` CreatedAt *time.Time `gorm:"comment:'创建时间'"` UpdatedAt *time.Time `gorm:"comment:'更新时间'"` DeletedAt *time.Time `sql:"index" gorm:"comment:'删除时间'"` }
Model base model definition, including fields `ID`, `CreatedAt`, `UpdatedAt`, `DeletedAt`, which could be embedded in your models
type OneHook ¶
type OneHook struct { Pre func(*gin.Context) Post func(*gin.Context) Auth func(c *gin.Context) bool Cond func(map[string]interface{}, *gin.Context, struct{ Name string }) map[string]interface{} }
OneHook defined one hook opts
type Opts ¶
type Opts struct { Prefix string FeaturePrefix string RoutePrefixs *RoutePrefixs RouteHooks *RouteHooks }
Opts defined api params
type Parameter ¶
type Parameter struct { Fields Fields `json:"fields" yaml:"fields"` Examples []Example `json:"examples" yaml:"examples"` }
Parameter defined model api doc
type Profile ¶
type Profile struct { DB string Name string Reflector interface{} AutoHook bool Opts *Opts // contains filtered or unexported fields }
Profile defined model profile
type Query ¶
type Query struct { Query struct { Cond string `form:"cond" json:"cond" xml:"cond"` Select string `form:"select" json:"select" xml:"select"` Preload string `form:"preload" json:"preload" xml:"preload"` Order string `form:"order" json:"order" xml:"order"` Page int `form:"page" json:"page" xml:"page"` Size int `form:"size" json:"size" xml:"size"` Range string `form:"range" json:"range" xml:"range"` } Cond map[string]interface{} SQL string Select string Preload []string Order string Page int Size int Range string }
Query defined query std
func (*Query) BuildRelated ¶
func (q *Query) BuildRelated()
BuildRelated defined related sql for preLoad
type RouteHooks ¶
type RouteHooks struct { One *OneHook List *ListHook Create *CreateHook Update *UpdateHook Delete *DeleteHook }
RouteHooks defined route hooks