85 lines
2.3 KiB
Go
85 lines
2.3 KiB
Go
package gm
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/core/cbase"
|
|
)
|
|
|
|
/*
|
|
模块名:gm
|
|
描述:提供管理员相关的http接口
|
|
开发:李伟
|
|
*/
|
|
func NewModule() core.IModule {
|
|
m := new(GM)
|
|
return m
|
|
}
|
|
|
|
type GM struct {
|
|
cbase.ModuleBase
|
|
options *Options
|
|
api_comp *Api_Comp //提供weba pi服务的组件
|
|
modelUser *modelUserComp
|
|
modelNotify *modelNotifyComp
|
|
configure *configureComp
|
|
}
|
|
|
|
//模块名
|
|
func (this *GM) GetType() core.M_Modules {
|
|
return comm.ModuleGM
|
|
}
|
|
|
|
//模块自定义参数
|
|
func (this *GM) NewOptions() (options core.IModuleOptions) {
|
|
return new(Options)
|
|
}
|
|
|
|
func (this *GM) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
|
err = this.ModuleBase.Init(service, module, options)
|
|
this.options = options.(*Options)
|
|
return
|
|
}
|
|
|
|
func (this *GM) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
|
|
this.modelUser = this.RegisterComp(new(modelUserComp)).(*modelUserComp)
|
|
this.modelNotify = this.RegisterComp(new(modelNotifyComp)).(*modelNotifyComp)
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
}
|
|
|
|
//日志
|
|
func (this *GM) Debugf(format string, a ...interface{}) {
|
|
if this.options.GetDebug() {
|
|
this.options.GetLog().Debugf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
|
|
}
|
|
}
|
|
func (this *GM) Infof(format string, a ...interface{}) {
|
|
if this.options.GetDebug() {
|
|
this.options.GetLog().Infof(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
|
|
}
|
|
}
|
|
func (this *GM) Warnf(format string, a ...interface{}) {
|
|
if this.options.Debug {
|
|
this.options.GetLog().Warnf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
|
|
}
|
|
}
|
|
func (this *GM) Errorf(format string, a ...interface{}) {
|
|
if this.options.GetLog() != nil {
|
|
this.options.GetLog().Errorf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
|
|
}
|
|
}
|
|
func (this *GM) Panicf(format string, a ...interface{}) {
|
|
if this.options.GetLog() != nil {
|
|
this.options.GetLog().Panicf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
|
|
}
|
|
}
|
|
func (this *GM) Fatalf(format string, a ...interface{}) {
|
|
if this.options.GetLog() != nil {
|
|
this.options.GetLog().Fatalf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
|
|
}
|
|
}
|