From 621f50bff31f897e08fe181cf13311a89e5cc5b9 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Thu, 15 Sep 2022 20:33:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/sys/config.go | 9 +++++++++ modules/sys/model_sys.go | 30 ++++++++++++++++++++++++++++++ modules/sys/module.go | 9 +++++++++ 3 files changed, 48 insertions(+) create mode 100644 modules/sys/model_sys.go diff --git a/modules/sys/config.go b/modules/sys/config.go index 3547f4bdb..b86fef7bc 100644 --- a/modules/sys/config.go +++ b/modules/sys/config.go @@ -37,6 +37,15 @@ func (this *configureComp) getOpencondCfg() (data *cfg.GameOpencond, err error) return } +func (this *configureComp) getFuncCfg(funcName string) (data *cfg.GameOpencondData) { + if cfg, err := this.getOpencondCfg(); err != nil { + return nil + } else { + data = cfg.GetDataMap()[funcName] + } + return +} + func (this *configureComp) getOpencondList() (list []*cfg.GameOpencondData) { if cfg, err := this.getOpencondCfg(); err != nil { return nil diff --git a/modules/sys/model_sys.go b/modules/sys/model_sys.go new file mode 100644 index 000000000..e6feddb94 --- /dev/null +++ b/modules/sys/model_sys.go @@ -0,0 +1,30 @@ +package sys + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/modules" +) + +type ModelSys struct { + modules.MCompModel + moduleSys *ModuleSys + service core.IService +} + +func (this *ModelSys) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.TableName = comm.TableSys + err = this.MCompModel.Init(service, module, comp, options) + this.moduleSys = module.(*ModuleSys) + this.service = service + return +} + +// 是否允许访问功能,条件:玩家等级 +func (this *ModelSys) IsAccess(funName string, userLv int32) bool { + conf := this.moduleSys.configure.getFuncCfg(funName) + if conf != nil { + return userLv >= conf.Main + } + return false +} diff --git a/modules/sys/module.go b/modules/sys/module.go index e1b5cc7b9..a077ae4d4 100644 --- a/modules/sys/module.go +++ b/modules/sys/module.go @@ -6,10 +6,14 @@ import ( "go_dreamfactory/modules" ) +var _ comm.ISys = (*ModuleSys)(nil) + type ModuleSys struct { modules.ModuleBase api *apiComp configure *configureComp + + modelSys *ModelSys } func NewModule() core.IModule { @@ -19,9 +23,14 @@ func NewModule() core.IModule { func (this *ModuleSys) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api = this.RegisterComp(new(apiComp)).(*apiComp) + this.modelSys = this.RegisterComp(new(ModelSys)).(*ModelSys) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } func (this *ModuleSys) GetType() core.M_Modules { return comm.ModuleSys } + +func (this *ModuleSys) IsAccess(funcName string, userLv int32) bool { + return this.modelSys.IsAccess(funcName, userLv) +}