package sys import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) 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 { this.validCond(uid, conf) } } return } func (this *ModelSys) validCond(uid string, condData *cfg.GameOpencondData) string { var flag bool for _, conf := range condData.Main { switch conf.Key { case 1: //等级 iuser := this.moduleSys.ModuleUser user := iuser.GetUser(uid) if user == nil { flag = false return "" } if user.Lv >= conf.Param { flag = true }else{ flag = false } case 2: //关卡ID iuser := this.moduleSys.ModuleUser ex, err := iuser.GetUserExpand(uid) if err != nil { flag = false return "" } if ex.Uid == "" { flag = false return "" } if v, ok := ex.Mline[1]; ok { if v >= conf.Param { flag = true }else{ flag = false } }else{ flag = false } case 3: //世界任务ID module, err := this.service.GetModule(comm.ModuleWorldtask) if err != nil { this.moduleSys.Debugln(err) flag = false return "" } if i, ok := module.(comm.IWorldtask); ok { d := i.GetMyWorldtask(uid) if _, ok := d.LastTaskIds[conf.Param]; ok { flag = true }else{ flag = false } }else{ flag = false } } } if flag { return condData.Id } return "" }