Documentation
¶
Index ¶
- Constants
- Variables
- func AddHTTPGuard(name string, guard gin.HandlerFunc)
- func AliasProcess(name string, alias string)
- func EnvInt(key interface{}, defaults ...int) int
- func EnvString(key interface{}, defaults ...string) string
- func IsAllowed(c *gin.Context, allowsMap map[string]bool) bool
- func KillPlugins()
- func LoadRuntime(option runtime.Option)
- func LoadService(source string, name string) (*service.Service, error)
- func LoadStore(source string, name string) (store.Store, error)
- func LoadTask(source string, name string) (*task.Task, error)
- func LoadWebSocketServer(source string, name string) (*websocket.Upgrader, error)
- func LoadWidget(path string, name string, register widget.ModuleRegister) (*widget.Widget, error)
- func ProcessGuard(name string) gin.HandlerFunc
- func RegisterProcessGroup(name string, group map[string]ProcessHandler)
- func RegisterProcessHandler(name string, handler ProcessHandler)
- func SelectPluginModel(name string) grpc.Model
- func SelectService(name string) *service.Service
- func SelectStore(name string) store.Store
- func SelectTask(name string) *task.Task
- func SelectWebSocketServer(name string) *websocket.Upgrader
- func ServeHTTP(server Server, shutdown chan bool, onShutdown func(Server), ...)
- func ServeHTTPCustomRouter(router *gin.Engine, server Server, shutdown chan bool, onShutdown func(Server), ...)
- func SetFileRoot(root string) error
- func SetHTTPGuards(guards map[string]gin.HandlerFunc)
- func SetHTTPRoutes(router *gin.Engine, server Server, middlewares ...gin.HandlerFunc)
- func SetModelLogger(output io.Writer, level log.Level)
- func SetPluginLogger(name string, output io.Writer, level hclog.Level)
- func ValidationEmail(value interface{}, _ maps.MapStrAny, _ ...interface{}) bool
- func ValidationEnum(value interface{}, _ maps.MapStrAny, args ...interface{}) bool
- func ValidationMax(value interface{}, _ maps.MapStrAny, args ...interface{}) bool
- func ValidationMaxLength(value interface{}, _ maps.MapStrAny, args ...interface{}) bool
- func ValidationMin(value interface{}, _ maps.MapStrAny, args ...interface{}) bool
- func ValidationMinLength(value interface{}, _ maps.MapStrAny, args ...interface{}) bool
- func ValidationMobile(value interface{}, _ maps.MapStrAny, args ...interface{}) bool
- func ValidationPattern(value interface{}, _ maps.MapStrAny, args ...interface{}) bool
- func ValidationTypeof(value interface{}, _ maps.MapStrAny, args ...interface{}) bool
- type API
- type Column
- func (column *Column) FliterIn(value interface{}, row maps.MapStrAny)
- func (column *Column) FliterOut(value interface{}, row maps.MapStrAny, export ...string)
- func (column *Column) Map() map[string]interface{}
- func (column Column) SetOption(col *schema.Column)
- func (column Column) SetType(table schema.Blueprint) *schema.Column
- func (column *Column) Validate(value interface{}, row maps.MapStrAny) (bool, []string)
- type ColumnMap
- type Encryptor
- type EncryptorAES
- type EncryptorAES128
- type EncryptorAES256
- type EncryptorPassword
- type ErrorOfImport
- type ErrorsImport
- type ExportData
- type Flow
- func (flow *Flow) DSLCheck(source map[string]interface{}) error
- func (flow *Flow) DSLCompile(root string, file string, source map[string]interface{}) error
- func (flow *Flow) DSLRefresh(root string, file string, source map[string]interface{}) error
- func (flow *Flow) DSLRemove(root string, file string) error
- func (flow *Flow) Exec(args ...interface{}) interface{}
- func (flow *Flow) ExecNode(node *FlowNode, ctx *FlowContext, prev int) []interface{}
- func (flow *Flow) FormatResult(ctx *FlowContext) interface{}
- func (flow *Flow) LoadScript(source string, name string) *Flow
- func (flow *Flow) LoadScriptReturn(source string, name string) (new *Flow, err error)
- func (flow *Flow) Prepare()
- func (flow *Flow) Reload() *Flow
- func (flow *Flow) RunProcess(node *FlowNode, ctx *FlowContext, data maps.Map) (interface{}, []interface{})
- func (flow *Flow) RunQuery(node *FlowNode, ctx *FlowContext, data maps.Map) (interface{}, []interface{})
- func (flow *Flow) RunScript(node *FlowNode, ctx *FlowContext, data maps.Map, processResp interface{}, ...) (interface{}, []interface{})
- func (flow *Flow) WithGlobal(global map[string]interface{}) *Flow
- func (flow *Flow) WithSID(sid string) *Flow
- type FlowContext
- type FlowNode
- type HTTP
- type IEncryptor
- type Import
- type Index
- type MetaData
- type Model
- func (mod *Model) Blueprint() (types.Blueprint, error)
- func (mod *Model) Create(row maps.MapStrAny) (int, error)
- func (mod *Model) CreateTable() error
- func (mod *Model) DSLCheck(source map[string]interface{}) error
- func (mod *Model) DSLCompile(root string, file string, source map[string]interface{}) error
- func (mod *Model) DSLRefresh(root string, file string, source map[string]interface{}) error
- func (mod *Model) DSLRemove(root string, file string) error
- func (mod *Model) Delete(id interface{}) error
- func (mod *Model) DeleteWhere(param QueryParam) (int, error)
- func (mod *Model) Destroy(id interface{}) error
- func (mod *Model) DestroyWhere(param QueryParam) (int, error)
- func (mod *Model) DropTable() error
- func (mod *Model) EachSave(rows []map[string]interface{}, eachrow ...maps.MapStrAny) ([]interface{}, error)
- func (mod *Model) Export(chunkSize int, process func(curr, total int)) ([]string, error)
- func (mod *Model) Filterselect(alias string, columns []interface{}, cmap map[string]ColumnMap, ...) []interface{}
- func (mod *Model) Find(id interface{}, param QueryParam) (maps.MapStr, error)
- func (mod *Model) FliterIn(row maps.MapStrAny)
- func (mod *Model) FliterOut(row maps.MapStrAny)
- func (mod *Model) FliterWhere(alias string, col interface{}) interface{}
- func (mod *Model) Get(param QueryParam) ([]maps.MapStr, error)
- func (mod *Model) HasTable() (bool, error)
- func (mod *Model) Import(file string) error
- func (mod *Model) Insert(columns []string, rows [][]interface{}) error
- func (mod *Model) InsertValues() ([]int, []error)
- func (mod *Model) Migrate(force bool) error
- func (mod *Model) MustCreate(row maps.MapStrAny) int
- func (mod *Model) MustDelete(id interface{})
- func (mod *Model) MustDeleteWhere(param QueryParam) int
- func (mod *Model) MustDestroy(id interface{})
- func (mod *Model) MustDestroyWhere(param QueryParam) int
- func (mod *Model) MustEachSave(rows []map[string]interface{}, eachrow ...maps.MapStrAny) []interface{}
- func (mod *Model) MustFind(id interface{}, param QueryParam) maps.MapStr
- func (mod *Model) MustGet(param QueryParam) []maps.MapStr
- func (mod *Model) MustInsert(columns []string, rows [][]interface{})
- func (mod *Model) MustPaginate(param QueryParam, page int, pagesize int) maps.MapStr
- func (mod *Model) MustSave(row maps.MapStrAny) interface{}
- func (mod *Model) MustUpdate(id interface{}, row maps.MapStrAny)
- func (mod *Model) MustUpdateWhere(param QueryParam, row maps.MapStrAny) int
- func (mod *Model) Paginate(param QueryParam, page int, pagesize int) (maps.MapStr, error)
- func (mod *Model) Reload() *Model
- func (mod *Model) Save(row maps.MapStrAny) (interface{}, error)
- func (mod *Model) SaveTable() error
- func (mod *Model) Update(id interface{}, row maps.MapStrAny) error
- func (mod *Model) UpdateWhere(param QueryParam, row maps.MapStrAny) (int, error)
- func (mod *Model) Validate(row maps.MapStrAny) []ValidateResponse
- type Option
- type Out
- type Path
- type Plugin
- type Process
- func (process *Process) ArgsArray(index int) []interface{}
- func (process *Process) ArgsBool(i int, defaults ...bool) bool
- func (process *Process) ArgsInt(i int, defaults ...int) int
- func (process *Process) ArgsMap(i int, defaults ...maps.MapStrAny) maps.MapStrAny
- func (process *Process) ArgsNotNull(i int)
- func (process *Process) ArgsQueryParams(i int, defaults ...QueryParam) QueryParam
- func (process *Process) ArgsRecords(index int) []map[string]interface{}
- func (process *Process) ArgsString(i int, defaults ...string) string
- func (process *Process) ArgsStrings(index int) []string
- func (process *Process) ArgsURLValue(i int, name string, defaults ...string) string
- func (process *Process) ArgsUint32(i int, defaults ...uint32) uint32
- func (process *Process) Exec() (value interface{}, err error)
- func (process *Process) Lang(defaults ...string) string
- func (process *Process) NumOfArgs() int
- func (process *Process) NumOfArgsIs(num int) bool
- func (process *Process) Run() interface{}
- func (process *Process) ValidateArgNums(length int)
- func (process *Process) WithGlobal(global map[string]interface{}) *Process
- func (process *Process) WithSID(sid string) *Process
- type ProcessHandler
- type QueryOrder
- type QueryParam
- func (param QueryParam) NewQuery() *QueryStack
- func (param QueryParam) Order(order QueryOrder, qb query.Query, mod *Model)
- func (param QueryParam) Query(stack *QueryStack, stackParams ...QueryStackParam) *QueryStack
- func (param QueryParam) Where(where QueryWhere, qb query.Query, mod *Model)
- func (param QueryParam) With(name string, stack *QueryStack, with With, mod *Model)
- type QueryStack
- func (stack *QueryStack) Builder() *QueryStackBuilder
- func (stack *QueryStack) FirstQuery() query.Query
- func (stack *QueryStack) Len() int
- func (stack *QueryStack) Merge(new *QueryStack)
- func (stack *QueryStack) Next() int
- func (stack *QueryStack) Paginate(page int, pagesize int) maps.MapStrAny
- func (stack *QueryStack) Push(builder QueryStackBuilder, param QueryStackParam)
- func (stack *QueryStack) Query() query.Query
- func (stack *QueryStack) QueryParam() QueryParam
- func (stack *QueryStack) Relation() Relation
- func (stack *QueryStack) Run() []maps.MapStrAny
- type QueryStackBuilder
- type QueryStackParam
- type QueryWhere
- type Redirect
- type Relation
- type ResponseImport
- func (resp *ResponseImport) CastInsert(line int, data []map[string]string, model *Model) ([]string, [][]interface{})
- func (resp *ResponseImport) Error(mesage string, code int, args ...interface{}) *ErrorOfImport
- func (resp *ResponseImport) InsertChunk(line int, data []map[string]string, model *Model)
- func (resp *ResponseImport) IsError(line int, process interface{}) bool
- type Schedule
- type Server
- type Socket
- type SocketEvent
- type Store
- type Table
- type TaskOption
- type Template
- func (tpl *Template) DSLCheck(source map[string]interface{}) error
- func (tpl *Template) DSLCompile(root string, file string, source map[string]interface{}) error
- func (tpl *Template) DSLRefresh(root string, file string, source map[string]interface{}) error
- func (tpl *Template) DSLRemove(root string, file string) error
- type UploadFile
- type ValidateResponse
- type Validation
- type WebSocket
- type WebSocketEvent
- type With
Constants ¶
const ( RelHasOne = "hasOne" // 1 v 1 RelHasMany = "hasMany" // 1 v n RelBelongsTo = "belongsTo" // inverse 1 v 1 / 1 v n / n v n RelHasOneThrough = "hasOneThrough" // 1 v 1 ( t1 <-> t2 <-> t3) RelHasManyThrough = "hasManyThrough" // 1 v n ( t1 <-> t2 <-> t3) RelBelongsToMany = "belongsToMany" // 1 v1 / 1 v n / n v n RelMorphOne = "morphOne" RelMorphMany = "morphMany" RelMorphToMany = "morphToMany" RelMorphByMany = "morphByMany" RelMorphMap = "morphMap" )
Relationship types
Variables ¶
var APIs = map[string]*API{}
APIs 已加载API列表
var Encryptors = map[string]Encryptor{}
Encryptors 已加载加密器
var FileSystemHandlers = map[string]ProcessHandler{
"readfile": processReadFile,
"readfilebuffer": processReadFileBuffer,
"writefile": processWirteFile,
"writefilebuffer": processWriteFileBuffer,
"readdir": processReadDir,
"mkdir": processMkdir,
"mkdirall": processMkdirAll,
"mkdirtemp": processMkdirTemp,
"remove": processRemove,
"removeall": processRemoveAll,
"exists": processExists,
"isdir": processIsDir,
"isfile": processIsFile,
"islink": processIsLink,
"chmod": processChmod,
"size": processSize,
"mode": processMode,
"modtime": processModTime,
"basename": processBaseName,
"dirname": processDirName,
"extname": processExtName,
"mimetype": processMimeType,
"move": processMove,
"copy": processCopy,
"upload": processUpload,
"download": processDownload,
}
FileSystemHandlers the file system handlers
var Flows = map[string]*Flow{}
Flows 已加载工作流列表
var HTTPGuards = map[string]gin.HandlerFunc{}
HTTPGuards 支持的中间件
var HTTPHandlers = map[string]ProcessHandler{
"get": processHTTPGet,
"post": processHTTPPost,
"put": processHTTPPut,
"patch": processHTTPPatch,
"delete": processHTTPDelete,
"head": processHTTPHead,
"send": processHTTPSend,
}
HTTPHandlers the http handlers
var HandlerGroups = map[string]map[string]ProcessHandler{}
HandlerGroups registered process handler groups
var IEncryptors = map[string]IEncryptor{ "AES": &EncryptorAES{}, "PASSWORD": &EncryptorPassword{}, }
IEncryptors 加密码器接口映射
var ModelHandlers = map[string]ProcessHandler{
"find": processFind,
"get": processGet,
"paginate": processPaginate,
"selectoption": processSelectOption,
"create": processCreate,
"update": processUpdate,
"save": processSave,
"delete": processDelete,
"destroy": processDestroy,
"insert": processInsert,
"updatewhere": processUpdateWhere,
"deletewhere": processDeleteWhere,
"destroywhere": processDestroyWhere,
"eachsave": processEachSave,
"eachsaveafterdelete": processEachSaveAfterDelete,
}
ModelHandlers 模型运行器
var Models = map[string]*Model{}
Models 已载入模型
var Plugins = map[string]*Plugin{}
Plugins 已加载插件
var ScheduleHandlers = map[string]ProcessHandler{
"start": processScheduleStart,
"stop": processScheduleStop,
}
ScheduleHandlers chedule process handlers
var Schedules = map[string]*Schedule{}
Schedules the registered schedules
var SchemaHandlers = map[string]ProcessHandler{
"create": processSchemaCreate,
"drop": processSchemaDrop,
"tables": processSchemaTables,
"tableget": processSchemaTableGet,
"tablecreate": processSchemaTableCreate,
"tabledrop": processSchemaTableDrop,
"tablerename": processSchemaTableRename,
"tablediff": processSchemaTableDiff,
"tablesave": processSchemaTableSave,
"columnadd": processSchemaColumnAdd,
"columnalt": processSchemaColumnAlt,
"columndel": processSchemaColumnDel,
"indexadd": processSchemaIndexAdd,
"indexdel": processSchemaIndexDel,
}
SchemaHandlers Processes
var Services = map[string]*service.Service{}
Services services loaded (Alpha)
var Sockets = map[string]*Socket{}
Sockets sockets loaded (Alpha)
var StoreHandlers = map[string]ProcessHandler{
"get": processStoreGet,
"set": processStoreSet,
"has": processStoreHas,
"del": processStoreDel,
"getdel": processStoreGetDel,
"len": processStoreLen,
"keys": processStoreKeys,
"clear": processStoreClear,
}
StoreHandlers store process handlers
var TaskHandlers = map[string]ProcessHandler{
"add": processTaskAdd,
"progress": processTaskProgress,
"get": processTaskGet,
}
TaskHandlers task process handlers
var ThirdHandlers = map[string]ProcessHandler{}
ThirdHandlers 第三方处理器
var Validations = map[string]func(value interface{}, row maps.MapStrAny, args ...interface{}) bool{ "typof": ValidationTypeof, "min": ValidationMin, "max": ValidationMax, "enum": ValidationEnum, "pattern": ValidationPattern, "minLength": ValidationMinLength, "maxLength": ValidationMaxLength, "email": ValidationEmail, "mobile": ValidationMobile, }
Validations 数据校验函数
var WebSockets = map[string]*WebSocket{}
WebSockets websockets loaded (Alpha)
var WidgetCustomHandlers = map[string]map[string]ProcessHandler{}
WidgetCustomHandlers custom widget handlers
var WidgetHandlers = map[string]ProcessHandler{
"reload": processReloadWidgetInstance,
}
WidgetHandlers widget process handlers
var Yao *runtime.Runtime
Yao JavaScript 运行环境
Functions ¶
func LoadRuntime ¶ added in v0.10.2
LoadRuntime load runtime
func LoadService ¶
LoadService load socket server/client
func LoadWebSocketServer ¶
LoadWebSocketServer load websocket servers
func LoadWidget ¶
LoadWidget load widgets
func RegisterProcessGroup ¶ added in v0.10.2
func RegisterProcessGroup(name string, group map[string]ProcessHandler)
RegisterProcessGroup register a process handler group
func RegisterProcessHandler ¶
func RegisterProcessHandler(name string, handler ProcessHandler)
RegisterProcessHandler 注册 ProcessHandler
func SelectService ¶
SelectService Get socket by name
func SelectWebSocketServer ¶
SelectWebSocketServer Get WebSocket server by name
func ServeHTTP ¶
func ServeHTTP(server Server, shutdown chan bool, onShutdown func(Server), middlewares ...gin.HandlerFunc)
ServeHTTP Start the http server
func ServeHTTPCustomRouter ¶
func ServeHTTPCustomRouter(router *gin.Engine, server Server, shutdown chan bool, onShutdown func(Server), middlewares ...gin.HandlerFunc)
ServeHTTPCustomRouter Start the cumtom http server
func SetHTTPRoutes ¶
func SetHTTPRoutes(router *gin.Engine, server Server, middlewares ...gin.HandlerFunc)
SetHTTPRoutes 设定路由
func SetModelLogger ¶
SetModelLogger 设定模型 Logger
func SetPluginLogger ¶
SetPluginLogger 设置日志
func ValidationEmail ¶
ValidationEmail 验证邮箱
func ValidationEnum ¶
ValidationEnum 枚举型
func ValidationMax ¶
ValidationMax 最大值
func ValidationMaxLength ¶
ValidationMaxLength 最大长度
func ValidationMin ¶
ValidationMin 最小值
func ValidationMinLength ¶
ValidationMinLength 最小长度
func ValidationMobile ¶
ValidationMobile 验证手机号
func ValidationPattern ¶
ValidationPattern 正则匹配
func ValidationTypeof ¶
ValidationTypeof 校验数值类型
Types ¶
type Column ¶
type Column struct {
Label string `json:"label,omitempty"`
Name string `json:"name"`
Type string `json:"type,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Comment string `json:"comment,omitempty"`
Length int `json:"length,omitempty"`
Precision int `json:"precision,omitempty"`
Scale int `json:"scale,omitempty"`
Nullable bool `json:"nullable,omitempty"`
Option []string `json:"option,omitempty"`
Default interface{} `json:"default,omitempty"`
DefaultRaw string `json:"default_raw,omitempty"`
Example interface{} `json:"example,omitempty"`
Generate string `json:"generate,omitempty"` // Increment, UUID,...
Crypt string `json:"crypt,omitempty"` // AES, PASSWORD, AES-256, AES-128, PASSWORD-HASH, ...
Validations []Validation `json:"validations,omitempty"`
Index bool `json:"index,omitempty"`
Unique bool `json:"unique,omitempty"`
Primary bool `json:"primary,omitempty"`
// contains filtered or unexported fields
}
Column the field description struct
type Encryptor ¶
type Encryptor struct {
Name string `json:"-"` // 名称
Source string `json:"-"` // 来源
Salt string `json:"salt,omitempty"` // 盐
Key string `json:"key,omitempty"` // 钥匙
Secret string `json:"secret,omitempty"` // 密钥
}
Encryptor 加密器
type EncryptorAES ¶
type EncryptorAES struct{ Encryptor }
EncryptorAES AES
func (EncryptorAES) Decode ¶
func (aes EncryptorAES) Decode(field string) (string, error)
Decode AES Decode
type EncryptorPassword ¶
type EncryptorPassword struct{ Encryptor }
EncryptorPassword 密码加密
func (EncryptorPassword) Decode ¶
func (pwd EncryptorPassword) Decode(value string) (string, error)
Decode PASSWORD Decode
type ErrorOfImport ¶
type ErrorOfImport struct {
Code int `json:"code"` // 错误码
Message string `json:"message"` // 错误描述
File string `json:"file"` // 出错文件
Line int `json:"line,omitempty"` // 出错行
Field string `json:"field,omitempty"` // 源数据出错字段名称
Value interface{} `json:"value,omitempty"` // 源数据出错数值
}
ErrorOfImport 导入错误结构体
func (*ErrorOfImport) AtLine ¶
func (err *ErrorOfImport) AtLine(line int) *ErrorOfImport
AtLine 设置出错行
func (*ErrorOfImport) FieldIs ¶
func (err *ErrorOfImport) FieldIs(name string) *ErrorOfImport
FieldIs 设置出错字段
func (*ErrorOfImport) FileIs ¶
func (err *ErrorOfImport) FileIs(filename string) *ErrorOfImport
FileIs 设置出错文件
func (*ErrorOfImport) ValueIs ¶
func (err *ErrorOfImport) ValueIs(value interface{}) *ErrorOfImport
ValueIs 设置出错字段
type ExportData ¶
type ExportData struct {
Model string `json:"model"`
Columns []string `json:"columns"`
Values [][]interface{} `json:"values"`
}
ExportData the export data struct
type Flow ¶
type Flow struct {
Name string `json:"-"`
Source string `json:"-"`
Scripts map[string]string `json:"-"`
Label string `json:"label"`
Version string `json:"version"`
Description string `json:"description,omitempty"`
Nodes []FlowNode `json:"nodes,omitempty"`
Output interface{} `json:"output,omitempty"`
Global map[string]interface{} // 全局变量
Sid string // 会话ID
}
Flow 工作流
func LoadFlowReturn ¶
LoadFlowReturn 加载数据流
func (*Flow) DSLCompile ¶
DSLCompile compile the FLow
func (*Flow) DSLRefresh ¶
DSLRefresh refresh the FLow
func (*Flow) ExecNode ¶
func (flow *Flow) ExecNode(node *FlowNode, ctx *FlowContext, prev int) []interface{}
ExecNode 运行节点
func (*Flow) FormatResult ¶
func (flow *Flow) FormatResult(ctx *FlowContext) interface{}
FormatResult 结果集格式化输出
func (*Flow) LoadScript ¶
LoadScript 载入脚本
func (*Flow) LoadScriptReturn ¶
LoadScriptReturn 加载载入脚本
func (*Flow) RunProcess ¶
func (flow *Flow) RunProcess(node *FlowNode, ctx *FlowContext, data maps.Map) (interface{}, []interface{})
RunProcess 运行处理器
func (*Flow) RunQuery ¶
func (flow *Flow) RunQuery(node *FlowNode, ctx *FlowContext, data maps.Map) (interface{}, []interface{})
RunQuery 运行 Query DSL 查询
func (*Flow) RunScript ¶
func (flow *Flow) RunScript(node *FlowNode, ctx *FlowContext, data maps.Map, processResp interface{}, processOuts []interface{}) (interface{}, []interface{})
RunScript 运行数据处理脚本
func (*Flow) WithGlobal ¶
WithGlobal 设定全局变量
type FlowContext ¶
type FlowContext struct {
In []interface{}
Res map[string]interface{}
Context *context.Context
Cancel context.CancelFunc
}
FlowContext 工作流上下文
type FlowNode ¶
type FlowNode struct {
Name string `json:"name,omitempty"`
Process string `json:"process,omitempty"`
Engine string `json:"engine,omitempty"` // 数据分析引擎名称
Query interface{} `json:"query,omitempty"` // 数据分析语言 Query Source
DSL share.DSL `json:"-"` // 数据分析语言 Query DSL
Script string `json:"script,omitempty"`
Args []interface{} `json:"args,omitempty"`
Outs []interface{} `json:"outs,omitempty"`
}
FlowNode 工作流节点
type HTTP ¶
type HTTP struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description,omitempty"`
Group string `json:"group,omitempty"`
Guard string `json:"guard,omitempty"`
Paths []Path `json:"paths,omitempty"`
}
HTTP http 协议服务
type IEncryptor ¶
type IEncryptor interface {
Set(crypt Encryptor)
Encode(value string) (string, error)
Decode(value string) (string, error)
Validate(hash string, value string) bool
}
IEncryptor 加密器接口
type Import ¶
type Import struct {
Mapping map[string]string `json:"mapping,omitempty"` // 源数据与数据模型字段映射表
Process string `json:"process,omitempty"` // 源数据与数据模型转换处理器 (process & mapping 任选其一)
Chunk int `json:"chunk,omitempty"` // 每次处理数据数量
Notify func(line int, record string) `json:"-"` // 进度通报函数
Option map[string]interface{} `json:"option,omitempty"` // CSV 分割符等参数
}
Import 数据导入配置
func (*Import) InsertCSV ¶
func (impt *Import) InsertCSV(csvfile string, model string) *ResponseImport
InsertCSV 导入CSV使用 (insert)
type Index ¶
type Index struct {
Comment string `json:"comment,omitempty"`
Name string `json:"name,omitempty"`
Columns []string `json:"columns,omitempty"`
Type string `json:"type,omitempty"` // primary,unique,index,match
}
Index the search index struct
type MetaData ¶
type MetaData struct {
Name string `json:"name,omitempty"` // 元数据名称
Connector string `json:"connector,omitempty"` // Bind a connector, MySQL, SQLite, Postgres, Clickhouse, Tidb, Oracle support. default is SQLite
Table Table `json:"table,omitempty"` // 数据表选项
Columns []Column `json:"columns,omitempty"` // 字段定义
Indexes []Index `json:"indexes,omitempty"` // 索引定义
Relations map[string]Relation `json:"relations,omitempty"` // 映射关系定义
Values []maps.MapStrAny `json:"values,omitempty"` // 初始数值
Option Option `json:"option,omitempty"` // 元数据配置
}
MetaData 元数据
type Model ¶
type Model struct {
ID string
Name string
Source string
Driver string // Driver
MetaData MetaData
Columns map[string]*Column // 字段映射表
ColumnNames []interface{} // 字段名称清单
PrimaryKey string // 主键(单一主键)
PrimaryKeys []string // 主键(联合主键)
UniqueColumns []*Column // 唯一字段清单
}
Model 数据模型
func LoadModelReturn ¶
LoadModelReturn 加载数据模型
func (*Model) CreateTable ¶ added in v0.10.2
CreateTable create the table of the model
func (*Model) DSLCompile ¶
DSLCompile compile the DSL
func (*Model) DSLRefresh ¶
DSLRefresh refresh the DSL
func (*Model) DeleteWhere ¶
func (mod *Model) DeleteWhere(param QueryParam) (int, error)
DeleteWhere 批量删除数据, 返回更新行数
func (*Model) DestroyWhere ¶
func (mod *Model) DestroyWhere(param QueryParam) (int, error)
DestroyWhere 批量真删除数据, 返回更新行数
func (*Model) EachSave ¶
func (mod *Model) EachSave(rows []map[string]interface{}, eachrow ...maps.MapStrAny) ([]interface{}, error)
EachSave 批量保存数据, 返回数据ID集合
func (*Model) Filterselect ¶
func (mod *Model) Filterselect(alias string, columns []interface{}, cmap map[string]ColumnMap, exportPrefix string) []interface{}
Filterselect 选择字段
func (*Model) Find ¶
func (mod *Model) Find(id interface{}, param QueryParam) (maps.MapStr, error)
Find 查询单条记录
func (*Model) FliterWhere ¶
FliterWhere 选项
func (*Model) InsertValues ¶ added in v0.10.2
InsertValues insert the default values of the model
func (*Model) MustCreate ¶
MustCreate 创建单条数据, 返回新创建数据ID, 失败抛出异常
func (*Model) MustDeleteWhere ¶
func (mod *Model) MustDeleteWhere(param QueryParam) int
MustDeleteWhere 批量删除数据, 返回更新行数, 失败抛出异常
func (*Model) MustDestroy ¶
func (mod *Model) MustDestroy(id interface{})
MustDestroy 真删除单条记录, 失败抛出异常
func (*Model) MustDestroyWhere ¶
func (mod *Model) MustDestroyWhere(param QueryParam) int
MustDestroyWhere 批量真删除数据, 返回更新行数, 失败抛出异常
func (*Model) MustEachSave ¶
func (mod *Model) MustEachSave(rows []map[string]interface{}, eachrow ...maps.MapStrAny) []interface{}
MustEachSave 批量保存数据, 返回数据ID集合, 失败抛出异常
func (*Model) MustFind ¶
func (mod *Model) MustFind(id interface{}, param QueryParam) maps.MapStr
MustFind 查询单条记录
func (*Model) MustGet ¶
func (mod *Model) MustGet(param QueryParam) []maps.MapStr
MustGet 按条件查询, 不分页, 失败抛出异常
func (*Model) MustInsert ¶
MustInsert 插入多条数据, 失败抛出异常
func (*Model) MustPaginate ¶
MustPaginate 按条件查询, 分页, 失败抛出异常
func (*Model) MustUpdate ¶
MustUpdate 更新单条数据, 失败抛出异常
func (*Model) MustUpdateWhere ¶
func (mod *Model) MustUpdateWhere(param QueryParam, row maps.MapStrAny) int
MustUpdateWhere 按条件更新记录, 返回更新行数, 失败抛出异常
func (*Model) UpdateWhere ¶
UpdateWhere 按条件更新记录, 返回更新行数
type Option ¶
type Option struct {
Timestamps bool `json:"timestamps,omitempty"` // + created_at, updated_at 字段
SoftDeletes bool `json:"soft_deletes,omitempty"` // + deleted_at 字段
Trackings bool `json:"trackings,omitempty"` // + created_by, updated_by, deleted_by 字段
Constraints bool `json:"constraints,omitempty"` // + 约束定义
Permission bool `json:"permission,omitempty"` // + __permission 字段
Logging bool `json:"logging,omitempty"` // + __logging_id 字段
Readonly bool `json:"read_only,omitempty"` // Ignore the migrate operation
}
Option 模型配置选项
type Out ¶
type Out struct {
Status int `json:"status"`
Type string `json:"type,omitempty"`
Body interface{} `json:"body,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Redirect *Redirect `json:"redirect,omitempty"`
}
Out http 输出
type Path ¶
type Path struct {
Label string `json:"label,omitempty"`
Description string `json:"description,omitempty"`
Path string `json:"path"`
Method string `json:"method"`
Process string `json:"process"`
Guard string `json:"guard,omitempty"`
In []string `json:"in,omitempty"`
Out Out `json:"out,omitempty"`
}
Path HTTP Path
type Process ¶
type Process struct {
Name string
Type string
Class string
Method string
Args []interface{}
Global map[string]interface{} // 全局变量
Sid string // 会话ID
Handler ProcessHandler
}
Process 运行器
func (*Process) ArgsQueryParams ¶
func (process *Process) ArgsQueryParams(i int, defaults ...QueryParam) QueryParam
ArgsQueryParams 读取参数 QueryParam
func (*Process) ArgsRecords ¶
ArgsRecords 读取 []map[string]interface{} 参数值
func (*Process) ArgsString ¶
ArgsString 读取参数 String
func (*Process) ArgsStrings ¶
ArgsStrings 读取 []string 参数值
func (*Process) ArgsURLValue ¶
ArgsURLValue 读取参数
func (*Process) ArgsUint32 ¶ added in v0.10.2
ArgsUint32 get Uint32
func (*Process) NumOfArgsIs ¶
NumOfArgsIs 参数数量是否等以给等值
func (*Process) ValidateArgNums ¶
ValidateArgNums 校验参数数量( args )
func (*Process) WithGlobal ¶
WithGlobal 设定全局变量
type QueryOrder ¶
type QueryOrder struct {
Rel string `json:"rel,omitempty"` // Relation Name
Column string `json:"column"`
Option string `json:"option,omitempty"` // desc, asc
}
QueryOrder Order 查询排序
type QueryParam ¶
type QueryParam struct {
Model string `json:"model,omitempty"`
Table string `json:"table,omitempty"`
Alias string `json:"alias,omitempty"`
Export string `json:"export,omitempty"` // 导出前缀
Select []interface{} `json:"select,omitempty"` // string | dbal.Raw
Wheres []QueryWhere `json:"wheres,omitempty"`
Orders []QueryOrder `json:"orders,omitempty"`
Limit int `json:"limit,omitempty"`
Page int `json:"page,omitempty"`
PageSize int `json:"pagesize,omitempty"`
Withs map[string]With `json:"withs,omitempty"`
}
QueryParam 数据查询器参数
func AnyToQueryParam ¶
func AnyToQueryParam(v interface{}) (QueryParam, bool)
AnyToQueryParam interface 转换为 QueryParams
func URLToQueryParam ¶
func URLToQueryParam(values url.Values) QueryParam
URLToQueryParam url.Values 转换为 QueryParams
func (QueryParam) Order ¶
func (param QueryParam) Order(order QueryOrder, qb query.Query, mod *Model)
Order 排序条件
func (QueryParam) Query ¶
func (param QueryParam) Query(stack *QueryStack, stackParams ...QueryStackParam) *QueryStack
Query 构建查询栈(本版先实现,下一版本根据实际应用场景迭代)
func (QueryParam) Where ¶
func (param QueryParam) Where(where QueryWhere, qb query.Query, mod *Model)
Where 查询条件
func (QueryParam) With ¶
func (param QueryParam) With(name string, stack *QueryStack, with With, mod *Model)
With 关联查询
type QueryStack ¶
type QueryStack struct {
Builders []QueryStackBuilder
Params []QueryStackParam
Current int
}
QueryStack 查询栈
func (*QueryStack) Builder ¶
func (stack *QueryStack) Builder() *QueryStackBuilder
Builder 返回当前查询构建器
func (*QueryStack) FirstQuery ¶
func (stack *QueryStack) FirstQuery() query.Query
FirstQuery 返回第一个查询器
func (*QueryStack) Paginate ¶
func (stack *QueryStack) Paginate(page int, pagesize int) maps.MapStrAny
Paginate 执行查询栈(分页查询)
func (*QueryStack) Push ¶
func (stack *QueryStack) Push(builder QueryStackBuilder, param QueryStackParam)
Push 添加查询器
func (*QueryStack) QueryParam ¶
func (stack *QueryStack) QueryParam() QueryParam
QueryParam 返回当前查询参数
type QueryStackBuilder ¶
QueryStackBuilder 查询构建器
type QueryStackParam ¶
type QueryStackParam struct {
QueryParam QueryParam
Relation Relation
ExportPrefix string // 字段导出前缀
}
QueryStackParam QueryStack 查询参数
type QueryWhere ¶
type QueryWhere struct {
Rel string `json:"rel,omitempty"` // Relation Name
Column interface{} `json:"column,omitempty"`
Value interface{} `json:"value,omitempty"`
Method string `json:"method,omitempty"` // where,orwhere, wherein, orwherein...
OP string `json:"op,omitempty"` // 操作 eq/gt/lt/ge/le/like...
Wheres []QueryWhere `json:"wheres,omitempty"` // 分组查询
}
QueryWhere Where 查询条件
type Redirect ¶ added in v0.10.2
type Redirect struct {
Code int `json:"code,omitempty"`
Location string `json:"location,omitempty"`
}
Redirect out redirect
type Relation ¶
type Relation struct {
Name string `json:"-"`
Type string `json:"type"`
Key string `json:"key,omitempty"`
Model string `json:"model,omitempty"`
Foreign string `json:"foreign,omitempty"`
Links []Relation `json:"links,omitempty"`
Query QueryParam `json:"query,omitempty"`
}
Relation the new xun model relation
type ResponseImport ¶
type ResponseImport struct {
Import *Import `json:"import"` // 导入数据
Errors *ErrorsImport `json:"errors"` // 导入错误集合
Success int `json:"success"` // 成功导入记录数量
Failure int `json:"failure"` // 失败导入记录数量
Total int `json:"total"` // 总记录记录数量
}
ResponseImport 导出结果
func (*ResponseImport) CastInsert ¶
func (resp *ResponseImport) CastInsert(line int, data []map[string]string, model *Model) ([]string, [][]interface{})
CastInsert 数据格式转换
func (*ResponseImport) Error ¶
func (resp *ResponseImport) Error(mesage string, code int, args ...interface{}) *ErrorOfImport
Error 导入数据时错误
func (*ResponseImport) InsertChunk ¶
func (resp *ResponseImport) InsertChunk(line int, data []map[string]string, model *Model)
InsertChunk 导入数据 (insert)
func (*ResponseImport) IsError ¶
func (resp *ResponseImport) IsError(line int, process interface{}) bool
IsError 错误检查
type Schedule ¶
type Schedule struct {
Name string `json:"name"`
Process string `json:"process,omitempty"`
Schedule string `json:"schedule"`
TaskName string `json:"task,omitempty"`
Args []interface{} `json:"args,omitempty"`
Enabled bool
// contains filtered or unexported fields
}
Schedule the schedule struct
func LoadSchedule ¶
LoadSchedule load schedule
func SelectSchedule ¶
SelectSchedule select schedule by name
type Server ¶
type Server struct {
Debug bool `json:"debug,omitempty"`
Port int `json:"port,omitempty"`
Host string `json:"host,omitempty"`
Root string `json:"root,omitempty"` // API 根目录
Allows []string `json:"allows,omitempty"` // 许可跨域访问域名
}
Server API 服务配置
type Socket ¶
type Socket struct {
Name string `json:"name"`
Version string `json:"version"`
Mode string `json:"mode,omitempty"` // Server | client
Description string `json:"description,omitempty"`
Protocol string `json:"protocol,omitempty"`
Host string `json:"host,omitempty"`
Port string `json:"port,omitempty"`
Event SocketEvent `json:"event,omitempty"`
Timeout int `json:"timeout,omitempty"` // timeout (seconds)
BufferSize int `json:"buffer,omitempty"` // bufferSize
KeepAlive int `json:"keep,omitempty"` // -1 not keep alive, 0 keep alive always, keep alive n seconds.
Process string `json:"process,omitempty"`
AttemptAfter int `json:"attempt_after,omitempty"` // Attempt attempt_after
Attempts int `json:"attempts,omitempty"` // max times try to reconnect server when connection break (client mode only)
// contains filtered or unexported fields
}
Socket struct
func LoadSocket ¶
LoadSocket load socket server/client
type SocketEvent ¶
type SocketEvent struct {
Data string `json:"data,omitempty"`
Error string `json:"error,omitempty"`
Closed string `json:"closed,omitempty"`
Connected string `json:"connected,omitempty"`
}
SocketEvent struct
type Store ¶
type Store struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Connector string `json:"connector,omitempty"`
Type string `json:"type,omitempty"` // warning: type is deprecated in the future new version
Option map[string]interface{} `json:"option,omitempty"`
}
Store the kv-store setting
type Table ¶
type Table struct {
Name string `json:"name,omitempty"` // optional, if not set, the default is generate from model name. eg name.space.user, table name is name_space_user
Prefix string `json:"prefix,omitempty"` // optional, the table prefix
Comment string `json:"comment,omitempty"`
Engine string `json:"engine,omitempty"` // InnoDB,MyISAM ( MySQL Only )
Collation string `json:"collation"`
Charset string `json:"charset"`
PrimaryKeys []string `json:"primarykeys"`
}
Table the model mapping table in DB
type TaskOption ¶
type TaskOption struct {
Name string `json:"name"`
Process string `json:"process"`
Size interface{} `json:"size,omitempty"`
WorkerNums interface{} `json:"worker_nums,omitempty"`
AttemptAfter interface{} `json:"attempt_after,omitempty"`
Attempts interface{} `json:"attempts,omitempty"`
Timeout interface{} `json:"timeout,omitempty"`
Event struct {
Next string `json:"next,omitempty"`
Add string `json:"add,omitempty"`
Success string `json:"success,omitempty"`
Error string `json:"error,omitempty"`
Progress string `json:"progress,omitempty"`
} `json:"event"`
}
TaskOption the task option
type Template ¶
type Template struct{}
Template the Template DSL
func (*Template) DSLCompile ¶
DSLCompile compile the DSL
func (*Template) DSLRefresh ¶
DSLRefresh refresh the DSL
type UploadFile ¶ added in v0.10.2
type UploadFile struct {
Name string `json:"name"`
TempFile string `json:"tempFile"`
Size int64 `json:"size"`
Header textproto.MIMEHeader `json:"mimeType"`
}
UploadFile upload file
type ValidateResponse ¶
type ValidateResponse struct {
Line int `json:"line,omitempty"`
Column string `json:"column,omitempty"`
Messages []string `json:"messages,omitempty"`
}
ValidateResponse 数据校验返回结果
type Validation ¶
type Validation struct {
Method string `json:"method"`
Args []interface{} `json:"args,omitempty"`
Message string `json:"message,omitempty"`
}
Validation the field validation struct
type WebSocket ¶
type WebSocket struct {
websocket.WSClientOption
Event WebSocketEvent `json:"event,omitempty"`
Client *websocket.WSClient
}
WebSocket the websocket struct
func LoadWebSocket ¶
LoadWebSocket load websockets client
func SelectWebSocket ¶
SelectWebSocket Get WebSocket client by name
type WebSocketEvent ¶
type WebSocketEvent struct {
Data string `json:"data,omitempty"`
Error string `json:"error,omitempty"`
Closed string `json:"closed,omitempty"`
Connected string `json:"connected,omitempty"`
}
WebSocketEvent the websocket struct
type With ¶
type With struct {
Name string `json:"name"`
Query QueryParam `json:"query,omitempty"`
}
With relations 关联查询
Source Files
¶
- api.go
- api.http.go
- api.types.go
- api.ws.go
- column.go
- crypt.go
- crypt.types.go
- flow.dsl.go
- flow.go
- flow.process.go
- flow.types.go
- fs.go
- http.go
- import.go
- import.types.go
- index.go
- model.atomic.go
- model.dsl.go
- model.filter.go
- model.go
- model.migrate.go
- model.process.go
- model.types.go
- plugin.go
- plugin.types.go
- process.args.go
- process.go
- process.types.go
- query.go
- query.stack.go
- query.types.go
- query.url.go
- runtime.go
- schedule.go
- schema.go
- service.go
- socket.go
- socket.type.go
- store.go
- store.process.go
- store.types.go
- task.go
- template.go
- utils.go
- validation.go
- websocket.go
- websocket.type.go
- widget.go