Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigDomain() *configDomain
- func CoreDomain() *coreDomain
- func CrontabDomain() *crontabDomain
- func DictDomain() *dictDomain
- func ExceptionDomain() *exceptionDomain
- func GetBirdClassName(classId int, name string) (string, string)
- func GetConfig() conf
- func HookDomain() *hookDomain
- func Md5(args ...interface{}) string
- func ModuleDomain() *moduleDomain
- func PermissionDomain() *permissionDomain
- func QueueDomain() *queueDomain
- func RouteDomain() *routeDomain
- func SetLogHandler(l Logger)
- func SetQueueTaskStore(t func(b *Bird) TaskStoreInterface)
- func Sha1(args ...interface{}) string
- type AppInterface
- type BaseQuery
- type Bird
- func (this *Bird) ConfigInit(confPtr ConfigInterface) ConfigInterface
- func (this *Bird) LogDebug(msg string, arg ...interface{})
- func (this *Bird) LogDebugf(msg string, fomrat string, arg ...interface{})
- func (this *Bird) LogFatal(msg string, arg ...interface{})
- func (this *Bird) LogFatalf(msg string, fomrat string, arg ...interface{})
- func (this *Bird) LogInfo(msg string, arg ...interface{})
- func (this *Bird) LogInfof(msg string, fomrat string, arg ...interface{})
- func (this *Bird) LogWarn(msg string, arg ...interface{})
- func (this *Bird) LogWarnf(msg string, fomrat string, arg ...interface{})
- func (this *Bird) SetHandler(name string) *Bird
- func (this *Bird) Single(name string, createFunc func() interface{}) interface{}
- type ComponentInterface
- type ConfigInfo
- type ConfigInterface
- type Configer
- type Context
- func (this *Context) BindCookie(objectPtr interface{}) *Context
- func (this *Context) BindForm(objectPtr interface{}) *Context
- func (this *Context) BindHead(objectPtr interface{}) *Context
- func (this *Context) BindJSON(objectPtr interface{}) *Context
- func (this *Context) BindQuery(objectPtr interface{}) *Context
- func (this *Context) Code(code int)
- func (this *Context) JSON(code int, res interface{}, msg string)
- func (this *Context) JWTClaims() *middleware.Claims
- func (this *Context) Msg(code int, msg string)
- func (this *Context) MultiHandler(key string, expireMinutes, times int, fn func())
- func (this *Context) Res(code int, data interface{})
- func (this *Context) Session() sessions.Session
- func (this *Context) UniqueHandler(key string, fn func())
- type CrontabInfo
- type CrontabInterface
- type Dict
- type DictItem
- type EventInfo
- type EventInterface
- type Exception
- type ExceptionBind
- type ExceptionInfo
- type ExceptionJWT
- type ExceptionPermission
- type H
- type Hook
- type HookInfo
- type JWT
- type Log
- type Logger
- type ModelInterface
- type ModuleInfo
- type ModuleInterface
- type Permission
- type QueueInfo
- type QueueInterface
- type RouteInfo
- type Task
- type TaskStoreInterface
- type X
Constants ¶
View Source
const ( BIRD_CLASS_FREE = 1 //系统(自由鸟) BIRD_CLASS_ROUTER = 2 //路由 BIRD_CLASS_QUEUE = 3 //队列 BIRD_CLASS_CRONTAB = 4 //定时任务 BIRD_CLASS_EVENT = 5 //钩子 )
划分鸟类
View Source
const ( LOG_DEBUG = 1 LOG_INFO = 2 LOG_WARN = 3 LOG_FATAL = 4 )
View Source
const ( FORMAT_DATE = "2006-01-02" FORMAT_DATETIME = "2006-01-02 15:04:05" )
日期格式
View Source
const ( CONFIG_DIR = "./config" RUNTIME_DIR = "./runtime" )
View Source
const ( HOOK_SYNC = 0 //同步(默认) HOOK_ASYNC = 1 //异步 )
View Source
const GIN_KEY_BIRD = "gin_key_bird"
存鸟类的key
Variables ¶
View Source
var OrmEngine *xorm.Engine
Functions ¶
func CoreDomain ¶
func CoreDomain() *coreDomain
func DictDomain ¶
func DictDomain() *dictDomain
func ExceptionDomain ¶
func ExceptionDomain() *exceptionDomain
func HookDomain ¶
func HookDomain() *hookDomain
func QueueDomain ¶
func QueueDomain() *queueDomain
func RouteDomain ¶
func RouteDomain() *routeDomain
Types ¶
type AppInterface ¶
type AppInterface interface {
Init(*gin.Engine) //站点初始化执行方法(可以放一些中间件处理的东西)
Modules() []ModuleInterface //加载需要的模块
PermissionHandler(*gin.Context, *Permission) bool //权限处理(使用Throw中断)
Install(*Bird) //安装入口
Debug() func() //调试方法,如果此方法不为空,则不启动web服务且优先执行,专门用于紧急调试使用
}
应用接口
type Bird ¶
type Bird struct {
orm.Engine //集成orm引擎
Context *Context //请求上下文(如果不是http请求则为nil)
sync.Mutex
// contains filtered or unexported fields
}
鸟上下文,所有控制器部分都贯穿着这只鸟,建议所有模型、组件都继承这只鸟 可以更方便实现事务的同步
func (*Bird) ConfigInit ¶
func (this *Bird) ConfigInit(confPtr ConfigInterface) ConfigInterface
初始化配置,并自动获取配置(为避免程序运行中修改配置,获取的对象值为克隆值)
type ComponentInterface ¶
type ComponentInterface interface {
Models() []ModelInterface //数据库模型
}
组件接口
type ConfigInfo ¶
type ConfigInfo struct {
ModuleName string `json:"moduleName"` //模块名
Name string `json:"name"` //配置名称
Alias string `json:"alias"` //配置别名
Filename string `json:"file"` //文件
// contains filtered or unexported fields
}
查询结构
type ConfigInterface ¶
type ConfigInterface interface {
Default() ConfigInterface //默认配置
Name() string //配置名称
Alias() string //配置别名
Validate() error //验证
}
配置接口
type Context ¶
升级版context
func (*Context) BindCookie ¶
绑定cookie
func (*Context) MultiHandler ¶
当key在有效期expireMinutes内被调用了times次则执行fn
func (*Context) UniqueHandler ¶
session单例处理器,可以处理阅读、点击之类的数据 如果session里面未保存key,则执行fn
type CrontabInfo ¶
type CrontabInfo struct {
ModuleName string `json:"moduleName"`
Name string `json:"name"` //名称
Expression string `json:"expression"` //表达式
// contains filtered or unexported fields
}
查询结构
type CrontabInterface ¶
type CrontabInterface interface {
Name() string //任务名称
Expression() string //定时时间表达式
Handler(*Bird) //执行方法
}
定时任务接口
type Dict ¶
type Dict struct {
Alias string `json:"alias"` //字典别名
Name string `json:"name"` //字典名称
ModuleName string `json:"moduleName"` //字典所在模块名
Items []*DictItem `json:"items"` //字典
}
字典
type DictItem ¶
type DictItem struct {
Const string `json:"const"` //常量名
Label string `json:"label"` //名称
Value interface{} `json:"value"` //值
Desc string `json:"desc"` //描述
}
字典列表
type EventInfo ¶
type EventInfo struct {
HookId string `json:"hookId"`
Name string `json:"name"` //事件名称
ModuleName string `json:"moduleName"`
// contains filtered or unexported fields
}
查询结构
type EventInterface ¶
type EventInterface interface {
HookId() string //事件id
Handler(b *Bird, args ...interface{}) //事件处理方法
}
事件接口
type ExceptionBind ¶
type ExceptionBind struct {
Field string
try.ExceptionBase
}
数据绑定错误
func (*ExceptionBind) Name ¶
func (this *ExceptionBind) Name() string
type ExceptionInfo ¶
type ExceptionInfo struct {
Id string `json:"id"` //异常id
Name string `json:"name"` //异常名称
Code int `json:"code"` //返回的错误代码
LogLevel int `json:"logLevel"` //日志记录级别
ModuleName string `json:"moduleName"` //模块名称
}
异常类型
type ExceptionJWT ¶
type ExceptionJWT struct {
try.ExceptionBase
}
jwt异常【未登录】
func (*ExceptionJWT) Name ¶
func (this *ExceptionJWT) Name() string
type ExceptionPermission ¶
type ExceptionPermission struct {
try.ExceptionBase
}
权限错误
func (*ExceptionPermission) Name ¶
func (this *ExceptionPermission) Name() string
type Hook ¶
type Hook struct {
Id string `json:"id"` //钩子id
Name string `json:"name"` //钩子名称
Mode int `json:"mode"` //钩子类型(1=同步,2=异步)
ArgsDesc string `json:"desc"` //参数说明
}
钩子
type HookInfo ¶
type HookInfo struct {
HookId string `json:"hookId"` //编号
Name string `json:"name"` //名称
ModuleName string `json:"moduleName"` //所属模块名
Mode int `json:"mode"` //钩子类型
ModeName string `json:"modeName"` //钩子类型
ArgsDesc string `json:"argsDesc"` //参数说明
Events []*EventInfo `json:"events"` //已经注册的事件
}
查询结构
type Log ¶
type Log struct {
BirdId int64 //保证是一个请求发起的
Msg string //日志标题
BirdClass int //鸟类
BirdName string //鸟名
Level int //日志等级
Handler string //操作人
IP string //操作ip
Data interface{} //错误内容
}
日志结构
type ModuleInfo ¶
type ModuleInfo struct {
Name string `json:"name"`
Components int `json:"components"` //组件数量
Dicts int `json:"dicts"` //字典数量
Events int `json:"events"` //注册事件数量
Hooks int `json:"hooks"` //钩子数量
Tables int `json:"tables"` //数据库数量
Configs int `json:"configs"` //配置列表
// contains filtered or unexported fields
}
type ModuleInterface ¶
type ModuleInterface interface {
Install(*Bird)
ModuleName() string //模块名称
Init(*gin.Engine) //模块初始化,此处可放置路由
Exceptions() []Exception //异常列表
Crontabs() []CrontabInterface //定时任务
Queues() []QueueInterface //队列
Components() []ComponentInterface //组件
Hooks() []*Hook //钩子列表(注册后的事件才能使用)
Events() []EventInterface //事件列表(自动寻找对应钩子)
Dicts() []*Dict //数据字典
}
模块接口
type Permission ¶
type Permission struct {
Id string `json:"id"` //权限id
Pid string `json:"pid"` //权限上级id
Name string `json:"name"` //权限名
Childs []*Permission `json:"childs"` //子权限
}
权限
func (*Permission) Child ¶
func (this *Permission) Child(id string, name string) *Permission
生成子权限 id不能重复
func (*Permission) Watch ¶
func (this *Permission) Watch(fn gin.HandlerFunc) gin.HandlerFunc
监视并拦截,fn可以为nil
type QueueInfo ¶
type QueueInfo struct {
ModuleName string `json:"moduleName"`
Alias string `json:"alias"` //队列别名
Name string `json:"name"` //名称
// contains filtered or unexported fields
}
查询结构
type QueueInterface ¶
type QueueInterface interface {
Name() string //任务名称【唯一】
Alias() string //任务别名【唯一】
Handler(*Bird, *Task) //执行方法
}
队列任务接口
Source Files
¶
Click to show internal directories.
Click to hide internal directories.