Back to godoc.org

Package xormext

v0.0.0-...-5d03f69
Latest Go to latest

The latest major version is .

Published: Oct 22, 2019 | License: MIT | Module: github.com/2637309949/bulrush-addition

Index

Variables

var FailureHandler = func(c *gin.Context) {
	c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{
		"message": "Access Denied, you don't have permission",
	})
}

FailureHandler handlerss

func GenDoc

func GenDoc(profile *Profile, routePrefixs *RoutePrefixs, apis ...string) *[]Doc

GenDoc defined doc

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) Feature

func (ai *API) Feature(name string) *API

Feature defined feature api

func (*API) FeatureWithOpts

func (ai *API) FeatureWithOpts(opts *Opts) *API

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 ComplexMapper

type ComplexMapper struct {
}

ComplexMapper defined mapper

func (ComplexMapper) Obj2Table

func (m ComplexMapper) Obj2Table(o string) string

Obj2Table defined mapper

func (ComplexMapper) Table2Obj

func (m ComplexMapper) Table2Obj(t string) string

Table2Obj defined mapper

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 XORM 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 Hook

type Hook struct {
	// contains filtered or unexported fields
}

Hook for API

func (*Hook) Auth

func (h *Hook) Auth(auth func(*gin.Context) bool) *Hook

Auth defined pre handler

func (*Hook) Post

func (h *Hook) Post(post func(*gin.Context)) *Hook

Post defined pre handler

func (*Hook) Pre

func (h *Hook) Pre(pre func(*gin.Context)) *Hook

Pre defined pre handler

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 NewQuery

func NewQuery() *Query

NewQuery defined new query

func (*Query) Build

func (q *Query) Build(pre map[string]interface{}) error

Build defined all build

func (*Query) BuildCond

func (q *Query) BuildCond(cond map[string]interface{}) error

BuildCond defined select sql

func (*Query) BuildOrder

func (q *Query) BuildOrder()

BuildOrder defined order sql

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

type RoutePrefixs

type RoutePrefixs struct {
	One    func(string) string
	List   func(string) string
	Create func(string) string
	Update func(string) string
	Delete func(string) string
	// contains filtered or unexported fields
}

RoutePrefixs defined route prefixs

type UpdateHook

type UpdateHook 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{}
}

UpdateHook defined create hook opts

type XORM

type XORM struct {
	DB  *xorm.EngineGroup
	API *API
	// contains filtered or unexported fields
}

XORM Type Defined

func New

func New() *XORM

New New mongo instance Export Session, API and AutoHook

func (*XORM) Conf

func (e *XORM) Conf(conf *Config) *XORM

Conf set e conf

func (*XORM) Docs

func (e *XORM) Docs() *[]Doc

Docs defined Docs for bulrush

func (*XORM) Init

func (e *XORM) Init(init func(*XORM)) *XORM

Init e

func (*XORM) Model

func (e *XORM) Model(name string) *xorm.Session

Model return instance

func (*XORM) Plugin

func (e *XORM) Plugin(r *gin.RouterGroup) *XORM

Plugin defined plugin for bulrush

func (*XORM) Profile

func (e *XORM) Profile(name string) *Profile

Profile model profile

func (*XORM) Register

func (e *XORM) Register(profile *Profile) *XORM

Register model should provide name and reflector paramters

func (*XORM) Var

func (e *XORM) Var(name string) interface{}

Var return Var reflect from reflector entity

func (*XORM) Vars

func (e *XORM) Vars(name string) interface{}

Vars return array of Var

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier