Documentation ¶
Index ¶
- Constants
- func CheckSqlError(err error)
- type AppInterface
- type BaseQuery
- type ComponentInterface
- type ConfigInterface
- type Configer
- type CrontabInterface
- type EventInterface
- type HandlerFunc
- type HookInterface
- type LogLevel
- type Logger
- type MaoConfigInterface
- type MaoLogInterface
- type Model
- func (this *Model) Alias(alias string) string
- func (this *Model) Cols(cols ...string) *Model
- func (this *Model) Create() bool
- func (this *Model) Delete() bool
- func (this *Model) Exists() bool
- func (this *Model) Get() bool
- func (this *Model) Match(column string, data any) *Model
- func (this *Model) Must(cols ...string) *Model
- func (this *Model) Omit(cols ...string) *Model
- func (this *Model) SetData(data any) *Model
- func (this *Model) SetTableName(tableName string)
- func (this *Model) TableName() string
- func (this *Model) Update() bool
- func (this *Model) Where(query string, args ...any) *Model
- type ModelInterface
- type Module
- type ModuleInterface
- type NoWebInterface
- type Permission
- type Router
- type RouterGroup
- func (this *RouterGroup) Any(relativePath string, handlers ...HandlerFunc) *Router
- func (this *RouterGroup) DELETE(relativePath string, handlers ...HandlerFunc) *Router
- func (this *RouterGroup) GET(relativePath string, handlers ...HandlerFunc) *Router
- func (this *RouterGroup) Group(relativePath string, handlers ...HandlerFunc) *RouterGroup
- func (this *RouterGroup) POST(relativePath string, handlers ...HandlerFunc) *Router
- func (this *RouterGroup) PUT(relativePath string, handlers ...HandlerFunc) *Router
- func (this *RouterGroup) Permission(name string, code ...string) *RouterGroup
- func (this *RouterGroup) Use(middleware ...HandlerFunc)
- type RunMode
- type Server
- func (this *Server) GetComponents() []ComponentInterface
- func (this *Server) GetModules() []ModuleInterface
- func (this *Server) InstallModule(module ModuleInterface)
- func (this *Server) LoadModule(module ModuleInterface)
- func (this *Server) RemoveModule()
- func (this *Server) Run()
- func (this *Server) TaskLine() *Taskline
- type SetSetTaskLiner
- type Taskline
- func (this *Taskline) Config() MaoConfigInterface
- func (this *Taskline) FindPage(db *xorm.Session, listPtr interface{}, page, limit int) int64
- func (this *Taskline) GetTaskid() int64
- func (this *Taskline) LogDebug(args ...any)
- func (this *Taskline) LogDebugf(format string, args ...any)
- func (this *Taskline) LogError(args ...any)
- func (this *Taskline) LogErrorf(format string, args ...any)
- func (this *Taskline) LogInfo(args ...any)
- func (this *Taskline) LogInfof(format string, args ...any)
- func (this *Taskline) LogWarn(args ...any)
- func (this *Taskline) LogWarnf(format string, args ...any)
- func (this *Taskline) Mutex() *sync.Mutex
- func (this *Taskline) NewTaskLine() *Taskline
- func (this *Taskline) OrmModel(model ModelInterface) ModelInterface
- func (this *Taskline) OrmSession() *xorm.Session
- func (this *Taskline) OrmTable(bean any) *xorm.Session
- func (this *Taskline) PutHook(h HookInterface)
- func (this *Taskline) RenderConfig(conf ConfigInterface) ConfigInterface
- func (this *Taskline) Transaction(fn func())
- func (this *Taskline) UseEngine(engine *xorm.Engine)
- type WebEngine
- type Webline
- func (this *Webline) BindCookie(objectPtr interface{})
- func (this *Webline) BindForm(objectPtr interface{})
- func (this *Webline) BindJSON(objectPtr interface{})
- func (this *Webline) BindQuery(objectPtr interface{})
- func (this *Webline) GetPermissionList() []*Permission
- func (this *Webline) GetRouterName() string
- func (this *Webline) IsMobile() bool
- func (this *Webline) JSON(code int32, result any, msg ...any)
Constants ¶
View Source
const ( DIR_CONFIG = "./config" DIR_RUNTIME = "./runtime" DIR_LOGS = "./logs" )
View Source
const ( CODE_ERROR = 510 //错误但不致命 CODE_SQL = 511 //sql错误 CODE_FATAL = 512 //致命错误 CODE_WARN = 600 //错误警告3 )
错误代号[600以下的保存到日志,600以上的不保存]
View Source
const (
VERSION = "1.0.24"
)
Variables ¶
This section is empty.
Functions ¶
func CheckSqlError ¶
func CheckSqlError(err error)
Types ¶
type AppInterface ¶
type AppInterface interface { Init(*WebEngine) //站点初始化执行方法(可以放一些中间件处理的东西) Config() any //配置文件路径 Modules() []ModuleInterface //加载需要的模块 Install() error //安装入口 CheckPermission(webline *Webline, code, name string) //权限验证 Version() string //当前版本号 }
应用接口
type ComponentInterface ¶
type ComponentInterface interface { CompName() string //组件名称 Models() []ModelInterface //数据库模型 }
组件接口
type ConfigInterface ¶
type ConfigInterface interface { Default() ConfigInterface //默认配置 BeforeGet() //请求前 ConfigName() string //配置名称 ConfigAlias() string //配置别名 Validate() error //验证 }
配置接口
type Configer ¶
type Configer interface {
Config() ConfigInterface
}
type CrontabInterface ¶
type CrontabInterface interface { Name() string //任务名称 Schedule() string //定时时间表达式 Handler(*Taskline) //执行方法 }
定时任务接口
type EventInterface ¶
type EventInterface interface { HookCode() string //钩子代号,必须对应 Handler(m *Taskline, arg HookInterface) //事件处理方法 }
事件接口
type HandlerFunc ¶
type HandlerFunc = func(*Webline)
type HookInterface ¶
钩子接口
type MaoConfigInterface ¶
type MaoConfigInterface interface { Section(name string) *ini.Section Get(c ConfigInterface) ConfigInterface GetByAlias(alias string) ConfigInterface Save(confPtr ConfigInterface) }
type MaoLogInterface ¶
type ModelInterface ¶
type ModelInterface interface { TableName() string PrimaryKey() any //主键 SetTableName(string) //设置表名 // contains filtered or unexported methods }
模型接口
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
任务线包装,用给模块组合使用
func (*Module) SetTaskline ¶
type ModuleInterface ¶
type ModuleInterface interface { Install() //执行安装操作 ModuleName() string //模块名称 Enable() bool //是否启用,为false时自动限制接口访问 Init(*WebEngine) //模块初始化,此处可放置路由 Crontabs() []CrontabInterface //定时任务 Components() []ComponentInterface //组件 Hooks() []HookInterface //钩子列表(注册后的事件才能使用) Events() []EventInterface //事件列表(自动寻找对应钩子) }
模块接口
type Permission ¶
type Permission struct { Name string `json:"name"` Id string `json:"id"` Childs []*Permission `json:"childs"` Pid string `json:"pid"` }
权限输出
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
func (*RouterGroup) Any ¶
func (this *RouterGroup) Any(relativePath string, handlers ...HandlerFunc) *Router
func (*RouterGroup) DELETE ¶
func (this *RouterGroup) DELETE(relativePath string, handlers ...HandlerFunc) *Router
func (*RouterGroup) GET ¶
func (this *RouterGroup) GET(relativePath string, handlers ...HandlerFunc) *Router
GET请求
func (*RouterGroup) Group ¶
func (this *RouterGroup) Group(relativePath string, handlers ...HandlerFunc) *RouterGroup
func (*RouterGroup) POST ¶
func (this *RouterGroup) POST(relativePath string, handlers ...HandlerFunc) *Router
func (*RouterGroup) PUT ¶
func (this *RouterGroup) PUT(relativePath string, handlers ...HandlerFunc) *Router
func (*RouterGroup) Permission ¶
func (this *RouterGroup) Permission(name string, code ...string) *RouterGroup
权限配置使用
func (*RouterGroup) Use ¶
func (this *RouterGroup) Use(middleware ...HandlerFunc)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(app AppInterface) *Server
type Taskline ¶
type Taskline struct {
// contains filtered or unexported fields
}
func (*Taskline) OrmModel ¶
func (this *Taskline) OrmModel(model ModelInterface) ModelInterface
实例化一个对象【泛型】
func (*Taskline) RenderConfig ¶
func (this *Taskline) RenderConfig(conf ConfigInterface) ConfigInterface
根据配置接口读取配置信息
type WebEngine ¶
type WebEngine struct {
RouterGroup
}
func (*WebEngine) MiddleSign ¶
func (this *WebEngine) MiddleSign() HandlerFunc
签名中间件 计算规则 sign=SHA256()
Click to show internal directories.
Click to hide internal directories.