go_dreamfactory/modules/web/module.go

87 lines
2.4 KiB
Go

package web
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
)
/*
模块名:web
描述:提供管理员相关的http接口
开发:李伟
*/
func NewModule() core.IModule {
m := new(Web)
return m
}
type Web struct {
cbase.ModuleBase
options *Options
api_comp *Api_Comp //提供weba pi服务的组件
modelUser *modelUserComp
modelNotify *modelNotifyComp
modelMail *modelMailComp
configure *configureComp
}
//模块名
func (this *Web) GetType() core.M_Modules {
return comm.ModuleWeb
}
//模块自定义参数
func (this *Web) NewOptions() (options core.IModuleOptions) {
return new(Options)
}
func (this *Web) 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 *Web) 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.modelMail = this.RegisterComp(new(modelMailComp)).(*modelMailComp)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
}
//日志
func (this *Web) Debugf(format string, a ...interface{}) {
if this.options.GetDebug() {
this.options.GetLog().Debugf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
}
}
func (this *Web) Infof(format string, a ...interface{}) {
if this.options.GetDebug() {
this.options.GetLog().Infof(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
}
}
func (this *Web) Warnf(format string, a ...interface{}) {
if this.options.Debug {
this.options.GetLog().Warnf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
}
}
func (this *Web) Errorf(format string, a ...interface{}) {
if this.options.GetLog() != nil {
this.options.GetLog().Errorf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
}
}
func (this *Web) Panicf(format string, a ...interface{}) {
if this.options.GetLog() != nil {
this.options.GetLog().Panicf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
}
}
func (this *Web) Fatalf(format string, a ...interface{}) {
if this.options.GetLog() != nil {
this.options.GetLog().Fatalf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
}
}