go_dreamfactory/modules/sys/model_sys.go
2022-11-24 16:57:53 +08:00

39 lines
887 B
Go

package sys
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
)
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, uid string) (code pb.ErrorCode) {
user := this.moduleSys.ModuleUser.GetUser(uid)
if user != nil {
conf := this.moduleSys.configure.getFuncCfg(funName)
if conf != nil {
if user.Lv < conf.Main{
code = pb.ErrorCode_NoOpened
return
}
}
}
return
}