修改gm模块为web模块

This commit is contained in:
liwei1dao 2022-07-25 16:35:35 +08:00
parent 4573ab8a64
commit 4e1db72bce
11 changed files with 32 additions and 32 deletions

View File

@ -29,7 +29,7 @@ const (
//模块名定义处
const (
ModuleGate core.M_Modules = "gateway" //gate模块 网关服务模块
ModuleGM core.M_Modules = "gm" //gm模块
ModuleWeb core.M_Modules = "web" //gm模块
ModuleUser core.M_Modules = "user" //用户模块
ModulePack core.M_Modules = "pack" //背包模块
ModuleMail core.M_Modules = "mail" //邮件模块

View File

@ -1,4 +1,4 @@
package gm
package web
import (
"go_dreamfactory/lego/core"
@ -15,7 +15,7 @@ import (
type Api_Comp struct {
cbase.ModuleCompBase
options *Options //模块参数
module *GM //当前模块对象
module *Web //当前模块对象
gin gin.ISys //gin 框架 web的热门框架
}
@ -23,7 +23,7 @@ type Api_Comp struct {
func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.ModuleCompBase.Init(service, module, comp, options)
this.options = options.(*Options)
this.module = module.(*GM)
this.module = module.(*Web)
this.gin, err = gin.NewSys(gin.SetListenPort(this.options.Port))
this.suitableMethods() //发射注册api
return

View File

@ -1,4 +1,4 @@
package gm
package web
import (
"go_dreamfactory/lego/sys/gin"

View File

@ -1,4 +1,4 @@
package gm
package web
import (
"go_dreamfactory/lego/sys/gin/engine"

View File

@ -1,4 +1,4 @@
package gm
package web
import (
"fmt"

View File

@ -1,4 +1,4 @@
package gm
package web
import "go_dreamfactory/pb"

View File

@ -1,4 +1,4 @@
package gm
package web
import (
"go_dreamfactory/lego/core"
@ -12,12 +12,12 @@ import (
//公告数据模块
type modelNotifyComp struct {
modules.MCompModel
module *GM
module *Web
}
func (this *modelNotifyComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
this.MCompModel.Init(service, module, comp, opt)
this.module = module.(*GM)
this.module = module.(*Web)
this.TableName = "notify"
return
}

View File

@ -1,4 +1,4 @@
package gm
package web
import (
"fmt"
@ -14,12 +14,12 @@ import (
//用户数据模块
type modelUserComp struct {
modules.MCompModel
module *GM
module *Web
}
func (this *modelUserComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
this.MCompModel.Init(service, module, comp, opt)
this.module = module.(*GM)
this.module = module.(*Web)
this.TableName = "user"
return
}

View File

@ -1,4 +1,4 @@
package gm
package web
import (
"fmt"
@ -9,16 +9,16 @@ import (
)
/*
模块名:gm
模块名:web
描述:提供管理员相关的http接口
开发:李伟
*/
func NewModule() core.IModule {
m := new(GM)
m := new(Web)
return m
}
type GM struct {
type Web struct {
cbase.ModuleBase
options *Options
api_comp *Api_Comp //提供weba pi服务的组件
@ -28,22 +28,22 @@ type GM struct {
}
//模块名
func (this *GM) GetType() core.M_Modules {
return comm.ModuleGM
func (this *Web) GetType() core.M_Modules {
return comm.ModuleWeb
}
//模块自定义参数
func (this *GM) NewOptions() (options core.IModuleOptions) {
func (this *Web) NewOptions() (options core.IModuleOptions) {
return new(Options)
}
func (this *GM) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
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 *GM) OnInstallComp() {
func (this *Web) OnInstallComp() {
this.ModuleBase.OnInstallComp()
this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
this.modelUser = this.RegisterComp(new(modelUserComp)).(*modelUserComp)
@ -52,32 +52,32 @@ func (this *GM) OnInstallComp() {
}
//日志
func (this *GM) Debugf(format string, a ...interface{}) {
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 *GM) Infof(format string, a ...interface{}) {
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 *GM) Warnf(format string, a ...interface{}) {
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 *GM) Errorf(format string, a ...interface{}) {
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 *GM) Panicf(format string, a ...interface{}) {
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 *GM) Fatalf(format string, a ...interface{}) {
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...)
}

View File

@ -1,4 +1,4 @@
package gm
package web
import (
"go_dreamfactory/lego/utils/mapstructure"

View File

@ -3,8 +3,8 @@ package main
import (
"flag"
"fmt"
"go_dreamfactory/modules/gm"
"go_dreamfactory/modules/mgolog"
"go_dreamfactory/modules/web"
"go_dreamfactory/services"
"go_dreamfactory/sys/cache"
"go_dreamfactory/sys/db"
@ -35,7 +35,7 @@ func main() {
)
lego.Run(s, //运行模块
mgolog.NewModule(),
gm.NewModule(),
web.NewModule(),
)
}