diff --git a/cmd/v2/FyneApp.toml b/cmd/v2/FyneApp.toml index 9d5c6f92b..dff6c88bf 100644 --- a/cmd/v2/FyneApp.toml +++ b/cmd/v2/FyneApp.toml @@ -4,5 +4,5 @@ Website = "http://legu.cc" Icon = "app.png" Name = "RobotGUI" ID = "cc.legu.app" - Version = "1.0.20" - Build = 23 + Version = "1.0.21" + Build = 25 diff --git a/cmd/v2/service/sshService.go b/cmd/v2/service/sshService.go index 8c8d90d69..c7933bf02 100644 --- a/cmd/v2/service/sshService.go +++ b/cmd/v2/service/sshService.go @@ -300,6 +300,7 @@ func (ss *SSHService) ScpDownload(localDir, remoteFilePath string) error { fileName := path.Base(remoteFile.Name()) if err := os.MkdirAll(localDir, fs.ModePerm); err != nil { + logrus.Error(err) return err } diff --git a/comm/imodule.go b/comm/imodule.go index 8e50291ec..5506cd7a7 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -145,7 +145,7 @@ type ( IRtask interface { // 条件校验 CheckCondi(uid string, condiId int32) (code pb.ErrorCode) - // 远程条件校验 + // 远程任务条件校验 RemoteCheckCondi(uid string, condiId int32, rsp *pb.DBRtaskRecord) error //任务触发 SendToRtask(session IUserSession, rtaskType TaskType, params ...int32) (code pb.ErrorCode) diff --git a/modules/arena/modelarena.go b/modules/arena/modelarena.go index 60f21428a..879561b60 100644 --- a/modules/arena/modelarena.go +++ b/modules/arena/modelarena.go @@ -90,7 +90,7 @@ func (this *modelArena) queryUserHeros(uid string, heroids []string) (results [] var ( model *db.DBModel ) - if model, err = this.module.GetDBNoduleByUid(uid, comm.TableHero, time.Hour); err != nil { + if model, err = this.module.GetDBModuleByUid(uid, comm.TableHero, time.Hour); err != nil { this.module.Errorln(err) return } diff --git a/modules/equipment/modelEquipment.go b/modules/equipment/modelEquipment.go index a3f81948e..7075139e4 100644 --- a/modules/equipment/modelEquipment.go +++ b/modules/equipment/modelEquipment.go @@ -56,7 +56,7 @@ func (this *modelEquipmentComp) QueryUserEquipments(uId string) (equipments []*p ) equipments = make([]*pb.DB_Equipment, 0) if this.module.IsCross() { - if model, err = this.module.GetDBNoduleByUid(uId, this.TableName, this.Expired); err != nil { + if model, err = this.module.GetDBModuleByUid(uId, this.TableName, this.Expired); err != nil { this.module.Errorln(err) } else { if err = model.GetList(uId, &equipments); err != nil { @@ -121,7 +121,7 @@ func (this *modelEquipmentComp) AddEquipments(session comm.IUserSession, cIds ma model *db.DBModel ) if this.module.IsCross() { - if model, err = this.module.GetDBNoduleByUid(uId, this.TableName, this.Expired); err != nil { + if model, err = this.module.GetDBModuleByUid(uId, this.TableName, this.Expired); err != nil { this.module.Errorln(err) } else { if err = model.AddLists(uId, add); err != nil { @@ -145,7 +145,7 @@ func (this *modelEquipmentComp) addEquipment(equip *pb.DB_Equipment) (err error) model *db.DBModel ) if this.module.IsCross() { - if model, err = this.module.GetDBNoduleByUid(equip.UId, this.TableName, this.Expired); err != nil { + if model, err = this.module.GetDBModuleByUid(equip.UId, this.TableName, this.Expired); err != nil { this.module.Errorln(err) } else { if err = model.AddList(equip.UId, equip.Id, equip); err != nil { @@ -169,7 +169,7 @@ func (this *modelEquipmentComp) DelEquipments(uId string, eIds []string) (change ) change = make([]*pb.DB_Equipment, 0) if this.module.IsCross() { - if model, err = this.module.GetDBNoduleByUid(uId, this.TableName, this.Expired); err != nil { + if model, err = this.module.GetDBModuleByUid(uId, this.TableName, this.Expired); err != nil { this.module.Errorln(err) } else { if err = model.DelListlds(uId, eIds...); err != nil { @@ -199,7 +199,7 @@ func (this *modelEquipmentComp) UpdateByHeroId(uid string, equipments ...*pb.DB_ model *db.DBModel ) if this.module.IsCross() { - if model, err = this.module.GetDBNoduleByUid(uid, this.TableName, this.Expired); err != nil { + if model, err = this.module.GetDBModuleByUid(uid, this.TableName, this.Expired); err != nil { this.module.Errorln(err) } else { for _, v := range equipments { diff --git a/modules/gm/module.go b/modules/gm/module.go index af5bb68d1..98551806b 100644 --- a/modules/gm/module.go +++ b/modules/gm/module.go @@ -124,7 +124,7 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC this.Errorf("资源发放失败,%v", code) } } - this.Debugf("使用bingo命令", log.Fields{"uid": session.GetUserId()}, datas[0], res) + this.Debug("使用bingo命令", log.Fields{"uid": session.GetUserId(), "param": datas[0], "res": res}) } else if len(datas) == 3 && (datas[0] == "worldtask") { module, err := this.service.GetModule(comm.ModuleWorldtask) if err != nil { @@ -132,7 +132,7 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC } if wt, ok := module.(comm.IWorldtask); ok { if err = wt.BingoJumpTask(session, utils.ToInt32(datas[1]), utils.ToInt32(datas[2])); err != nil { - this.Errorf("bingo worldTask Failed ,Parameter :%s,%s %v", datas[1], datas[2], err) + this.Error("bingo 世界任务", log.Fields{"params": datas, "err": err.Error()}) } } diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 24abc6eb9..7851680a1 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -132,7 +132,7 @@ func (this *ModelHero) initHeroOverlying(uid string, heroCfgId string, count int if hero != nil { hero.SameCount = count if this.moduleHero.IsCross() { - if model, err = this.moduleHero.GetDBNoduleByUid(uid, this.TableName, this.Expired); err != nil { + if model, err = this.moduleHero.GetDBModuleByUid(uid, this.TableName, this.Expired); err != nil { this.moduleHero.Errorln(err) } else { if err = model.AddList(uid, hero.Id, hero); err != nil { @@ -153,7 +153,7 @@ func (this *ModelHero) initHeroOverlying(uid string, heroCfgId string, count int func (this *ModelHero) createHeroOverlying(uid string, heroCfgId string, count int32) (hero *pb.DBHero, err error) { heros := make([]*pb.DBHero, 0) if this.moduleHero.IsCross() { - if dbModel, err := this.moduleHero.GetDBNoduleByUid(uid, this.TableName, this.Expired); err != nil { + if dbModel, err := this.moduleHero.GetDBModuleByUid(uid, this.TableName, this.Expired); err != nil { this.moduleHero.Errorln(err) } else { @@ -178,7 +178,7 @@ func (this *ModelHero) createHeroOverlying(uid string, heroCfgId string, count i hero = h if this.moduleHero.IsCross() { - if model, err := this.moduleHero.GetDBNoduleByUid(uid, this.TableName, this.Expired); err != nil { + if model, err := this.moduleHero.GetDBModuleByUid(uid, this.TableName, this.Expired); err != nil { this.moduleHero.Errorln(err) } else { if err := model.ChangeList(uid, h.Id, data); err != nil { diff --git a/modules/horoscope/modelhoroscope.go b/modules/horoscope/modelhoroscope.go index a8e02b1b8..6662532da 100644 --- a/modules/horoscope/modelhoroscope.go +++ b/modules/horoscope/modelhoroscope.go @@ -51,7 +51,7 @@ func (this *modelHoroscope) updateInfo(session comm.IUserSession, info *pb.DBHor "nodes": info.Nodes, "lastrest": info.Lastrest, }) - if model, err = this.module.GetDBNoduleByUid(info.Uid, this.TableName, time.Hour); err != nil { + if model, err = this.module.GetDBModuleByUid(info.Uid, this.TableName, time.Hour); err != nil { this.module.Errorln(err) return } diff --git a/modules/items/modelitems.go b/modules/items/modelitems.go index 6a2b4ed89..af7b723f9 100644 --- a/modules/items/modelitems.go +++ b/modules/items/modelitems.go @@ -41,7 +41,7 @@ func (this *ModelItemsComp) QueryUserPack(uId string) (itmes []*pb.DB_UserItemDa ) itmes = make([]*pb.DB_UserItemData, 0) if this.module.IsCross() { - if model, err = this.module.GetDBNoduleByUid(uId, this.TableName, this.Expired); err != nil { + if model, err = this.module.GetDBModuleByUid(uId, this.TableName, this.Expired); err != nil { this.module.Errorln(err) } else { if err = model.GetList(uId, &itmes); err != nil { @@ -65,7 +65,7 @@ func (this *ModelItemsComp) QueryUserPackByGridId(uId string, grid string) (itme itme = &pb.DB_UserItemData{} if this.module.IsCross() { - if model, err = this.module.GetDBNoduleByUid(uId, this.TableName, this.Expired); err != nil { + if model, err = this.module.GetDBModuleByUid(uId, this.TableName, this.Expired); err != nil { this.module.Errorln(err) } else { if err = model.GetListObj(uId, grid, itme); err != nil { @@ -91,7 +91,7 @@ func (this *ModelItemsComp) AddUserPack(uId string, itmes ...*pb.DB_UserItemData model *db.DBModel ) if this.module.IsCross() { - if model, err = this.module.GetDBNoduleByUid(uId, this.TableName, this.Expired); err != nil { + if model, err = this.module.GetDBModuleByUid(uId, this.TableName, this.Expired); err != nil { this.module.Errorln(err) } else { if err = model.AddLists(uId, data); err != nil { @@ -113,7 +113,7 @@ func (this *ModelItemsComp) UpdateUserPack(uid string, itmes ...*pb.DB_UserItemD model *db.DBModel ) if this.module.IsCross() { - if model, err = this.module.GetDBNoduleByUid(uid, this.TableName, this.Expired); err != nil { + if model, err = this.module.GetDBModuleByUid(uid, this.TableName, this.Expired); err != nil { this.module.Errorln(err) } else { for _, v := range itmes { @@ -147,7 +147,7 @@ func (this *ModelItemsComp) DeleteUserPack(uid string, itmes ...*pb.DB_UserItemD gridIds[i] = v.GridId } if this.module.IsCross() { - if model, err = this.module.GetDBNoduleByUid(uid, this.TableName, this.Expired); err != nil { + if model, err = this.module.GetDBModuleByUid(uid, this.TableName, this.Expired); err != nil { this.module.Errorln(err) } else { if err = model.DelListlds(uid, gridIds...); err != nil { diff --git a/modules/linestory/api_maintask.go b/modules/linestory/api_maintask.go index 8a6b8d1df..c26e042e4 100644 --- a/modules/linestory/api_maintask.go +++ b/modules/linestory/api_maintask.go @@ -2,6 +2,7 @@ package linestory import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -10,6 +11,7 @@ import ( // 支线剧情-我的主线任务 func (this *apiComp) MaintaskCheck(session comm.IUserSession, req *pb.LinestoryMaintaskReq) (code pb.ErrorCode) { if req.ChapterId == 0 { + this.moduleLinestory.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) code = pb.ErrorCode_ReqParameterError } return diff --git a/modules/linestory/api_receive.go b/modules/linestory/api_receive.go index 187cd9bcb..c86c5d12e 100644 --- a/modules/linestory/api_receive.go +++ b/modules/linestory/api_receive.go @@ -12,6 +12,7 @@ import ( // 章节奖励领取 func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.LinestoryReceiveReq) (code pb.ErrorCode) { if req.ChapterId == 0 { + this.moduleLinestory.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) code = pb.ErrorCode_ReqParameterError } return @@ -24,7 +25,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.LinestoryReceive uid := session.GetUserId() conf := this.moduleLinestory.configure.getChapterCfgById(req.ChapterId) if conf == nil { - log.Errorf("config is nil uid:%v groupId:%v", uid, req.ChapterId) + this.moduleLinestory.Error("配置未找到", log.Fields{"uid": uid, "chapterId": req.ChapterId}) code = pb.ErrorCode_ConfigNoFound return } @@ -42,7 +43,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.LinestoryReceive //发奖 if code := this.moduleLinestory.DispenseRes(session, conf.Reward, true); code != pb.ErrorCode_Success { - this.moduleLinestory.Errorf("奖励发放失败 uid:%v groupId:%v reward:%v", uid, req.ChapterId, conf.Reward) + this.moduleLinestory.Error("奖励发放失败", log.Fields{"uid": uid, "chapterId": req.ChapterId, "reward": conf.Reward}) } rsp := &pb.LinestoryReceiveResp{ diff --git a/modules/linestory/model_linestory.go b/modules/linestory/model_linestory.go index 6ccb87d6e..baaa288f9 100644 --- a/modules/linestory/model_linestory.go +++ b/modules/linestory/model_linestory.go @@ -58,6 +58,7 @@ func (this *ModelLinestory) getMaintasks(uid string, groupId int32) (list []*pb. if iwt, ok := module.(comm.IWorldtask); ok { // 获取玩家世界任务 wt := iwt.GetMyWorldtask(uid) + this.moduleLinestory.Debug("获取玩家世界任务", log.Fields{"uid": uid, "groupId": groupId, "worldtask": wt}) if wt != nil { mainTasks := this.moduleLinestory.configure.getMainTaskCfgByGroup(groupId) for _, conf := range mainTasks { @@ -66,11 +67,10 @@ func (this *ModelLinestory) getMaintasks(uid string, groupId int32) (list []*pb. if conf.Id == task.TaskId { list = append(list, &pb.TaskMain{ TaskId: conf.Id, - Status: 2, + Status: 1, }) } } - } } } diff --git a/modules/linestory/module.go b/modules/linestory/module.go index dd4c5fed3..a33a1442d 100644 --- a/modules/linestory/module.go +++ b/modules/linestory/module.go @@ -58,27 +58,45 @@ func (this *ModuleLinestory) Start() (err error) { func (this *ModuleLinestory) TaskFinishNotify(uid string, taskId, groupId int32) error { ls := this.modelLinestory.getLinestory(uid) - if v, ok := ls.TaskChapter[groupId]; ok { - if _, ok := utils.Findx(v.TaskIds, taskId); !ok { - v.TaskIds = append(v.TaskIds, taskId) + var isUpdate bool + if chapter, ok := ls.TaskChapter[groupId]; ok { + if _, ok := utils.Findx(chapter.TaskIds, taskId); !ok { + chapter.TaskIds = append(chapter.TaskIds, taskId) taskIds := this.configure.converArr(groupId) // 校验当前组下的任务是否全部完成 - if utils.ForContainer(taskIds, v.TaskIds) { + if utils.ForContainer(taskIds, chapter.TaskIds) { //说明组里的所有任务完成 - v.Receive = 1 - v.Status = 1 + chapter.Receive = 1 + chapter.Status = 1 } + + // 重置任务ID + if conf, ok := this.confMaintask.GetDataMap()[taskId]; ok { + if conf.Group == groupId { + var newTaskList []int32 + for _, v := range conf.Resetto { + newTaskList = utils.Deletex(chapter.TaskIds, v) + } + chapter.TaskIds = newTaskList + } + } + isUpdate = true } } else { tg := &pb.TaskChapter{} + // 设置完成的任务 tg.TaskIds = append(tg.TaskIds, taskId) if ls.TaskChapter == nil { ls.TaskChapter = make(map[int32]*pb.TaskChapter) } ls.TaskChapter[groupId] = tg + isUpdate = true } - update := map[string]interface{}{ - "taskChapter": ls.TaskChapter, + if isUpdate { + update := map[string]interface{}{ + "taskChapter": ls.TaskChapter, + } + return this.modelLinestory.Change(uid, update) } - return this.modelLinestory.Change(uid, update) + return nil } diff --git a/modules/modulebase.go b/modules/modulebase.go index e72005408..97136de46 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -391,7 +391,7 @@ func (this *ModuleBase) GetDBNodule(session comm.IUserSession, tableName string, } //跨服对象获取数据操作对象 -func (this *ModuleBase) GetDBNoduleByUid(uid, tableName string, expired time.Duration) (model *db.DBModel, err error) { +func (this *ModuleBase) GetDBModuleByUid(uid, tableName string, expired time.Duration) (model *db.DBModel, err error) { var ( stag string conn *db.DBConn diff --git a/modules/rtask/module.go b/modules/rtask/module.go index 17c0f25c6..cfb03ca44 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -278,13 +278,6 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T //任务完成则推送 if code := this.CheckCondi(uid, v.cfg.Id); code == pb.ErrorCode_Success { - //任务条件达成推送 - // if err := this.SendMsgToUser("taskcond", "finished", &pb.TaskcondFinishedPush{ - // CondId: v.cfg.Id, - // }, uid); err != nil { - // log.Errorf("任务条件达成推送失败 err:%v", err) - // } - // log.Errorf("任务条件达成 uid:%v condId:%v", uid, v.cfg.Id) module, err := this.service.GetModule(comm.ModuleWorldtask) if err == nil { if worldtask, ok := module.(comm.IWorldtask); ok { @@ -294,14 +287,17 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T notifyErr := &pb.NotifyErrorNotifyPush{ ReqMainType: string(comm.ModuleWorldtask), ReqSubType: "finish", - Code: pb.ErrorCode_WorldtaskLvNotEnough, Message: "", } if customErr.Code == pb.ErrorCode_WorldtaskLvNotEnough { + notifyErr.Code = pb.ErrorCode_WorldtaskLvNotEnough + session.SendMsg(string(comm.ModuleWorldtask), "finish", notifyErr) + } else if customErr.Code == pb.ErrorCode_UserSessionNobeing { + notifyErr.Code = pb.ErrorCode_UserSessionNobeing session.SendMsg(string(comm.ModuleWorldtask), "finish", notifyErr) } else { - log.Errorf("任务条件达成通知 失败 err:%v", err) + log.Error("任务条件达成通知", log.Fields{"uid": uid, "condId": v.cfg.Id, "err": err.Error()}) } } } @@ -413,7 +409,7 @@ func (this *ModuleRtask) RemoteCheckCondi(uid string, condiId int32, rsp *pb.DBR //接收区服worker发起的秘境事件 func (this *ModuleRtask) Rpc_ModuleRtaskSendTask(ctx context.Context, args *pb.RPCRTaskReq, reply *pb.EmptyResp) (err error) { - this.Debug("Rpc_ModuleRtaskSendTask", log.Fields{ "args": args.String()}) + this.Debug("Rpc_ModuleRtaskSendTask", log.Fields{"args": args.String()}) if args.Uid == "" { err = errors.New("参数异常!") return diff --git a/modules/sociaty/api_cross_accuse.go b/modules/sociaty/api_cross_accuse.go index 565d274da..3d0db2882 100644 --- a/modules/sociaty/api_cross_accuse.go +++ b/modules/sociaty/api_cross_accuse.go @@ -1,7 +1,9 @@ package sociaty import ( + "errors" "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -19,12 +21,13 @@ func (this *apiComp) Accuse(session comm.IUserSession, req *pb.SociatyAccuseReq) } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } + // 校验权限 if !this.module.modelSociaty.isRight(uid, sociaty, pb.SociatyJob_VICEPRESIDENT, pb.SociatyJob_ADMIN, @@ -33,9 +36,15 @@ func (this *apiComp) Accuse(session comm.IUserSession, req *pb.SociatyAccuseReq) return } + // 弹劾 if err := this.module.modelSociaty.accuse(sociaty); err != nil { - code = pb.ErrorCode_SociatyAccuse - this.module.Errorf("弹劾失败 sociatyId:%s uid:%s err:%v", sociaty.Id, uid, err) + var customErr = new(comm.CustomError) + if errors.As(err, &customErr) { + code = customErr.Code + }else{ + code = pb.ErrorCode_DBError + } + this.module.Error("弹劾", log.Fields{"uid": uid, "sociatyId": sociaty.Id}) return } diff --git a/modules/sociaty/api_cross_activitylist.go b/modules/sociaty/api_cross_activitylist.go index b5a010b4a..a5c6ef17c 100644 --- a/modules/sociaty/api_cross_activitylist.go +++ b/modules/sociaty/api_cross_activitylist.go @@ -2,6 +2,7 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -16,20 +17,14 @@ func (this *apiComp) ActivitylistCheck(session comm.IUserSession, req *pb.Sociat func (this *apiComp) Activitylist(session comm.IUserSession, req *pb.SociatyActivityListReq) (code pb.ErrorCode, data proto.Message) { uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } rsp := &pb.SociatyActivityListResp{} - defer func() { - if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeActivityList, rsp); err != nil { - code = pb.ErrorCode_SystemError - } - }() - sociatyTask := this.module.modelSociatyTask.getUserTask(uid, sociaty.Id) if sociatyTask.SociatyId != "" { var activityList []*pb.SociatyActivity @@ -43,5 +38,9 @@ func (this *apiComp) Activitylist(session comm.IUserSession, req *pb.SociatyActi rsp.List = activityList } + if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeActivityList, rsp); err != nil { + code = pb.ErrorCode_SystemError + } + return } diff --git a/modules/sociaty/api_cross_activityreceive.go b/modules/sociaty/api_cross_activityreceive.go index 90119b52d..0660f1535 100644 --- a/modules/sociaty/api_cross_activityreceive.go +++ b/modules/sociaty/api_cross_activityreceive.go @@ -2,6 +2,7 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -10,6 +11,7 @@ import ( // 活跃度领取 func (this *apiComp) ActivityreceiveCheck(session comm.IUserSession, req *pb.SociatyActivityReceiveReq) (code pb.ErrorCode) { if req.Id == 0 { + this.module.Error("活跃度领取参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) code = pb.ErrorCode_ReqParameterError } return @@ -23,7 +25,7 @@ func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyA sociaty := this.module.modelSociaty.getUserSociaty(uid) if sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } @@ -39,12 +41,7 @@ func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyA } } - ggt, err := this.module.configure.getSociatyActivityCfg() - if err != nil || ggt == nil { - code = pb.ErrorCode_ConfigNoFound - return - } - conf, ok := ggt.GetDataMap()[req.Id] + conf, ok := this.module.sociatyActivityConf.GetDataMap()[req.Id] if !ok { code = pb.ErrorCode_ConfigNoFound return @@ -53,13 +50,15 @@ func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyA //是否满足领取条件 if sociaty.Activity < conf.Activity { code = pb.ErrorCode_SociatyActivityNoEnough - this.module.Errorf("活跃度不足 sociatyId:%s uid:%s activity:%d", sociaty.Id, uid, sociaty.Activity) + this.module.Debug("活跃度不足", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "confId": req.Id, + "实际活跃度": sociaty.Activity, "期望活跃度": conf.Activity}) return } // 活跃度领取 if err := this.module.modelSociatyTask.activityReceive(req.Id, sociaty.Id, uid); err != nil { - this.module.Errorf("活跃度领取失败:%v", err) + this.module.Error("活跃度领取", log.Fields{"uid": uid, "params": req}) + code = pb.ErrorCode_DBError return } diff --git a/modules/sociaty/api_cross_agree.go b/modules/sociaty/api_cross_agree.go index ea9fcd7fb..43986c7ba 100644 --- a/modules/sociaty/api_cross_agree.go +++ b/modules/sociaty/api_cross_agree.go @@ -1,17 +1,20 @@ package sociaty import ( + "errors" "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" ) -// 申请-同意 +// 公会申请-同意 func (this *apiComp) AgreeCheck(session comm.IUserSession, req *pb.SociatyAgreeReq) (code pb.ErrorCode) { if req.Uid == "" { code = pb.ErrorCode_ReqParameterError + this.module.Error("公会申请-同意参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) } return } @@ -22,12 +25,13 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) ( } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } + // 校验权限 if !this.module.modelSociaty.isRight(uid, sociaty, pb.SociatyJob_PRESIDENT, pb.SociatyJob_VICEPRESIDENT, @@ -37,22 +41,21 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) ( } if err := this.module.modelSociaty.agree(req.Uid, sociaty); err != nil { - code = pb.ErrorCode_SociatyAgree - this.module.Errorf("申请同意失败:%v", err) + var customError = new(comm.CustomError) + if errors.As(err, &customError) { + code = customError.Code + } else { + code = pb.ErrorCode_DBError + } + this.module.Error("公会审核-同意", log.Fields{"uid": uid, "申请人": req.Uid, "sociatyId": sociaty.Id}) return } // 发邮件 if err := this.module.modelSociaty.sendMail("GuildApproved", []string{sociaty.Name}, []string{req.Uid}); err != nil { - this.module.Errorf("发送邮件id:GuildApproved uid:%v 失败 err:%v", uid, err) + this.module.Error("发送邮件 模板ID:GuildApproved", log.Fields{"uid": uid, "申请人": req.Uid, "sociatyId": sociaty.Id}) } - //审核通过推送 - this.module.SendMsgToUser(string(this.module.GetType()), "pagree", &pb.SociatyPAgreePush{ - Uid: uid, - SociatyId: sociaty.Id, - }, req.Uid) - rsp := &pb.SociatyAgreeResp{ Uid: req.Uid, SociatyId: sociaty.Id, @@ -60,6 +63,15 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) ( if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeAgree, rsp); err != nil { code = pb.ErrorCode_SystemError + return + } + + //审核通过推送给申请人 + if err := this.module.SendMsgToUser(string(this.module.GetType()), "pagree", &pb.SociatyPAgreePush{ + Uid: uid, + SociatyId: sociaty.Id, + }, req.Uid); err != nil { + this.module.Error("审核通过推送", log.Fields{"uid": uid, "申请人": req.Uid, "sociatyId": sociaty.Id}) } return } diff --git a/modules/sociaty/api_cross_apply.go b/modules/sociaty/api_cross_apply.go index 681b7eadb..993016c16 100644 --- a/modules/sociaty/api_cross_apply.go +++ b/modules/sociaty/api_cross_apply.go @@ -1,8 +1,11 @@ package sociaty import ( + "errors" "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" + "go_dreamfactory/utils" "google.golang.org/protobuf/proto" ) @@ -12,6 +15,7 @@ import ( func (this *apiComp) ApplyCheck(session comm.IUserSession, req *pb.SociatyApplyReq) (code pb.ErrorCode) { if req.SociatyId == "" { code = pb.ErrorCode_ReqParameterError + this.module.Error("公会申请参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) } return } @@ -24,28 +28,34 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) ( uid := session.GetUserId() sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("sociatyId: %s no found", req.SociatyId) + this.module.Error("公会未找到", log.Fields{"uid": uid, "sociatyId": req.SociatyId}) return } // userex - // userEx, err := this.module.ModuleUser.GetRemoteUserExpand(uid) - // if err != nil { - // this.module.Errorf("GetRemoteUserExpand uid: err:%v", uid, err) - // code = pb.ErrorCode_UserSessionNobeing - // return - // } + userEx, err := this.module.ModuleUser.GetRemoteUserExpand(uid) + if err != nil { + this.module.Error("GetRemoteUserExpand", log.Fields{"uid": uid, "err": err.Error()}) + code = pb.ErrorCode_UserSessionNobeing + return + } - // if utils.IsInCDHour(userEx.SociatyCd) { - // code = pb.ErrorCode_SociatyCDLimit - // return - // } + if utils.IsInCDHour(userEx.SociatyCd) { + code = pb.ErrorCode_SociatyCDLimit + return + } + + // 是否公会成员 + if this.module.modelSociaty.isMember(uid, sociaty) { + code = pb.ErrorCode_SociatyBelongTo + return + } - // 是否达到入会等级 user, err := this.module.ModuleUser.GetRemoteUser(uid) if err != nil { + code = pb.ErrorCode_DBError return } @@ -54,17 +64,12 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) ( return } + // 是否达到入会等级 if user.Lv < sociaty.ApplyLv { code = pb.ErrorCode_SociatyAppyLvNoEnough return } - // 是否公会成员 - if this.module.modelSociaty.isMember(uid, sociaty) { - code = pb.ErrorCode_SociatyBelongTo - return - } - // 是否已申请 if this.module.modelSociaty.isApplied(uid, sociaty) { code = pb.ErrorCode_SociatyApplied @@ -79,8 +84,13 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) ( // 申请 if err := this.module.modelSociaty.apply(uid, sociaty); err != nil { - code = pb.ErrorCode_SociatyApply - this.module.Errorf("公会申请失败 sociatyId:%s err:%v", req.SociatyId, err) + var customError = new(comm.CustomError) + if errors.As(err, &customError) { + code = customError.Code + } else { + code = pb.ErrorCode_DBError + } + this.module.Error("公会申请", log.Fields{"uid": uid, "sociatyId": req.SociatyId, "err": err.Error()}) return } rsp := &pb.SociatyApplyResp{ diff --git a/modules/sociaty/api_cross_applycancel.go b/modules/sociaty/api_cross_applycancel.go index b110d9788..0cecbba2f 100644 --- a/modules/sociaty/api_cross_applycancel.go +++ b/modules/sociaty/api_cross_applycancel.go @@ -2,14 +2,18 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" ) +// 取消公会申请 + func (this *apiComp) ApplyCancelCheck(session comm.IUserSession, req *pb.SociatyApplyCancelReq) (code pb.ErrorCode) { if req.SociatyId == "" { code = pb.ErrorCode_ReqParameterError + this.module.Error("公会申请取消参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) } return } @@ -20,9 +24,16 @@ func (this *apiComp) ApplyCancel(session comm.IUserSession, req *pb.SociatyApply } uid := session.GetUserId() - if err := this.module.modelSociaty.applyCancel(uid, req.SociatyId); err != nil { - code = pb.ErrorCode_SociatyApplyCanel - this.module.Errorf("申请撤销失败:%v", err) + sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) + if sociaty != nil && sociaty.Id == "" { + code = pb.ErrorCode_SociatyNoFound + this.module.Error("公会未找到", log.Fields{"uid": uid, "sociatyId": req.SociatyId}) + return + } + + if err := this.module.modelSociaty.applyCancel(uid, sociaty); err != nil { + code = pb.ErrorCode_DBError + this.module.Error("申请撤销", log.Fields{"uid": uid, "sociatyId": req.SociatyId, "err": err.Error()}) return } diff --git a/modules/sociaty/api_cross_applylist.go b/modules/sociaty/api_cross_applylist.go index c03c73a52..0b2d34839 100644 --- a/modules/sociaty/api_cross_applylist.go +++ b/modules/sociaty/api_cross_applylist.go @@ -2,6 +2,7 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -12,6 +13,7 @@ import ( func (this *apiComp) ApplyListCheck(session comm.IUserSession, req *pb.SociatyApplyListReq) (code pb.ErrorCode) { if req.SociatyId == "" { code = pb.ErrorCode_ReqParameterError + this.module.Error("申请列表参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) } return } @@ -20,14 +22,15 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.SociatyApplyLi if code = this.ApplyListCheck(session, req); code != pb.ErrorCode_Success { return } + uid := session.GetUserId() sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("sociatyId: %s no found", req.SociatyId) + this.module.Error("公会未找到", log.Fields{"uid": uid, "sociatyId": req.SociatyId}) return } - uid := session.GetUserId() + // 校验权限 if !this.module.modelSociaty.isRight(uid, sociaty, pb.SociatyJob_PRESIDENT, pb.SociatyJob_VICEPRESIDENT, diff --git a/modules/sociaty/api_cross_assign.go b/modules/sociaty/api_cross_assign.go index 1295b13b4..97cb489c2 100644 --- a/modules/sociaty/api_cross_assign.go +++ b/modules/sociaty/api_cross_assign.go @@ -1,7 +1,9 @@ package sociaty import ( + "errors" "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -11,6 +13,7 @@ import ( func (this *apiComp) AssignCheck(session comm.IUserSession, req *pb.SociatyAssignReq) (code pb.ErrorCode) { if req.TargetId == "" { code = pb.ErrorCode_ReqParameterError + this.module.Error("公会转让参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) } return } @@ -23,31 +26,47 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq) uid := session.GetUserId() if uid == req.TargetId { code = pb.ErrorCode_ReqParameterError - this.module.Errorf("不能转让给自己 uid:%s", uid) + this.module.Error("不能转让给自己", log.Fields{"uid": uid}) return } sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } + // 校验权限 if !this.module.modelSociaty.isRight(uid, sociaty, pb.SociatyJob_PRESIDENT) { code = pb.ErrorCode_SociatyNoRight return } - if err := this.module.modelSociaty.assign(uid, req.TargetId, sociaty); err != nil { - code = pb.ErrorCode_SociatyAssign - this.module.Errorf("转让失败:%v", err) + // 校验目标是否公会成员 + if !this.module.modelSociaty.isMember(req.TargetId, sociaty) { + code = pb.ErrorCode_SociatyNoMember return } + // 公会转让 + if err := this.module.modelSociaty.assign(uid, req.TargetId, sociaty); err != nil { + code = pb.ErrorCode_DBError + this.module.Errorf("公会转让", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "targetId": req.TargetId, "err": err.Error()}) + return + } + + // 添加日志(成员职位变动) if err := this.module.modelSociatyLog.addLog(Log_Job, sociaty.Id, uid, req.TargetId, pb.SociatyJob_PRESIDENT.String()); err != nil { - this.module.Errorf("转让日志 err:%v", err) + var customErr = new(comm.CustomError) + if errors.As(err, &customErr) { + code = customErr.Code + } else { + code = pb.ErrorCode_DBError + } + this.module.Error("公会转让日志", log.Fields{"uid": uid, "sociatyId": sociaty.Id, + "targetId": req.TargetId, "日志模板": Log_Job, "err": err.Error()}) } rsp := &pb.SociatyAssignResp{ diff --git a/modules/sociaty/api_cross_cancel.go b/modules/sociaty/api_cross_cancel.go deleted file mode 100644 index f6b1da66d..000000000 --- a/modules/sociaty/api_cross_cancel.go +++ /dev/null @@ -1,18 +0,0 @@ -package sociaty - -import ( - "go_dreamfactory/comm" - "go_dreamfactory/pb" - - "google.golang.org/protobuf/proto" -) - -// 申请取消 - -func (this *apiComp) CancelCheck(session comm.IUserSession, req *pb.SociatyCancelReq) (code pb.ErrorCode) { - return -} - -func (this *apiComp) Cancel(session comm.IUserSession, req *pb.SociatyCancelReq) (code pb.ErrorCode, data proto.Message) { - return -} diff --git a/modules/sociaty/api_cross_create.go b/modules/sociaty/api_cross_create.go index f62545548..d6c5cfbd2 100644 --- a/modules/sociaty/api_cross_create.go +++ b/modules/sociaty/api_cross_create.go @@ -3,6 +3,7 @@ package sociaty import ( "errors" "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "go_dreamfactory/utils" "strings" @@ -16,6 +17,7 @@ import ( // 公会创建 func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.SociatyCreateReq) (code pb.ErrorCode) { if len(req.Notice) > 150 || strings.TrimSpace(req.Name) == "" { + this.module.Error("公会创建参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) code = pb.ErrorCode_ReqParameterError } return @@ -30,20 +32,18 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq) user, err := this.module.ModuleUser.GetRemoteUser(uid) if err != nil { - this.module.Errorf("GetRmoteUser err:%v", err) code = pb.ErrorCode_DBError return } if user.Uid == "" { - this.module.Errorf("GetRmoteUser not found uid:%v", uid) + this.module.Error("GetRmoteUser not found", log.Fields{"uid": uid}) code = pb.ErrorCode_UserSessionNobeing return } userExpand, err := this.module.ModuleUser.GetRemoteUserExpand(uid) if err != nil { - this.module.Errorf("GetRemoteUserExpand err:%v", err) code = pb.ErrorCode_DBError return } @@ -64,25 +64,23 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq) if err := this.module.modelSociaty.isNameExist(req.Name); err != nil { var customErr = new(comm.CustomError) if errors.As(err, &customErr) { - if customErr.Code == pb.ErrorCode_SociatyNameExist { - code = pb.ErrorCode_SociatyNameExist - return - } + code = customErr.Code + return } code = pb.ErrorCode_DBError return } //检查钻石 - if code = this.module.ConsumeRes(session, []*cfg.Gameatn{ - this.module.globalConf.GuildBuildCos}, true); code != pb.ErrorCode_Success { + if code = this.module.ConsumeRes(session, []*cfg.Gameatn{this.module.globalConf.GuildBuildCos}, true); code != pb.ErrorCode_Success { + this.module.Warn("资源不足", log.Fields{"uid": uid, "res": this.module.globalConf.GuildBuildCos}) return } //创建公会 sociaty := &pb.DBSociaty{ Creater: user.Uid, - Name: req.Name, + Name: strings.TrimSpace(req.Name), Icon: req.Icon, Notice: req.Notice, IsApplyCheck: req.IsApplyCheck, @@ -96,8 +94,15 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq) Ctime: configure.Now().Unix(), }) if err := this.module.modelSociaty.create(sociaty); err != nil { - code = pb.ErrorCode_DBError - this.module.Errorf("创建公会 err:%v", err) + var customError = new(comm.CustomError) + if errors.As(err, &customError) { + if customError.Code == pb.ErrorCode_SociatyNoFound { + code = pb.ErrorCode_SociatyNoFound + } else { + code = pb.ErrorCode_DBError + } + } + this.module.Error("创建公会", log.Fields{"uid": uid, "params": req, "err": err.Error()}) return } @@ -108,13 +113,13 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq) if err = this.module.ModuleUser.ChangeRemoteUserExpand(user.Uid, update); err != nil { code = pb.ErrorCode_DBError - this.module.Errorf("更新玩家公会ID err:%v", err) + this.module.Error("更新玩家公会ID", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()}) return } - // 初始化任务 + // 初始化玩家公会任务 if err := this.module.modelSociatyTask.initSociatyTask(user.Uid, sociaty.Id); err != nil { - this.module.Errorf("初始化玩家任务 err:%v", err) + this.module.Error("初始化玩家公会任务", log.Fields{"uid": uid, "err": err.Error()}) } if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeCreate, &pb.SociatyCreateResp{ diff --git a/modules/sociaty/api_cross_discharge.go b/modules/sociaty/api_cross_discharge.go index 0e20d5774..44ca08375 100644 --- a/modules/sociaty/api_cross_discharge.go +++ b/modules/sociaty/api_cross_discharge.go @@ -1,7 +1,9 @@ package sociaty import ( + "errors" "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -12,6 +14,7 @@ import ( func (this *apiComp) DischargeCheck(session comm.IUserSession, req *pb.SociatyDischargeReq) (code pb.ErrorCode) { if req.TargetId == "" { code = pb.ErrorCode_ReqParameterError + this.module.Error("踢出公会参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) } return } @@ -22,12 +25,13 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } + // 校验权限 if !this.module.modelSociaty.isRight(uid, sociaty, pb.SociatyJob_PRESIDENT, pb.SociatyJob_VICEPRESIDENT) { @@ -37,27 +41,37 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar // 踢人 if err := this.module.modelSociaty.discharge(req.TargetId, sociaty); err != nil { - code = pb.ErrorCode_SociatyDischarge - this.module.Errorf("踢出公会失败:%v", err) + var customError = new(comm.CustomError) + if errors.As(err, &customError) { + code = customError.Code + } else { + code = pb.ErrorCode_DBError + } + this.module.Error("踢出公会", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "被踢人": req.TargetId, "err": err.Error()}) return } // 发邮件 receiver := this.module.modelSociaty.getMemberIds(sociaty) - this.module.modelSociaty.sendMail("GuildExpel", []string{sociaty.Name}, receiver) + if err := this.module.modelSociaty.sendMail("GuildExpel", []string{sociaty.Name}, receiver); err != nil { + this.module.Error("发送邮件 模板ID:GuildExpel", log.Fields{"uid": uid, "被踢人": req.TargetId, "sociatyId": sociaty.Id}) + } //清除玩家sociatyId update := map[string]interface{}{ "sociatyId": "", //公会ID置空 } + if err := this.module.ModuleUser.ChangeRemoteUserExpand(req.TargetId, update); err != nil { code = pb.ErrorCode_DBError - this.module.Errorf("更新玩家公会ID err:%v", err) + this.module.Error("更新玩家公会ID", log.Fields{"uid": uid, "被踢人": req.TargetId, "err": err.Error()}) return } + // 添加日志 if err := this.module.modelSociatyLog.addLog(Log_Discharge, sociaty.Id, uid, req.TargetId); err != nil { - this.module.Errorf("踢出公会日志 err:%v", err) + this.module.Error("踢出公会日志", log.Fields{"uid": uid, "sociatyId": sociaty.Id, + "targetId": req.TargetId, "日志模板": Log_Discharge, "err": err.Error()}) } rsp := &pb.SociatyDischargeResp{ diff --git a/modules/sociaty/api_cross_dismiss.go b/modules/sociaty/api_cross_dismiss.go index 0048a6f5a..d29a33047 100644 --- a/modules/sociaty/api_cross_dismiss.go +++ b/modules/sociaty/api_cross_dismiss.go @@ -2,6 +2,7 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "go_dreamfactory/utils" @@ -11,15 +12,22 @@ import ( // 公会解散 func (this *apiComp) DismissCheck(session comm.IUserSession, req *pb.SociatyDismissReq) (code pb.ErrorCode) { + if req.Dismiss > 1 { + code = pb.ErrorCode_ReqParameterError + this.module.Error("公会解散参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) + } return } func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissReq) (code pb.ErrorCode, data proto.Message) { + if code = this.DismissCheck(session, req); code != pb.ErrorCode_Success { + return + } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } @@ -28,16 +36,21 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe SociatyId: sociaty.Id, } + // 校验权限 if !this.module.modelSociaty.isRight(uid, sociaty, pb.SociatyJob_PRESIDENT) { code = pb.ErrorCode_SociatyNoRight return } + + //公会解散 update := map[string]interface{}{} globalCnf := this.module.globalConf + var isUpdate bool if sociaty.DismissTime == 0 { //更新解散倒计时 update["dismissTime"] = utils.AddHour(int(globalCnf.GuildDissolutionCountDownCd)).Unix() + isUpdate = true } else { if req.Dismiss == 1 { //取消解散 if utils.IsInCDHour(int64(sociaty.DismissCD)) { @@ -49,12 +62,15 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe } //取消倒计时 update["dismissTime"] = 0 + isUpdate = true } } - if err := this.module.modelSociaty.updateSociaty(sociaty.Id, update); err != nil { - code = pb.ErrorCode_DBError - return + if isUpdate { + if err := this.module.modelSociaty.updateSociaty(sociaty.Id, update); err != nil { + code = pb.ErrorCode_DBError + return + } } if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeDismiss, rsp); err != nil { diff --git a/modules/sociaty/api_cross_list.go b/modules/sociaty/api_cross_list.go index 6e48069d6..6f1a5265e 100644 --- a/modules/sociaty/api_cross_list.go +++ b/modules/sociaty/api_cross_list.go @@ -2,6 +2,7 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -9,6 +10,10 @@ import ( // 公会列表 func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.SociatyListReq) (code pb.ErrorCode) { + if req.Filter > 3 { + code = pb.ErrorCode_ReqParameterError + this.module.Error("公会列表参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) + } return } diff --git a/modules/sociaty/api_cross_log.go b/modules/sociaty/api_cross_log.go index 7d8453995..4397a2feb 100644 --- a/modules/sociaty/api_cross_log.go +++ b/modules/sociaty/api_cross_log.go @@ -2,6 +2,7 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -16,12 +17,13 @@ func (this *apiComp) LogCheck(session comm.IUserSession, req *pb.SociatyLogReq) func (this *apiComp) Log(session comm.IUserSession, req *pb.SociatyLogReq) (code pb.ErrorCode, data proto.Message) { uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } + // 日志列表 sl := this.module.modelSociatyLog.logList(sociaty.Id) rsp := &pb.SociatyLogResp{ diff --git a/modules/sociaty/api_cross_members.go b/modules/sociaty/api_cross_members.go index 87f379ba6..5f6679586 100644 --- a/modules/sociaty/api_cross_members.go +++ b/modules/sociaty/api_cross_members.go @@ -2,6 +2,7 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -16,12 +17,13 @@ func (this *apiComp) MembersCheck(session comm.IUserSession, req *pb.SociatyMemb func (this *apiComp) Members(session comm.IUserSession, req *pb.SociatyMembersReq) (code pb.ErrorCode, data proto.Message) { uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } + // 成员列表 members := this.module.modelSociaty.members(sociaty) rsp := &pb.SociatyMembersResp{ List: members, diff --git a/modules/sociaty/api_cross_mine.go b/modules/sociaty/api_cross_mine.go index 04a0d8437..3b171dcfd 100644 --- a/modules/sociaty/api_cross_mine.go +++ b/modules/sociaty/api_cross_mine.go @@ -2,12 +2,15 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "go_dreamfactory/utils" "google.golang.org/protobuf/proto" ) +// 我的公会 + func (this *apiComp) MineCheck(session comm.IUserSession, req *pb.SociatyMineReq) (code pb.ErrorCode) { return } @@ -16,52 +19,63 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (co uid := session.GetUserId() userEx, err := this.module.ModuleUser.GetRemoteUserExpand(uid) if err != nil { - this.module.Errorf("GetRemoteUserExpand uid: err:%v", uid, err) + this.module.Error("GetRemoteUserExpand", log.Fields{"uid": uid, "err": err}) code = pb.ErrorCode_UserSessionNobeing return } rsp := &pb.SociatyMineResp{} - // 已加入公会 - if userEx.SociatyId != "" { - sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { - code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("sociatyId: %s no found", userEx.SociatyId) - return - } + // 未加入公会 + if userEx.SociatyId == "" { + code = pb.ErrorCode_SociatyNoAdded + return + } - //验证是否解散 - if this.module.modelSociaty.isDismiss(sociaty) { - code = pb.ErrorCode_SociatyDismissed - return - } + // 获取公会 + sociaty := this.module.modelSociaty.getUserSociaty(uid) + if sociaty != nil && sociaty.Id == "" { + code = pb.ErrorCode_SociatyNoFound + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) + return + } - // 初始玩家公会任务 - sociatyTask := this.module.modelSociatyTask.getUserTask(uid, sociaty.Id) - if sociatyTask.SociatyId != "" { - if utils.IsFirstTody(sociatyTask.LastUpdateTime) { - if err := this.module.modelSociatyTask.deleTask(sociaty.Id, uid); err == nil { - if err = this.module.modelSociatyTask.initSociatyTask(uid, sociaty.Id); err != nil { - this.module.Errorf("初始化玩家攻击任务失败 err:%v", err) - } + //判断公会是否解散(公会解散非立即执行) + if this.module.modelSociaty.isDismiss(sociaty) { + code = pb.ErrorCode_SociatyDismissed + return + } + + // 初始玩家公会任务 + sociatyTask := this.module.modelSociatyTask.getUserTask(uid, sociaty.Id) + if sociatyTask.SociatyId != "" { + // 今日首次进入公会 + if utils.IsFirstTody(sociatyTask.LastUpdateTime) { + // 删除任务 + if err := this.module.modelSociatyTask.deleTask(sociaty.Id, uid); err == nil { + // 初始新的公会任务 + if err = this.module.modelSociatyTask.initSociatyTask(uid, sociaty.Id); err != nil { + this.module.Error("初始化玩家公会任务", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err}) } } } - - // 获取会长 - master := this.module.modelSociaty.getMasterInfo(sociaty) - if master != nil { - if err := this.module.modelSociaty.extendJob(master.Uid, sociaty); err == nil { - // 获取新的会长 - master = this.module.modelSociaty.getMasterInfo(sociaty) - } - } - rsp.Sociaty = sociaty - rsp.Master = master } + // 获取会长 + master := this.module.modelSociaty.getMasterInfo(sociaty) + if master != nil { + // 会长弹劾判断 + if err := this.module.modelSociaty.extendJob(master.Uid, sociaty); err == nil { + // 获取新的会长 + master = this.module.modelSociaty.getMasterInfo(sociaty) + } else { + code = pb.ErrorCode_DBError + this.module.Error("会长弹劾", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "master": master.Uid, "err": err}) + } + } + rsp.Sociaty = sociaty + rsp.Master = master + if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeMine, rsp); err != nil { code = pb.ErrorCode_SystemError } diff --git a/modules/sociaty/api_cross_quit.go b/modules/sociaty/api_cross_quit.go index d5e1e105c..7eaf00543 100644 --- a/modules/sociaty/api_cross_quit.go +++ b/modules/sociaty/api_cross_quit.go @@ -2,6 +2,7 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "go_dreamfactory/utils" @@ -17,9 +18,9 @@ func (this *apiComp) QuitCheck(session comm.IUserSession, req *pb.SociatyQuitReq func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (code pb.ErrorCode, data proto.Message) { uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } @@ -30,9 +31,10 @@ func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (co return } + // 退出公会 if err := this.module.modelSociaty.quit(uid, sociaty); err != nil { code = pb.ErrorCode_SociatyQuit - this.module.Errorf("退出公会失败:%v", err) + this.module.Errorf("退出公会", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()}) return } @@ -44,12 +46,14 @@ func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (co if err := this.module.ModuleUser.ChangeRemoteUserExpand(uid, update); err != nil { code = pb.ErrorCode_DBError - this.module.Errorf("更新玩家公会ID err:%v", err) + this.module.Error("退出公会,更新玩家公会ID", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()}) return } + // 添加退出公会日志 if err := this.module.modelSociatyLog.addLog(Log_Quit, sociaty.Id, uid); err != nil { - this.module.Errorf("退出公会日志 err:%v", err) + this.module.Error("踢出公会日志", log.Fields{"uid": uid, "sociatyId": sociaty.Id, + "日志模板": Log_Quit, "err": err.Error()}) } rsp := &pb.SociatyQuitResp{ diff --git a/modules/sociaty/api_cross_rank.go b/modules/sociaty/api_cross_rank.go index fd30b19b0..34e5c1d36 100644 --- a/modules/sociaty/api_cross_rank.go +++ b/modules/sociaty/api_cross_rank.go @@ -14,6 +14,7 @@ func (this *apiComp) RankCheck(session comm.IUserSession, req *pb.SociatyRankReq } func (this *apiComp) Rank(session comm.IUserSession, req *pb.SociatyRankReq) (code pb.ErrorCode, data proto.Message) { + // 排行榜 list := this.module.modelSociaty.rank() rsp := &pb.SociatyRankResp{ Rank: list, diff --git a/modules/sociaty/api_cross_receive.go b/modules/sociaty/api_cross_receive.go index 1ad85ae84..b04e96176 100644 --- a/modules/sociaty/api_cross_receive.go +++ b/modules/sociaty/api_cross_receive.go @@ -2,16 +2,18 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" ) -// 任务奖励领取 +// 公会任务奖励领取 func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.SociatyReceiveReq) (code pb.ErrorCode) { if req.TaskId == 0 { code = pb.ErrorCode_ReqParameterError + this.module.Error("公会任务奖励领取参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) } return } @@ -22,9 +24,9 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } @@ -32,7 +34,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe sociatyTask := this.module.modelSociaty.getUserTaskList(uid, sociaty.Id) for _, v := range sociatyTask.TaskList { if v.TaskId == req.TaskId { - if v.Status == 1 {//已领取 + if v.Status == 1 { //已领取 code = pb.ErrorCode_SociatyRewardReceived return } @@ -43,40 +45,35 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe // 验证任务是否完成 if err, ok := this.module.modelSociaty.validTask(uid, req.TaskId); err != nil || !ok { code = pb.ErrorCode_SociatyTaskValidation - this.module.Errorf("任务 taskId:%v 验证未通过", req.TaskId) + this.module.Error("公会任务未通过", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "taskId": req.TaskId, "err": err.Error()}) return } - // 领取 + // 奖励领取 if err := this.module.modelSociatyTask.receive(req.TaskId, sociaty.Id, uid); err != nil { code = pb.ErrorCode_SociatyRewardReceive - this.module.Errorf("领取任务奖励 err:%v", err) + this.module.Error("领取公会任务奖励", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "taskId": req.TaskId, "err": err.Error()}) return } //获取奖励配置 - ggt, err := this.module.configure.getSociatyTaskCfg() - if err != nil || ggt == nil { - code = pb.ErrorCode_ConfigNoFound - return - } - conf, ok := ggt.GetDataMap()[req.TaskId] + conf, ok := this.module.sociatyTaskConf.GetDataMap()[req.TaskId] if ok { // 发放个人奖励 if code = this.module.DispenseRes(session, conf.Reward, true); code != pb.ErrorCode_Success { - this.module.Errorf("发放个人奖励失败 sociatyId:%s uid:%s taskId:%d code:%v", sociaty.Id, uid, req.TaskId, code) + this.module.Error("发放公会个人奖励失败", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "taskId": req.TaskId, "code": code}) } } // 更新公会经验和活跃度 if err := this.module.modelSociaty.updateResourceFromTask(sociaty, conf); err != nil { - this.module.Errorf("更新公会资源 sociatyId:%s uid:%s taskId:%d err:%v", sociaty.Id, uid, req.TaskId, err) + this.module.Error("更新公会资源", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "taskId": req.TaskId, "err": err.Error()}) return } // 更新成员贡献值 if err := this.module.modelSociaty.updateMemberContribution(uid, conf.Contribution, sociaty); err != nil { - this.module.Errorf("更新成员贡献值 sociatyId:%s uid:%s taskId:%d err:%v", sociaty.Id, uid, req.TaskId, err) + this.module.Error("更新公会成员贡献值", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "taskId": req.TaskId, "err": err.Error()}) return } diff --git a/modules/sociaty/api_cross_refuse.go b/modules/sociaty/api_cross_refuse.go index ff1635be5..06c6ef2e6 100644 --- a/modules/sociaty/api_cross_refuse.go +++ b/modules/sociaty/api_cross_refuse.go @@ -2,16 +2,18 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" ) -// 申请复查 +// 公会申请审核-拒绝 func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.SociatyRefuseReq) (code pb.ErrorCode) { if req.Uid == "" { code = pb.ErrorCode_ReqParameterError + this.module.Error("公会申请审核-拒绝参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) } return } @@ -22,12 +24,13 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SociatyRefuseReq) } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } + // 校验权限 if !this.module.modelSociaty.isRight(uid, sociaty, pb.SociatyJob_PRESIDENT, pb.SociatyJob_VICEPRESIDENT, @@ -36,9 +39,16 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SociatyRefuseReq) return } + // 已是公会成员 + if this.module.modelSociaty.isMember(uid, sociaty) { + code = pb.ErrorCode_SociatyAdded + return + } + + // 拒绝公会申请 if err := this.module.modelSociaty.refuse(req.Uid, sociaty); err != nil { code = pb.ErrorCode_SociatyRefuse - this.module.Errorf("申请拒绝失败:%v", err) + this.module.Error("申请拒绝", log.Fields{"uid": uid, "拒绝目标人": req.Uid, "err": err.Error()}) return } diff --git a/modules/sociaty/api_cross_search.go b/modules/sociaty/api_cross_search.go index ef306ff15..c1ec054c9 100644 --- a/modules/sociaty/api_cross_search.go +++ b/modules/sociaty/api_cross_search.go @@ -2,6 +2,7 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -11,6 +12,7 @@ import ( func (this *apiComp) SearchCheck(session comm.IUserSession, req *pb.SociatySearchReq) (code pb.ErrorCode) { if req.Name == "" { code = pb.ErrorCode_ReqParameterError + this.module.Error("公会搜索参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) } return } @@ -22,7 +24,7 @@ func (this *apiComp) Search(session comm.IUserSession, req *pb.SociatySearchReq) rsp := &pb.SociatySearchResp{} sociaty := this.module.modelSociaty.findByName(req.Name) - if sociaty.Id != "" { + if sociaty != nil && sociaty.Id != "" { rsp.List = append(rsp.List, sociaty) } diff --git a/modules/sociaty/api_cross_setting.go b/modules/sociaty/api_cross_setting.go index bb201f45e..417990236 100644 --- a/modules/sociaty/api_cross_setting.go +++ b/modules/sociaty/api_cross_setting.go @@ -2,6 +2,7 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -10,6 +11,10 @@ import ( // 公会设置 func (this *apiComp) SettingCheck(session comm.IUserSession, req *pb.SociatySettingReq) (code pb.ErrorCode) { + if req.ApplyLv == 0 || req.Icon == "" { + code = pb.ErrorCode_ReqParameterError + this.module.Error("公会设置参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) + } return } @@ -20,12 +25,13 @@ func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingRe uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } + // 校验权限 if !this.module.modelSociaty.isRight(uid, sociaty, pb.SociatyJob_PRESIDENT, pb.SociatyJob_VICEPRESIDENT) { code = pb.ErrorCode_SociatyNoRight @@ -37,9 +43,10 @@ func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingRe sociaty.IsApplyCheck = req.IsApplyCheck sociaty.ApplyLv = req.ApplyLv + // 设置 if err := this.module.modelSociaty.setting(sociaty); err != nil { code = pb.ErrorCode_SociatySetting - this.module.Errorf("公会修改失败:%v", err) + this.module.Error("公会修改", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "params": req, "err": err.Error()}) return } diff --git a/modules/sociaty/api_cross_settingjob.go b/modules/sociaty/api_cross_settingjob.go index 528f98e88..3fa08da0f 100644 --- a/modules/sociaty/api_cross_settingjob.go +++ b/modules/sociaty/api_cross_settingjob.go @@ -2,6 +2,7 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -11,6 +12,7 @@ import ( func (this *apiComp) SettingJobCheck(session comm.IUserSession, req *pb.SociatySettingJobReq) (code pb.ErrorCode) { if req.TargetId == "" || req.Job == 0 { code = pb.ErrorCode_ReqParameterError + this.module.Error("公会设置职位参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) } return } @@ -22,9 +24,9 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } @@ -35,6 +37,12 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin return } + // 不能设置自己 + if uid == req.TargetId { + code = pb.ErrorCode_SociatySelfSetting + return + } + // 判断职位人数 globalConf := this.module.globalConf jobCount := this.module.modelSociaty.getJobCount(req.Job, sociaty) @@ -44,16 +52,10 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin return } - // 不能设置自己 - if uid == req.TargetId { - code = pb.ErrorCode_SociatySelfSetting - return - } - // 设置职位 if err := this.module.modelSociaty.settingJob(req.TargetId, req.Job, sociaty); err != nil { code = pb.ErrorCode_SociatySettingJob - this.module.Errorf("设置职位失败:%v", err) + this.module.Errorf("设置公会职位", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "params": req, "err": err.Error()}) return } diff --git a/modules/sociaty/api_cross_sign.go b/modules/sociaty/api_cross_sign.go index 5c8e720c3..713b94980 100644 --- a/modules/sociaty/api_cross_sign.go +++ b/modules/sociaty/api_cross_sign.go @@ -2,6 +2,7 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -19,9 +20,15 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (co uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty != nil && sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) + return + } + + // 不是该公会成员 + if !this.module.modelSociaty.isMember(uid, sociaty) { + code = pb.ErrorCode_SociatyNoAdded return } @@ -34,38 +41,34 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (co // 签到 if err := this.module.modelSociaty.sign(uid, sociaty); err != nil { code = pb.ErrorCode_SociatyAgree - this.module.Errorf("签到失败:%v", err) - return - } - - ggs, err := this.module.configure.getSociatySignCfg() - if err != nil { - code = pb.ErrorCode_ConfigNoFound + this.module.Error("签到失败", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()}) return } // 发奖 lastSignCount := sociaty.LastSignCount var signCfgId int32 //签到配置ID - for _, v := range ggs.GetDataList() { + for _, v := range this.module.sociatySignConf.GetDataList() { if lastSignCount >= v.Down && lastSignCount <= v.Up { // 发放签到奖励 if code = this.module.DispenseRes(session, v.Reward, true); code == pb.ErrorCode_Success { signCfgId = v.Id + } else { + log.Error("发放签到奖励失败", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "code": code}) } break } } - if cfg, ok := ggs.GetDataMap()[signCfgId]; ok { + if cfg, ok := this.module.sociatySignConf.GetDataMap()[signCfgId]; ok { // 更新公会经验 if cfg.Exp.T == "guildexp" { if err := this.module.modelSociaty.updateSociatyExp(cfg.Exp.N, sociaty); err != nil { - this.module.Errorf("公会经验更新失败:%v", err) + this.module.Error("公会经验更新", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "经验": cfg.Exp.N, "err": err.Error()}) } // 更新等级 if err := this.module.modelSociaty.changeLv(sociaty); err != nil { - this.module.Errorf("公会等级更新失败:%v", err) + this.module.Error("公会等级更新", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()}) } } } diff --git a/modules/sociaty/api_cross_tasklist.go b/modules/sociaty/api_cross_tasklist.go index c30123028..cfde9b3cc 100644 --- a/modules/sociaty/api_cross_tasklist.go +++ b/modules/sociaty/api_cross_tasklist.go @@ -2,6 +2,7 @@ package sociaty import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -18,17 +19,11 @@ func (this *apiComp) TaskList(session comm.IUserSession, req *pb.SociatyTaskList sociaty := this.module.modelSociaty.getUserSociaty(uid) if sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound - this.module.Errorf("uid:%s not in sociaty", uid) + this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid}) return } rsp := &pb.SociatyTaskListResp{} - defer func() { - if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeTasklist, rsp); err != nil { - code = pb.ErrorCode_SystemError - } - }() - sociatyTask := this.module.modelSociatyTask.getUserTask(uid, sociaty.Id) if sociatyTask.SociatyId != "" { var taskList []*pb.SociatyTask @@ -42,5 +37,8 @@ func (this *apiComp) TaskList(session comm.IUserSession, req *pb.SociatyTaskList rsp.List = taskList } + if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeTasklist, rsp); err != nil { + code = pb.ErrorCode_SystemError + } return } diff --git a/modules/sociaty/model_sociaty.go b/modules/sociaty/model_sociaty.go index b36afdc68..1b9de59fb 100644 --- a/modules/sociaty/model_sociaty.go +++ b/modules/sociaty/model_sociaty.go @@ -2,7 +2,6 @@ package sociaty import ( "context" - "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" event_v2 "go_dreamfactory/lego/sys/event/v2" @@ -60,7 +59,7 @@ func (this *ModelSociaty) Init(service core.IService, module core.IModule, comp // 创建公会 func (this *ModelSociaty) create(sociaty *pb.DBSociaty) error { if sociaty == nil { - return fmt.Errorf("sociaty is nil") + return comm.NewCustomError(pb.ErrorCode_SociatyNoFound) } _id := primitive.NewObjectID().Hex() sociaty.Id = _id @@ -99,16 +98,17 @@ func (this *ModelSociaty) list(uid string, filter pb.SociatyListFilter) (list [] return } + logFields := log.Fields{"uid": uid, "filter": filter} switch filter { case pb.SociatyListFilter_ALL: //所有 if err := this.GetList("", &list); err != nil { - log.Errorf("sociaty list err:%v", err) + log.Error("公会列表", logFields) return } case pb.SociatyListFilter_CONDI: //满足条件 //玩家等级大于等于公会的申请等级限制 if err := this.GetList("", &list); err != nil { - log.Errorf("sociaty list err:%v", err) + log.Error("公会列表", logFields) return } var newList []*pb.DBSociaty @@ -131,7 +131,7 @@ func (this *ModelSociaty) list(uid string, filter pb.SociatyListFilter) (list [] } case pb.SociatyListFilter_APPLYING: //申请中 if err := this.GetList("", &list); err != nil { - log.Errorf("sociaty list err:%v", err) + log.Error("公会列表", logFields) return } @@ -167,8 +167,8 @@ func (this *ModelSociaty) findByName(name string) *pb.DBSociaty { // 获取公会 func (this *ModelSociaty) getSociaty(sociatyId string) (sociaty *pb.DBSociaty) { sociaty = &pb.DBSociaty{} - if err := this.GetListObj("", sociatyId, sociaty); err != nil { - this.moduleSociaty.Errorf("sociaty [%s] found err:%v", sociatyId, err) + if err := this.GetListObj(comm.RDS_EMPTY, sociatyId, sociaty); err != nil { + log.Error("GetListObj", log.Fields{"sociatyId": sociatyId}) return } return @@ -198,7 +198,6 @@ func (this *ModelSociaty) getUserSociaty(uid string) (sociaty *pb.DBSociaty) { if this.moduleSociaty.IsCross() { userEx, err = this.moduleSociaty.ModuleUser.GetRemoteUserExpand(uid) if err != nil { - log.Errorf("GetUserExpand uid:%v err:%v", uid, err) return } if userEx.SociatyId != "" { @@ -213,7 +212,6 @@ func (this *ModelSociaty) getUserSociaty(uid string) (sociaty *pb.DBSociaty) { } else { userEx, err = this.moduleSociaty.ModuleUser.GetUserExpand(uid) if err != nil { - log.Errorf("GetUserExpand uid:%v err:%v", uid, err) return } if userEx.SociatyId != "" { @@ -267,12 +265,7 @@ func (this *ModelSociaty) setting(sociaty *pb.DBSociaty) error { } // 申请撤销 -func (this *ModelSociaty) applyCancel(uid, sociatyId string) error { - sociaty := this.getSociaty(sociatyId) - if sociaty.Id == "" { - return fmt.Errorf("sociatyId: %s 公会不存在", sociatyId) - } - +func (this *ModelSociaty) applyCancel(uid string, sociaty *pb.DBSociaty) error { return this.delFromApplyRecord(uid, sociaty) } @@ -360,13 +353,11 @@ func (this *ModelSociaty) dismiss(sociaty *pb.DBSociaty) error { return err } //推送 - if err := this.moduleSociaty.SendMsgToUsers( + this.moduleSociaty.SendMsgToUsers( string(this.moduleSociaty.GetType()), "pdismiss", &pb.SociatyPDismissPush{SociatyId: sociaty.Id}, - this.getMemberIds(sociaty)...); err != nil { - log.Errorf("公会解散推送 err:%v", err) - } + this.getMemberIds(sociaty)...) //发邮件 this.sendMail("GuildDissolution", []string{sociaty.Name}, this.getMemberIds(sociaty)) @@ -389,7 +380,7 @@ func (this *ModelSociaty) delFromApplyRecord(uid string, sociaty *pb.DBSociaty) //添加成员 func (this *ModelSociaty) addMember(uid string, sociaty *pb.DBSociaty) error { if int32(len(sociaty.Members)) >= this.getMemberMax(sociaty) { - return fmt.Errorf("member max") + return comm.NewCustomError(pb.ErrorCode_SociatyMemberCountLimit) } sociaty.Members = append(sociaty.Members, &pb.SociatyMember{ Uid: uid, @@ -459,7 +450,7 @@ func (this *ModelSociaty) getMemberIds(sociaty *pb.DBSociaty) (ids []string) { // 同意 func (this *ModelSociaty) agree(uid string, sociaty *pb.DBSociaty) error { if this.isMember(uid, sociaty) { - return fmt.Errorf("已是该公会成员 uid:%s sociatyId:%s", uid, sociaty.Id) + return comm.NewCustomError(pb.ErrorCode_SociatyBelongTo) } //删除申请记录 if err := this.delFromApplyRecord(uid, sociaty); err != nil { @@ -477,9 +468,6 @@ func (this *ModelSociaty) agree(uid string, sociaty *pb.DBSociaty) error { //拒绝 func (this *ModelSociaty) refuse(uid string, sociaty *pb.DBSociaty) error { - if this.isMember(uid, sociaty) { - return fmt.Errorf("已是该公会成员 uid:%s sociatyId:%s", uid, sociaty.Id) - } return this.delFromApplyRecord(uid, sociaty) } @@ -487,10 +475,6 @@ func (this *ModelSociaty) refuse(uid string, sociaty *pb.DBSociaty) error { // targetId 目标玩家ID // srcId 玩家ID 会长 func (this *ModelSociaty) assign(srcId, targetId string, sociaty *pb.DBSociaty) error { - if !this.isMember(targetId, sociaty) { - return fmt.Errorf("不是该公会成员 uid:%s sociatyId:%s", targetId, sociaty.Id) - } - for _, m := range sociaty.Members { if m.Uid == srcId { m.Uid = targetId @@ -511,7 +495,7 @@ func (this *ModelSociaty) discharge(targetId string, sociaty *pb.DBSociaty) erro for i, m := range sociaty.Members { if m.Uid == targetId { if m.Job == pb.SociatyJob_PRESIDENT { - return fmt.Errorf("会长 %s 不可以被踢出", targetId) + return comm.NewCustomError(pb.ErrorCode_SociatyMasterNoDiss) } sociaty.Members = append(sociaty.Members[:i], sociaty.Members[i+1:]...) } @@ -569,7 +553,7 @@ func (this *ModelSociaty) getMasterInfo(sociaty *pb.DBSociaty) *pb.SociatyMember func (this *ModelSociaty) accuse(sociaty *pb.DBSociaty) error { master := this.getMasterInfo(sociaty) if master == nil { - return errors.New("会长不存在") + return comm.NewCustomError(pb.ErrorCode_SociatyNoMaster) } user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(master.Uid) @@ -583,7 +567,7 @@ func (this *ModelSociaty) accuse(sociaty *pb.DBSociaty) error { now := configure.Now().Unix() left := now - user.Offlinetime if left < int64(globalCnf.GuildInitiateImpeachmentTime*3600) || user.Offlinetime == 0 { - return errors.New("会长很称职,无需弹劾") + return comm.NewCustomError(pb.ErrorCode_SociatyNoAccuse) } else { //更新会长的弹劾倒计时时间 update := map[string]interface{}{ @@ -594,10 +578,11 @@ func (this *ModelSociaty) accuse(sociaty *pb.DBSociaty) error { } // 弹劾倒计时判断 +// 会长在截至时间前进入公会终止弹劾,否则进行新会长选举 // srcMasterId 原会长ID func (this *ModelSociaty) extendJob(srcMasterId string, sociaty *pb.DBSociaty) error { if sociaty.AccuseTime != 0 { - //终止弹劾 + //会长在截至时间前进入公会终止弹劾 now := configure.Now().Unix() if now < sociaty.AccuseTime { update := map[string]interface{}{ @@ -654,7 +639,7 @@ func (this *ModelSociaty) electNewMaster(srcMasterId string, sociaty *pb.DBSocia } } if maxCount >= 1 { //有两个以上的最大值 - //比较时间 升序 + //比较时间 升序,先加入公会的人有优先候选权 sort.SliceStable(data, func(i, j int) bool { return data[i].Ctime < data[j].Ctime }) @@ -684,9 +669,6 @@ func (this *ModelSociaty) electNewMaster(srcMasterId string, sociaty *pb.DBSocia // 签到 func (this *ModelSociaty) sign(uid string, sociaty *pb.DBSociaty) error { - if !this.isMember(uid, sociaty) { - return fmt.Errorf("不是该公会成员 uid:%s sociatyId:%s", uid, sociaty.Id) - } sociaty.SignIds = append(sociaty.SignIds, uid) @@ -821,7 +803,7 @@ func (this *ModelSociaty) rankDataChanged(event interface{}, next func(event int func (this *ModelSociaty) rank() (rank []*pb.DBSociatyRank) { var list []*pb.DBSociaty if err := this.GetList("", &list); err != nil { - log.Errorf("sociaty list err:%v", err) + log.Error("公会列表", log.Fields{"err": err.Error()}) return nil } @@ -836,6 +818,7 @@ func (this *ModelSociaty) rank() (rank []*pb.DBSociatyRank) { rank = this.sort(rank) + // 只取前20条数据 if len(rank) > 20 { rank = append(rank[:0], rank[19:]...) } @@ -901,18 +884,10 @@ func (this *ModelSociaty) validTask(uid string, taskId int32) (err error, ok boo return } - grc, err := this.moduleSociaty.configure.getRtaskCondiCfg() - if err != nil { - return - } - if grc == nil { - return errors.New("RtaskCondiCfg is nil"), false - } - // 遍历玩家任务数据 if data, ok := rsp.Vals[taskId]; ok { //查找表配置 - conf, ok := grc.GetDataMap()[taskId] + conf, ok := this.moduleSociaty.rtaskCondConf.GetDataMap()[taskId] if ok { if data.Rtype == conf.Type && data.Data[0] >= conf.Data1 { return nil, true diff --git a/modules/sociaty/model_sociatylog.go b/modules/sociaty/model_sociatylog.go index ead6d4d53..55164e545 100644 --- a/modules/sociaty/model_sociatylog.go +++ b/modules/sociaty/model_sociatylog.go @@ -1,9 +1,9 @@ package sociaty import ( - "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" @@ -37,7 +37,7 @@ func (this *ModelSociatyLog) addLog(tag Tag, sociatyId string, params ...string) content = string(Log_Add) count := strings.Count(content, "%s") if count != len(params) { - return fmt.Errorf("参数和模板参数不匹配 期望:%d 实际%d", count, len(params)) + return comm.NewCustomError(pb.ErrorCode_SociatyLogParams) } for i := 0; i < len(params); i++ { user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(params[i]) @@ -49,7 +49,7 @@ func (this *ModelSociatyLog) addLog(tag Tag, sociatyId string, params ...string) content = string(Log_Quit) count := strings.Count(content, "%s") if count != len(params) { - return fmt.Errorf("参数和模板参数不匹配 期望:%d 实际%d", count, len(params)) + return comm.NewCustomError(pb.ErrorCode_SociatyLogParams) } for i := 0; i < len(params); i++ { user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(params[i]) @@ -61,7 +61,7 @@ func (this *ModelSociatyLog) addLog(tag Tag, sociatyId string, params ...string) content = string(Log_Job) count := strings.Count(content, "%s") if count != len(params) { - return fmt.Errorf("参数和模板参数不匹配 期望:%d 实际%d", count, len(params)) + return comm.NewCustomError(pb.ErrorCode_SociatyLogParams) } for i := 0; i < len(params); i++ { if i == 2 { @@ -88,7 +88,7 @@ func (this *ModelSociatyLog) addLog(tag Tag, sociatyId string, params ...string) content = string(Log_Job) count := strings.Count(content, "%s") if count != len(params) { - return fmt.Errorf("参数和模板参数不匹配 期望:%d 实际%d", count, len(params)) + return comm.NewCustomError(pb.ErrorCode_SociatyLogParams) } for i := 0; i < len(params); i++ { user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(params[i]) @@ -100,7 +100,7 @@ func (this *ModelSociatyLog) addLog(tag Tag, sociatyId string, params ...string) content = string(Log_Job) count := strings.Count(content, "%s") if count != len(params) { - return fmt.Errorf("参数和模板参数不匹配 期望:%d 实际%d", count, len(params)) + return comm.NewCustomError(pb.ErrorCode_SociatyLogParams) } for i := 0; i < len(params); i++ { content = strings.Replace(content, "%s", params[i], 1) @@ -160,17 +160,19 @@ func (this *ModelSociatyLog) addLog(tag Tag, sociatyId string, params ...string) // 查询日志 func (this *ModelSociatyLog) logList(sociatyId string) (slist []*pb.SociatyLog) { - log := &pb.DBSociatyLog{} - if err := this.Get(sociatyId, log); err != nil { + sociatyLog := &pb.DBSociatyLog{} + if err := this.Get(sociatyId, sociatyLog); err != nil { + log.Error("公会日志列表", log.Fields{"sociatyId": sociatyId}) return nil } - for _, l := range log.List { + for _, l := range sociatyLog.List { slist = append(slist, &pb.SociatyLog{ Content: l.Content, Ctime: l.Ctime, }) } + // 创建时间排序 降序 sort.SliceStable(slist, func(i, j int) bool { return slist[i].Ctime > slist[j].Ctime }) diff --git a/modules/sociaty/model_sociatytask.go b/modules/sociaty/model_sociatytask.go index b9aebdaf2..45b5bce06 100644 --- a/modules/sociaty/model_sociatytask.go +++ b/modules/sociaty/model_sociatytask.go @@ -1,7 +1,6 @@ package sociaty import ( - "errors" "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" @@ -26,29 +25,25 @@ func (this *ModelSociatyTask) Init(service core.IService, module core.IModule, c // 初始化公会任务 加入成员时初始化 func (this *ModelSociatyTask) initSociatyTask(uid, sociatyId string) error { - ggt, err := this.moduleSociaty.configure.getSociatyTaskCfg() - if err != nil || ggt == nil { - return errors.New("SociatyTaskCfg not found") - } sociatyTask := &pb.DBSociatyTask{ SociatyId: sociatyId, Uid: uid, } var taskList []*pb.SociatyTask - list := ggt.GetDataList() + taskListConf := this.moduleSociaty.sociatyTaskConf.GetDataList() globalConf := this.moduleSociaty.globalConf // 大于4条配置 - if len(list) > int(globalConf.GuildTaskNum) { + if len(taskListConf) > int(globalConf.GuildTaskNum) { //随机4条任务 - randInts := utils.RandomNumbers(0, len(list)-1, int(globalConf.GuildTaskNum)) + randInts := utils.RandomNumbers(0, len(taskListConf)-1, int(globalConf.GuildTaskNum)) for _, v := range randInts { taskList = append(taskList, &pb.SociatyTask{ - TaskId: list[v].TypeId, + TaskId: taskListConf[v].TypeId, }) } } else { - for _, v := range list { + for _, v := range taskListConf { taskList = append(taskList, &pb.SociatyTask{ TaskId: v.TypeId, }) @@ -59,7 +54,7 @@ func (this *ModelSociatyTask) initSociatyTask(uid, sociatyId string) error { return this.moduleSociaty.modelSociatyTask.AddList(sociatyId, uid, sociatyTask) } -//任务列表 +//公会任务列表 func (this *ModelSociatyTask) getUserTask(uid, sociatyId string) (task *pb.DBSociatyTask) { task = &pb.DBSociatyTask{} this.GetListObj(sociatyId, uid, task) @@ -91,14 +86,19 @@ func (this *ModelSociatyTask) receive(taskId int32, sociatyId, uid string) error func (this *ModelSociatyTask) activityReceive(id int32, sociatyId, uid string) error { sociatyTask := &pb.DBSociatyTask{} this.GetListObj(sociatyId, uid, sociatyTask) + var isUpdate bool for _, t := range sociatyTask.ActivityList { if t.Id == id { t.Status = 1 //领取 + isUpdate = true break } } - update := map[string]interface{}{ - "activityList": sociatyTask.ActivityList, + if isUpdate { + update := map[string]interface{}{ + "activityList": sociatyTask.ActivityList, + } + return this.ChangeList(sociatyId, uid, update) } - return this.ChangeList(sociatyId, uid, update) + return nil } diff --git a/modules/sociaty/module.go b/modules/sociaty/module.go index 412cccbed..8cbe7d194 100644 --- a/modules/sociaty/module.go +++ b/modules/sociaty/module.go @@ -20,13 +20,17 @@ var _ comm.ISociaty = (*Sociaty)(nil) type Sociaty struct { modules.ModuleBase - api *apiComp - service base.IRPCXService - modelSociaty *ModelSociaty - modelSociatyTask *ModelSociatyTask - modelSociatyLog *ModelSociatyLog - configure *configureComp - globalConf *cfg.GameGlobalData + api *apiComp + service base.IRPCXService + modelSociaty *ModelSociaty + modelSociatyTask *ModelSociatyTask + modelSociatyLog *ModelSociatyLog + configure *configureComp + globalConf *cfg.GameGlobalData + sociatyActivityConf *cfg.GameGuildActivity + sociatyTaskConf *cfg.GameGuildTask + sociatySignConf *cfg.GameGuildSign + rtaskCondConf *cfg.GameRdtaskCondi } func NewModule() core.IModule { @@ -59,6 +63,10 @@ func (this *Sociaty) Start() (err error) { if this.globalConf == nil { err = errors.New("global config not found") } + this.sociatyActivityConf, err = this.configure.getSociatyActivityCfg() + this.sociatyTaskConf, err = this.configure.getSociatyTaskCfg() + this.rtaskCondConf, err = this.configure.getRtaskCondiCfg() + this.sociatySignConf, err = this.configure.getSociatySignCfg() return } diff --git a/modules/user/model_expand.go b/modules/user/model_expand.go index f2a74014c..bc51df2fa 100644 --- a/modules/user/model_expand.go +++ b/modules/user/model_expand.go @@ -3,6 +3,7 @@ package user import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" "go_dreamfactory/sys/db" @@ -28,20 +29,21 @@ func (this *ModelExpand) Init(service core.IService, module core.IModule, comp c func (this *ModelExpand) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) { result = &pb.DBUserExpand{} if db.IsCross() { - if model, err := this.module.GetDBNoduleByUid(uid, this.TableName, this.Expired); err != nil { - this.module.Errorln(err) + if model, err := this.module.GetDBModuleByUid(uid, this.TableName, this.Expired); err != nil { + this.module.Error("Cross GetDBModuleByUid", log.Fields{"uid": uid}) + return result, err } else { if err = model.Get(uid, result); err != nil && mongo.ErrNoDocuments != err { - this.module.Errorf("err:%v", err) + this.module.Error("Cross Get", log.Fields{"uid": uid}) + return result,err } } } else { if err = this.Get(uid, result); err != nil && mongo.ErrNoDocuments != err { - this.module.Errorf("err:%v", err) + this.module.Error("Get", log.Fields{"uid": uid}) } } - err = nil - return result, err + return } //修改用户扩展数据 @@ -53,7 +55,7 @@ func (this *ModelExpand) ChangeUserExpand(uid string, value map[string]interface model *db.DBModel ) if db.IsCross() { - if model, err = this.module.GetDBNoduleByUid(uid, this.TableName, this.Expired); err == nil { + if model, err = this.module.GetDBModuleByUid(uid, this.TableName, this.Expired); err == nil { return model.Change(uid, value) } else { this.module.Errorln(err) diff --git a/modules/user/model_user.go b/modules/user/model_user.go index 1073ab24d..3d79cdeee 100644 --- a/modules/user/model_user.go +++ b/modules/user/model_user.go @@ -78,7 +78,7 @@ func (this *ModelUser) GetUser(uid string) (user *pb.DBUser) { // return // } if this.module.IsCross() { - if model, err := this.module.GetDBNoduleByUid(uid, this.TableName, this.Expired); err != nil { + if model, err := this.module.GetDBModuleByUid(uid, this.TableName, this.Expired); err != nil { this.module.Errorln(err) } else { if err = model.Get(uid, user); err != nil { @@ -96,7 +96,7 @@ func (this *ModelUser) GetUser(uid string) (user *pb.DBUser) { //设置属性 func (this *ModelUser) updateUserAttr(uid string, data map[string]interface{}) error { if this.module.IsCross() { - if model, err := this.module.GetDBNoduleByUid(uid, this.TableName, this.Expired); err != nil { + if model, err := this.module.GetDBModuleByUid(uid, this.TableName, this.Expired); err != nil { this.module.Errorln(err) } else { if err = model.Change(uid, data); err != nil { diff --git a/modules/user/module.go b/modules/user/module.go index 5de6bf409..9e88111c2 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -164,7 +164,6 @@ func (this *User) CrossUserOnlineList() ([]*pb.CacheUser, error) { err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), comm.Service_Worker, Rpc_GetAllOnlineUser, nil, reply) if err != nil { - log.Errorf("Rpc_GetAllOnlineUser err:%v", err) return nil, err } return reply.Users, err @@ -176,7 +175,6 @@ func (this *User) CrossUserSession(uid string) *pb.CacheUser { err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), comm.Service_Worker, Rpc_GetCrossUserSession, &pb.UIdReq{Uid: uid}, cacheUser) if err != nil { - log.Errorf("Rpc_GetCrossUserSession err:%v", err) return nil } return cacheUser @@ -192,7 +190,6 @@ func (this *User) CrossSearchUser(nickName string) ([]*pb.DBUser, error) { err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), comm.Service_Worker, Rpc_QueryUser, &pb.NameReq{Name: name}, reply) if err != nil { - log.Errorf("Rpc_QueryUser err:%v", err) return nil, err } @@ -243,7 +240,7 @@ func (this *User) QueryAttributeValue(uid string, attr string) (value int64) { func (this *User) change(session comm.IUserSession, attr string, add int32) (change *pb.UserResChangedPush, code pb.ErrorCode) { if add == 0 { - log.Errorf("attr no changed,uid: %s attr: %s add: %d", session.GetUserId(), attr, add) + log.Error("attr no changed", log.Fields{"uid": session.GetUserId(), "attr": attr, "add": add}) // code = pb.ErrorCode_ReqParameterError return } @@ -435,7 +432,6 @@ func (this *User) EventUserChanged(session comm.IUserSession) { } func (this *User) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) { - return this.modelExpand.GetUserExpand(uid) } diff --git a/modules/worldtask/api_battlefinish.go b/modules/worldtask/api_battlefinish.go index 3a7ad1849..b9b5e4631 100644 --- a/modules/worldtask/api_battlefinish.go +++ b/modules/worldtask/api_battlefinish.go @@ -2,6 +2,7 @@ package worldtask import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -10,6 +11,7 @@ import ( // 战斗结束的请求 func (this *apiComp) BattlefinishCheck(session comm.IUserSession, req *pb.WorldtaskBattleFinishReq) (code pb.ErrorCode) { if req.BattleConfId == 0 || req.TaskId == 0 || req.Report == nil { + this.module.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) code = pb.ErrorCode_ReqParameterError } return @@ -20,9 +22,6 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa return } - defer func() { - this.module.Errorf("战斗结束 taskId:%v", req.TaskId) - }() taskConf, err := this.module.configure.getWorldtaskById(req.TaskId) if err != nil || taskConf == nil { code = pb.ErrorCode_ConfigNoFound @@ -40,11 +39,12 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa } if ibattle, ok := battleModule.(comm.IBattle); ok { - // var isWin bool - if code, _ = ibattle.CheckBattleReport(session, req.Report); code == pb.ErrorCode_Success { + var isWin bool + if code, isWin = ibattle.CheckBattleReport(session, req.Report); code == pb.ErrorCode_Success { //触发任务 this.module.ModuleRtask.SendToRtask(session, comm.Rtype70, 1, req.BattleConfId) } + this.module.Debug("校验战报", log.Fields{"uid": session.GetUserId(), "taskId": req.TaskId, "战斗结果": isWin}) } if err := session.SendMsg(string(this.module.GetType()), WorldtaskBattleFinish, rsp); err != nil { diff --git a/modules/worldtask/api_battlestart.go b/modules/worldtask/api_battlestart.go index d84718ecf..3e173070d 100644 --- a/modules/worldtask/api_battlestart.go +++ b/modules/worldtask/api_battlestart.go @@ -10,6 +10,10 @@ import ( // 战斗开始 func (this *apiComp) BattlestartCheck(session comm.IUserSession, req *pb.WorldtaskBattleStartReq) (code pb.ErrorCode) { + if req.BattleConfId == 0 || len(req.Teamids) == 0 || req.Leadpos == 0 { + this.module.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) + code = pb.ErrorCode_ReqParameterError + } return } diff --git a/modules/worldtask/api_finish.go b/modules/worldtask/api_finish.go index 9c0b965fb..aa7c34643 100644 --- a/modules/worldtask/api_finish.go +++ b/modules/worldtask/api_finish.go @@ -2,6 +2,7 @@ package worldtask import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -11,6 +12,7 @@ import ( func (this *apiComp) FinishCheck(session comm.IUserSession, req *pb.WorldtaskFinishReq) (code pb.ErrorCode) { if req.GroupId == 0 || req.TaskId == 0 { + this.module.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) code = pb.ErrorCode_ReqParameterError } return @@ -60,7 +62,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe // 前置任务ID if !this.module.modelWorldtask.IsPreFinished(userTask, curTaskConf) { - this.module.Warnf("前置任务未完成 uid:%v preTaskId:%v taskId:", uid, curTaskConf.Ontxe, curTaskConf.Key) + this.module.Debug("前置任务未完成", log.Fields{"uid": uid, "preTaskId": curTaskConf.Ontxe, "taskId": curTaskConf.Key}) code = pb.ErrorCode_WorldtaskLastUnFinished return } @@ -80,12 +82,12 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe // 完成任务 if err := this.module.modelWorldtask.finishTask(req.GroupId, req.TaskId, userTask); err != nil { code = pb.ErrorCode_WorldtaskFinish - this.module.Errorf("finishTask err:%v", err) + this.module.Error("finishTask", log.Fields{"uid": uid, "groupId": req.GroupId, "taskId": req.TaskId, "err": err.Error()}) return } // 发奖 if code = this.module.DispenseRes(session, curTaskConf.Reword, true); code != pb.ErrorCode_Success { - this.module.Errorf("资源发放失败 err:%v", err) + this.module.Error("资源发放", log.Fields{"uid": uid, "groupId": req.GroupId, "taskId": req.TaskId, "reword": curTaskConf.Reword, "code": code}) } } diff --git a/modules/worldtask/api_mine.go b/modules/worldtask/api_mine.go index afa2d4bce..abb3f96a1 100644 --- a/modules/worldtask/api_mine.go +++ b/modules/worldtask/api_mine.go @@ -2,6 +2,7 @@ package worldtask import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -16,6 +17,7 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.WorldtaskMineReq) ( uid := session.GetUserId() myWorldtask, err := this.module.modelWorldtask.getWorldtask(uid) if err != nil { + this.module.Error("获取玩家世界任务失败", log.Fields{"uid": uid, "err": err.Error()}) code = pb.ErrorCode_DBError return } diff --git a/modules/worldtask/model_worldtask.go b/modules/worldtask/model_worldtask.go index ebf2535e6..e0056befa 100644 --- a/modules/worldtask/model_worldtask.go +++ b/modules/worldtask/model_worldtask.go @@ -31,6 +31,7 @@ func (this *ModelWorldtask) getWorldtask(uid string) (*pb.DBWorldtask, error) { d := &pb.DBWorldtask{} if err := this.Get(uid, d); err != nil { if err != mongo.ErrNoDocuments { + log.Error("getWorldtask", log.Fields{"uid": uid}) return d, err } } @@ -38,6 +39,7 @@ func (this *ModelWorldtask) getWorldtask(uid string) (*pb.DBWorldtask, error) { } //判断前置任务是否完成 +// true 已完成 false未完成 func (this *ModelWorldtask) IsPreFinished(userTask *pb.DBWorldtask, curTaskConf *cfg.GameWorldTaskData) bool { var ( lastTaskId int32 @@ -94,7 +96,7 @@ func (this *ModelWorldtask) finishTask(groupId, taskId int32, task *pb.DBWorldta if module, err := this.service.GetModule(comm.ModuleLinestory); err == nil { if iLinestory, ok := module.(comm.ILinestory); ok { if err := iLinestory.TaskFinishNotify(task.Uid, taskId, groupId); err != nil { - log.Errorf("任务完成通知失败 groupId:%v taskId:%v err:%v", groupId, taskId, err) + log.Error("任务完成通知", log.Fields{"uid": task.Uid, "groupId": groupId, "taskId": taskId, "err": err.Error()}) } } } diff --git a/modules/worldtask/module.go b/modules/worldtask/module.go index dbf86ea85..159efe0ab 100644 --- a/modules/worldtask/module.go +++ b/modules/worldtask/module.go @@ -1,7 +1,6 @@ package worldtask import ( - "errors" "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/base" @@ -9,6 +8,7 @@ import ( "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" ) var _ comm.IWorldtask = (*Worldtask)(nil) @@ -19,6 +19,7 @@ type Worldtask struct { service base.IRPCXService configure *configureComp modelWorldtask *ModelWorldtask + worldtaskConf *cfg.GameWorldTask } func NewModule() core.IModule { @@ -35,29 +36,33 @@ func (this *Worldtask) OnInstallComp() { this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.modelWorldtask = this.RegisterComp(new(ModelWorldtask)).(*ModelWorldtask) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) - } + func (this *Worldtask) GetType() core.M_Modules { return comm.ModuleWorldtask } +func (this *Worldtask) Start() (err error) { + err = this.ModuleBase.Start() + if this.worldtaskConf, err = this.configure.getWorldtaskCfg(); err != nil { + return err + } + return +} + // 任务条件达成通知 func (this *Worldtask) TaskcondNotify(session comm.IUserSession, condId int32) error { uid := session.GetUserId() - conf, err := this.configure.getWorldtaskCfg() - if err != nil || conf == nil { - return err - } - finishedTaskIds := make(map[int32]int32) //达成的任务条件 - for _, c := range conf.GetDataList() { + for _, c := range this.worldtaskConf.GetDataList() { if c.Completetask == condId && c.Completetask != 0 { finishedTaskIds[c.Group] = c.Key } } if len(finishedTaskIds) == 0 { + this.Debug("没有匹配到任务世界任务", log.Fields{"uid": uid, "condId": condId}) return nil } @@ -66,20 +71,23 @@ func (this *Worldtask) TaskcondNotify(session comm.IUserSession, condId int32) e // 获取用户信息 user := this.ModuleUser.GetUser(uid) if user == nil { - return fmt.Errorf("玩家uid:%v not found", uid) + return comm.NewCustomError(pb.ErrorCode_UserSessionNobeing) } // 玩家世界任务 userTask, err := this.modelWorldtask.getWorldtask(uid) if err != nil { + this.Error("获取玩家世界任务", log.Fields{"uid": uid, "condId": condId}) return err } if userTask.Uid != "" { //查找任务ID根据condId 可能会找出不同的任务 for k, id := range finishedTaskIds { + logFields := log.Fields{"uid": uid, "group": k, "taskId": id, "condId": condId} // 判断任务是否已完成 if this.modelWorldtask.isFinished(id, userTask.TaskList) { + this.Debug("任务已完成", logFields) continue } taskConf, err := this.configure.getWorldtaskById(id) @@ -88,7 +96,7 @@ func (this *Worldtask) TaskcondNotify(session comm.IUserSession, condId int32) e } if taskConf != nil { if !this.modelWorldtask.IsPreFinished(userTask, taskConf) { - this.Errorf("世界任务已完成 uid:%v 要求taskid:%v", uid, id) + this.Debug("世界任务前置任务未完成", logFields) continue } @@ -96,29 +104,35 @@ func (this *Worldtask) TaskcondNotify(session comm.IUserSession, condId int32) e // 判断玩家等级要求 if user.Lv < taskConf.Lock { - this.Errorf("等级不满足 uid:%v 要求lv:%v", uid, taskConf.Lock) + logFields["当前lv"] = user.Lv + logFields["期望等级"] = taskConf.Lock + this.Debug("等级不满足", logFields) return comm.NewCustomError(pb.ErrorCode_WorldtaskLvNotEnough) } //完成任务 if err := this.modelWorldtask.finishTask(k, id, userTask); err != nil { - this.Errorf("世界任务完成失败 err:%v", err) + logFields["err"] = err.Error() + this.Error("世界任务完成", logFields) return err } - this.Debugf("任务条件达成完成 condId:%v group:%v taskId:%d", condId, k, id) + this.Debug("任务条件达成完成", logFields) //发奖 if code := this.DispenseRes(session, taskConf.Reword, true); code != pb.ErrorCode_Success { - this.Errorf("资源发放失败 err:%v", err) + logFields["reward"] = taskConf.Reword + logFields["code"] = code + this.Error("资源发放", logFields) } if nextTaskId != 0 { if err := session.SendMsg(string(this.GetType()), "nexttask", &pb.WorldtaskNexttaskPush{ NextTaskId: nextTaskId, }); err != nil { - log.Errorf("任务条件达成推送失败 err:%v", err) + logFields["err"] = err.Error() + log.Error("任务条件达成推送", logFields) } } else { - this.Debugf("已经是最后一个任务了 taskId:%v", taskConf.Key) + this.Debug("已经是最后一个任务了", logFields) } } @@ -133,7 +147,8 @@ func (this *Worldtask) TaskcondNotify(session comm.IUserSession, condId int32) e func (this *Worldtask) GetMyWorldtask(uid string) *pb.DBWorldtask { wt, err := this.modelWorldtask.getWorldtask(uid) if err != nil { - log.Errorf("GetMyWorldtask err:%v", err) + log.Errorln(err.Error()) + return nil } return wt } @@ -148,13 +163,8 @@ func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId // 更新数据 update := map[string]interface{}{} - conf, err := this.configure.getWorldtaskCfg() - if err != nil || conf == nil { - return errors.New("config is nil") - } - - taskConf, err := this.configure.getWorldtaskById(taskId) - if err != nil || taskConf == nil { + taskConf := this.worldtaskConf.GetDataMap()[taskId] + if taskConf == nil { return fmt.Errorf("taskId: %v config is nil", taskId) } @@ -166,7 +176,7 @@ func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId //遍历 if taskConf.Ontxe != 0 && taskConf.IdAfter != 0 { - for _, v := range conf.GetDataList() { + for _, v := range this.worldtaskConf.GetDataList() { if v.Group == groupId && v.Key <= taskId { mytask.LastTaskIds[groupId] = v.Key mytask.TaskList = append(mytask.TaskList, &pb.Worldtask{ @@ -188,12 +198,13 @@ func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId "taskList": mytask.TaskList, } - this.modelWorldtask.Change(uid, update) + if err := this.modelWorldtask.Change(uid, update); err != nil { + return err + } rsp := &pb.WorldtaskFinishIdsPush{ TaskList: mytask.TaskList, } - session.SendMsg(string(this.GetType()), "finishIds", rsp) - return nil + return session.SendMsg(string(this.GetType()), "finishIds", rsp) } diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index b39da82c3..ba2353600 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -203,18 +203,18 @@ const ( ErrorCode_SociatyNoFound ErrorCode = 3000 //公会不存在 ErrorCode_SociatyAdded ErrorCode = 3001 //已在公会里 ErrorCode_SociatyDiamondNoEnough ErrorCode = 3002 //钻石不足 - ErrorCode_SociatyApply ErrorCode = 3003 //申请失败 + ErrorCode_SociatyNoMember ErrorCode = 3003 //不是公会成员 ErrorCode_SociatyNoRight ErrorCode = 3004 //无权限 ErrorCode_SociatyNoAdded ErrorCode = 3005 //未加入公会 ErrorCode_SociatyDismiss ErrorCode = 3006 //解散失败 ErrorCode_SociatyQuit ErrorCode = 3007 //退会失败 ErrorCode_SociatyAgree ErrorCode = 3008 //申请-同意失败 ErrorCode_SociatyRefuse ErrorCode = 3009 //申请-拒绝失败 - ErrorCode_SociatyAssign ErrorCode = 30010 //公会转让失败 - ErrorCode_SociatyDischarge ErrorCode = 30011 //踢出失败 + ErrorCode_SociatyLogParams ErrorCode = 30010 //公会日志参数错误 + ErrorCode_SociatyMasterNoDiss ErrorCode = 30011 //会长不能被踢出 ErrorCode_SociatySettingJob ErrorCode = 30012 //设置职位失败 ErrorCode_SociatySetting ErrorCode = 30013 //公会修改失败 - ErrorCode_SociatyAccuse ErrorCode = 30014 //弹劾失败 + ErrorCode_SociatyNoAccuse ErrorCode = 30014 //无需弹劾 ErrorCode_SociatySign ErrorCode = 30015 //签到失败 ErrorCode_SociatySigned ErrorCode = 30016 //已签到 ErrorCode_SociatyCDLimit ErrorCode = 30017 // CD时间限制 @@ -224,7 +224,6 @@ const ( ErrorCode_SociatyRewardReceived ErrorCode = 30021 //奖励已领取 ErrorCode_SociatyRewardReceive ErrorCode = 30022 //奖励领取失败 ErrorCode_SociatyResource ErrorCode = 30023 //更新公会资源失败 - ErrorCode_SociatyApplyCanel ErrorCode = 30024 //申请撤销失败 ErrorCode_SociatyBelongTo ErrorCode = 30025 //已是公会成员 ErrorCode_SociatyApplied ErrorCode = 30026 //已申请 ErrorCode_SociatyAppyLvNoEnough ErrorCode = 30027 //申请等级不满足 @@ -234,6 +233,7 @@ const ( ErrorCode_SociatyDismissed ErrorCode = 30031 //公会已解散 ErrorCode_SociatyNameExist ErrorCode = 30032 //公会名存在 ErrorCode_SociatyQuitNoAllowed ErrorCode = 30033 //会长不允许退公会 + ErrorCode_SociatyNoMaster ErrorCode = 30034 //无会长 // arena ErrorCode_ArenaTicketBuyUp ErrorCode = 3101 //票据上限 ErrorCode_ArenaTicketNotEnough ErrorCode = 3102 //票据不足 @@ -435,18 +435,18 @@ var ( 3000: "SociatyNoFound", 3001: "SociatyAdded", 3002: "SociatyDiamondNoEnough", - 3003: "SociatyApply", + 3003: "SociatyNoMember", 3004: "SociatyNoRight", 3005: "SociatyNoAdded", 3006: "SociatyDismiss", 3007: "SociatyQuit", 3008: "SociatyAgree", 3009: "SociatyRefuse", - 30010: "SociatyAssign", - 30011: "SociatyDischarge", + 30010: "SociatyLogParams", + 30011: "SociatyMasterNoDiss", 30012: "SociatySettingJob", 30013: "SociatySetting", - 30014: "SociatyAccuse", + 30014: "SociatyNoAccuse", 30015: "SociatySign", 30016: "SociatySigned", 30017: "SociatyCDLimit", @@ -456,7 +456,6 @@ var ( 30021: "SociatyRewardReceived", 30022: "SociatyRewardReceive", 30023: "SociatyResource", - 30024: "SociatyApplyCanel", 30025: "SociatyBelongTo", 30026: "SociatyApplied", 30027: "SociatyAppyLvNoEnough", @@ -466,6 +465,7 @@ var ( 30031: "SociatyDismissed", 30032: "SociatyNameExist", 30033: "SociatyQuitNoAllowed", + 30034: "SociatyNoMaster", 3101: "ArenaTicketBuyUp", 3102: "ArenaTicketNotEnough", 3103: "ArenaTicketNpcInCd", @@ -655,18 +655,18 @@ var ( "SociatyNoFound": 3000, "SociatyAdded": 3001, "SociatyDiamondNoEnough": 3002, - "SociatyApply": 3003, + "SociatyNoMember": 3003, "SociatyNoRight": 3004, "SociatyNoAdded": 3005, "SociatyDismiss": 3006, "SociatyQuit": 3007, "SociatyAgree": 3008, "SociatyRefuse": 3009, - "SociatyAssign": 30010, - "SociatyDischarge": 30011, + "SociatyLogParams": 30010, + "SociatyMasterNoDiss": 30011, "SociatySettingJob": 30012, "SociatySetting": 30013, - "SociatyAccuse": 30014, + "SociatyNoAccuse": 30014, "SociatySign": 30015, "SociatySigned": 30016, "SociatyCDLimit": 30017, @@ -676,7 +676,6 @@ var ( "SociatyRewardReceived": 30021, "SociatyRewardReceive": 30022, "SociatyResource": 30023, - "SociatyApplyCanel": 30024, "SociatyBelongTo": 30025, "SociatyApplied": 30026, "SociatyAppyLvNoEnough": 30027, @@ -686,6 +685,7 @@ var ( "SociatyDismissed": 30031, "SociatyNameExist": 30032, "SociatyQuitNoAllowed": 30033, + "SociatyNoMaster": 30034, "ArenaTicketBuyUp": 3101, "ArenaTicketNotEnough": 3102, "ArenaTicketNpcInCd": 3103, @@ -747,7 +747,7 @@ var File_errorcode_proto protoreflect.FileDescriptor var file_errorcode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2a, 0xe7, 0x26, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0xf0, 0x26, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, @@ -970,95 +970,96 @@ var file_errorcode_proto_rawDesc = []byte{ 0x10, 0xb8, 0x17, 0x12, 0x11, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x64, 0x64, 0x65, 0x64, 0x10, 0xb9, 0x17, 0x12, 0x1b, 0x0a, 0x16, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x44, 0x69, 0x61, 0x6d, 0x6f, 0x6e, 0x64, 0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, - 0x10, 0xba, 0x17, 0x12, 0x11, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x70, - 0x70, 0x6c, 0x79, 0x10, 0xbb, 0x17, 0x12, 0x13, 0x0a, 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x79, 0x4e, 0x6f, 0x52, 0x69, 0x67, 0x68, 0x74, 0x10, 0xbc, 0x17, 0x12, 0x13, 0x0a, 0x0e, 0x53, - 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4e, 0x6f, 0x41, 0x64, 0x64, 0x65, 0x64, 0x10, 0xbd, 0x17, - 0x12, 0x13, 0x0a, 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x44, 0x69, 0x73, 0x6d, 0x69, - 0x73, 0x73, 0x10, 0xbe, 0x17, 0x12, 0x10, 0x0a, 0x0b, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, - 0x51, 0x75, 0x69, 0x74, 0x10, 0xbf, 0x17, 0x12, 0x11, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x69, 0x61, - 0x74, 0x79, 0x41, 0x67, 0x72, 0x65, 0x65, 0x10, 0xc0, 0x17, 0x12, 0x12, 0x0a, 0x0d, 0x53, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x65, 0x66, 0x75, 0x73, 0x65, 0x10, 0xc1, 0x17, 0x12, 0x13, - 0x0a, 0x0d, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x10, - 0xba, 0xea, 0x01, 0x12, 0x16, 0x0a, 0x10, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x44, 0x69, - 0x73, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x10, 0xbb, 0xea, 0x01, 0x12, 0x17, 0x0a, 0x11, 0x53, - 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x4a, 0x6f, 0x62, - 0x10, 0xbc, 0xea, 0x01, 0x12, 0x14, 0x0a, 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x53, - 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x10, 0xbd, 0xea, 0x01, 0x12, 0x13, 0x0a, 0x0d, 0x53, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x63, 0x63, 0x75, 0x73, 0x65, 0x10, 0xbe, 0xea, 0x01, 0x12, - 0x11, 0x0a, 0x0b, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x53, 0x69, 0x67, 0x6e, 0x10, 0xbf, - 0xea, 0x01, 0x12, 0x13, 0x0a, 0x0d, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x53, 0x69, 0x67, - 0x6e, 0x65, 0x64, 0x10, 0xc0, 0xea, 0x01, 0x12, 0x14, 0x0a, 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, - 0x74, 0x79, 0x43, 0x44, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x10, 0xc1, 0xea, 0x01, 0x12, 0x15, 0x0a, - 0x0f, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4d, 0x61, 0x78, - 0x10, 0xc2, 0xea, 0x01, 0x12, 0x18, 0x0a, 0x12, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x53, - 0x65, 0x6c, 0x66, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x10, 0xc3, 0xea, 0x01, 0x12, 0x1d, - 0x0a, 0x17, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x43, - 0x6f, 0x75, 0x6e, 0x74, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x10, 0xc4, 0xea, 0x01, 0x12, 0x1b, 0x0a, - 0x15, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, - 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x10, 0xc5, 0xea, 0x01, 0x12, 0x1a, 0x0a, 0x14, 0x53, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x63, 0x65, 0x69, - 0x76, 0x65, 0x10, 0xc6, 0xea, 0x01, 0x12, 0x15, 0x0a, 0x0f, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x79, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x10, 0xc7, 0xea, 0x01, 0x12, 0x17, 0x0a, - 0x11, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x61, 0x6e, - 0x65, 0x6c, 0x10, 0xc8, 0xea, 0x01, 0x12, 0x15, 0x0a, 0x0f, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x79, 0x42, 0x65, 0x6c, 0x6f, 0x6e, 0x67, 0x54, 0x6f, 0x10, 0xc9, 0xea, 0x01, 0x12, 0x14, 0x0a, - 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x64, 0x10, - 0xca, 0xea, 0x01, 0x12, 0x1b, 0x0a, 0x15, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x70, - 0x70, 0x79, 0x4c, 0x76, 0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xcb, 0xea, 0x01, - 0x12, 0x1b, 0x0a, 0x15, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x54, 0x61, 0x73, 0x6b, 0x56, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0xcc, 0xea, 0x01, 0x12, 0x1d, 0x0a, - 0x17, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, - 0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xcd, 0xea, 0x01, 0x12, 0x1c, 0x0a, 0x16, - 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x63, 0x69, 0x74, 0x76, 0x69, 0x74, 0x79, 0x52, - 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x10, 0xce, 0xea, 0x01, 0x12, 0x16, 0x0a, 0x10, 0x53, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x79, 0x44, 0x69, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x65, 0x64, 0x10, 0xcf, - 0xea, 0x01, 0x12, 0x16, 0x0a, 0x10, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4e, 0x61, 0x6d, - 0x65, 0x45, 0x78, 0x69, 0x73, 0x74, 0x10, 0xd0, 0xea, 0x01, 0x12, 0x1a, 0x0a, 0x14, 0x53, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x79, 0x51, 0x75, 0x69, 0x74, 0x4e, 0x6f, 0x41, 0x6c, 0x6c, 0x6f, 0x77, - 0x65, 0x64, 0x10, 0xd1, 0xea, 0x01, 0x12, 0x15, 0x0a, 0x10, 0x41, 0x72, 0x65, 0x6e, 0x61, 0x54, - 0x69, 0x63, 0x6b, 0x65, 0x74, 0x42, 0x75, 0x79, 0x55, 0x70, 0x10, 0x9d, 0x18, 0x12, 0x19, 0x0a, - 0x14, 0x41, 0x72, 0x65, 0x6e, 0x61, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x4e, 0x6f, 0x74, 0x45, - 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0x9e, 0x18, 0x12, 0x17, 0x0a, 0x12, 0x41, 0x72, 0x65, 0x6e, - 0x61, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x4e, 0x70, 0x63, 0x49, 0x6e, 0x43, 0x64, 0x10, 0x9f, - 0x18, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x70, 0x65, 0x61, - 0x74, 0x4c, 0x65, 0x61, 0x72, 0x6e, 0x10, 0x81, 0x19, 0x12, 0x12, 0x0a, 0x0d, 0x54, 0x61, 0x6c, - 0x65, 0x6e, 0x74, 0x45, 0x72, 0x72, 0x44, 0x61, 0x74, 0x61, 0x10, 0x82, 0x19, 0x12, 0x19, 0x0a, - 0x14, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x4c, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x42, - 0x65, 0x66, 0x6f, 0x72, 0x65, 0x10, 0x83, 0x19, 0x12, 0x15, 0x0a, 0x10, 0x54, 0x61, 0x6c, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x73, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x10, 0x84, 0x19, 0x12, - 0x10, 0x0a, 0x0b, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x42, 0x75, 0x79, 0x4d, 0x61, 0x78, 0x10, 0xe5, - 0x19, 0x12, 0x11, 0x0a, 0x0c, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x53, 0x65, 0x6c, 0x6c, 0x4d, 0x61, - 0x78, 0x10, 0xe6, 0x19, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x78, - 0x53, 0x65, 0x6c, 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x10, 0xe7, 0x19, 0x12, 0x16, 0x0a, 0x11, - 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x78, 0x49, 0x74, 0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, - 0x74, 0x10, 0xe8, 0x19, 0x12, 0x18, 0x0a, 0x13, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x52, 0x65, 0x70, - 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x10, 0xe9, 0x19, 0x12, 0x19, - 0x0a, 0x14, 0x48, 0x6f, 0x72, 0x6f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x4e, 0x6f, 0x74, 0x54, 0x75, - 0x72, 0x6e, 0x65, 0x64, 0x4f, 0x6e, 0x10, 0xc9, 0x1a, 0x12, 0x19, 0x0a, 0x14, 0x48, 0x6f, 0x72, - 0x6f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x52, 0x65, 0x73, 0x74, 0x43, 0x44, 0x4e, 0x6f, 0x45, 0x6e, - 0x64, 0x10, 0xca, 0x1a, 0x12, 0x16, 0x0a, 0x11, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, - 0x65, 0x4e, 0x6f, 0x74, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x10, 0xad, 0x1b, 0x12, 0x17, 0x0a, 0x12, - 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x52, 0x65, 0x6e, 0x65, 0x77, 0x54, 0x69, - 0x6d, 0x65, 0x10, 0xae, 0x1b, 0x12, 0x14, 0x0a, 0x0f, 0x47, 0x72, 0x6f, 0x77, 0x74, 0x61, 0x73, - 0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x10, 0x91, 0x1c, 0x12, 0x17, 0x0a, 0x12, 0x47, - 0x72, 0x6f, 0x77, 0x74, 0x61, 0x73, 0x6b, 0x41, 0x64, 0x76, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, - 0x65, 0x10, 0x92, 0x1c, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x61, 0x79, 0x42, 0x75, 0x79, 0x4e, 0x75, - 0x6d, 0x4e, 0x6f, 0x74, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xf5, 0x1c, 0x12, 0x14, 0x0a, - 0x0f, 0x50, 0x61, 0x79, 0x52, 0x65, 0x6e, 0x65, 0x77, 0x54, 0x69, 0x6d, 0x65, 0x45, 0x72, 0x72, - 0x10, 0xf6, 0x1c, 0x12, 0x14, 0x0a, 0x0f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, - 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x10, 0xd9, 0x1d, 0x12, 0x19, 0x0a, 0x14, 0x57, 0x6f, 0x72, - 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x4c, 0x76, 0x4e, 0x6f, 0x74, 0x45, 0x6e, 0x6f, 0x75, 0x67, - 0x68, 0x10, 0xda, 0x1d, 0x12, 0x16, 0x0a, 0x11, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, - 0x6b, 0x4e, 0x6f, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x10, 0xdb, 0x1d, 0x12, 0x18, 0x0a, 0x13, - 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x4e, 0x6f, 0x43, 0x6f, 0x6d, 0x70, 0x6c, - 0x65, 0x74, 0x65, 0x10, 0xdc, 0x1d, 0x12, 0x15, 0x0a, 0x10, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, - 0x61, 0x73, 0x6b, 0x46, 0x69, 0x6e, 0x69, 0x68, 0x65, 0x64, 0x10, 0xdd, 0x1d, 0x12, 0x1c, 0x0a, - 0x17, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x4c, 0x61, 0x73, 0x74, 0x55, 0x6e, - 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x10, 0xde, 0x1d, 0x12, 0x1e, 0x0a, 0x19, 0x41, - 0x63, 0x61, 0x64, 0x65, 0x6d, 0x79, 0x54, 0x61, 0x73, 0x6b, 0x4e, 0x6f, 0x43, 0x6f, 0x6d, 0x70, - 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x10, 0xbd, 0x1e, 0x42, 0x06, 0x5a, 0x04, 0x2e, - 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x10, 0xba, 0x17, 0x12, 0x14, 0x0a, 0x0f, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4e, 0x6f, + 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0xbb, 0x17, 0x12, 0x13, 0x0a, 0x0e, 0x53, 0x6f, 0x63, + 0x69, 0x61, 0x74, 0x79, 0x4e, 0x6f, 0x52, 0x69, 0x67, 0x68, 0x74, 0x10, 0xbc, 0x17, 0x12, 0x13, + 0x0a, 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4e, 0x6f, 0x41, 0x64, 0x64, 0x65, 0x64, + 0x10, 0xbd, 0x17, 0x12, 0x13, 0x0a, 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x44, 0x69, + 0x73, 0x6d, 0x69, 0x73, 0x73, 0x10, 0xbe, 0x17, 0x12, 0x10, 0x0a, 0x0b, 0x53, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x79, 0x51, 0x75, 0x69, 0x74, 0x10, 0xbf, 0x17, 0x12, 0x11, 0x0a, 0x0c, 0x53, 0x6f, + 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x67, 0x72, 0x65, 0x65, 0x10, 0xc0, 0x17, 0x12, 0x12, 0x0a, + 0x0d, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x65, 0x66, 0x75, 0x73, 0x65, 0x10, 0xc1, + 0x17, 0x12, 0x16, 0x0a, 0x10, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4c, 0x6f, 0x67, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x73, 0x10, 0xba, 0xea, 0x01, 0x12, 0x19, 0x0a, 0x13, 0x53, 0x6f, 0x63, + 0x69, 0x61, 0x74, 0x79, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x6f, 0x44, 0x69, 0x73, 0x73, + 0x10, 0xbb, 0xea, 0x01, 0x12, 0x17, 0x0a, 0x11, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x53, + 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x4a, 0x6f, 0x62, 0x10, 0xbc, 0xea, 0x01, 0x12, 0x14, 0x0a, + 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x10, + 0xbd, 0xea, 0x01, 0x12, 0x15, 0x0a, 0x0f, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4e, 0x6f, + 0x41, 0x63, 0x63, 0x75, 0x73, 0x65, 0x10, 0xbe, 0xea, 0x01, 0x12, 0x11, 0x0a, 0x0b, 0x53, 0x6f, + 0x63, 0x69, 0x61, 0x74, 0x79, 0x53, 0x69, 0x67, 0x6e, 0x10, 0xbf, 0xea, 0x01, 0x12, 0x13, 0x0a, + 0x0d, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x10, 0xc0, + 0xea, 0x01, 0x12, 0x14, 0x0a, 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x43, 0x44, 0x4c, + 0x69, 0x6d, 0x69, 0x74, 0x10, 0xc1, 0xea, 0x01, 0x12, 0x15, 0x0a, 0x0f, 0x53, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x79, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4d, 0x61, 0x78, 0x10, 0xc2, 0xea, 0x01, 0x12, + 0x18, 0x0a, 0x12, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x53, 0x65, 0x6c, 0x66, 0x53, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x10, 0xc3, 0xea, 0x01, 0x12, 0x1d, 0x0a, 0x17, 0x53, 0x6f, 0x63, + 0x69, 0x61, 0x74, 0x79, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x4c, + 0x69, 0x6d, 0x69, 0x74, 0x10, 0xc4, 0xea, 0x01, 0x12, 0x1b, 0x0a, 0x15, 0x53, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x79, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x64, 0x10, 0xc5, 0xea, 0x01, 0x12, 0x1a, 0x0a, 0x14, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, + 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x10, 0xc6, 0xea, + 0x01, 0x12, 0x15, 0x0a, 0x0f, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x10, 0xc7, 0xea, 0x01, 0x12, 0x15, 0x0a, 0x0f, 0x53, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x79, 0x42, 0x65, 0x6c, 0x6f, 0x6e, 0x67, 0x54, 0x6f, 0x10, 0xc9, 0xea, 0x01, 0x12, + 0x14, 0x0a, 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x65, + 0x64, 0x10, 0xca, 0xea, 0x01, 0x12, 0x1b, 0x0a, 0x15, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, + 0x41, 0x70, 0x70, 0x79, 0x4c, 0x76, 0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xcb, + 0xea, 0x01, 0x12, 0x1b, 0x0a, 0x15, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x54, 0x61, 0x73, + 0x6b, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0xcc, 0xea, 0x01, 0x12, + 0x1d, 0x0a, 0x17, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, + 0x74, 0x79, 0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xcd, 0xea, 0x01, 0x12, 0x1c, + 0x0a, 0x16, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x63, 0x69, 0x74, 0x76, 0x69, 0x74, + 0x79, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x10, 0xce, 0xea, 0x01, 0x12, 0x16, 0x0a, 0x10, + 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x44, 0x69, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x65, 0x64, + 0x10, 0xcf, 0xea, 0x01, 0x12, 0x16, 0x0a, 0x10, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4e, + 0x61, 0x6d, 0x65, 0x45, 0x78, 0x69, 0x73, 0x74, 0x10, 0xd0, 0xea, 0x01, 0x12, 0x1a, 0x0a, 0x14, + 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x51, 0x75, 0x69, 0x74, 0x4e, 0x6f, 0x41, 0x6c, 0x6c, + 0x6f, 0x77, 0x65, 0x64, 0x10, 0xd1, 0xea, 0x01, 0x12, 0x15, 0x0a, 0x0f, 0x53, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x79, 0x4e, 0x6f, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x10, 0xd2, 0xea, 0x01, 0x12, + 0x15, 0x0a, 0x10, 0x41, 0x72, 0x65, 0x6e, 0x61, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x42, 0x75, + 0x79, 0x55, 0x70, 0x10, 0x9d, 0x18, 0x12, 0x19, 0x0a, 0x14, 0x41, 0x72, 0x65, 0x6e, 0x61, 0x54, + 0x69, 0x63, 0x6b, 0x65, 0x74, 0x4e, 0x6f, 0x74, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0x9e, + 0x18, 0x12, 0x17, 0x0a, 0x12, 0x41, 0x72, 0x65, 0x6e, 0x61, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, + 0x4e, 0x70, 0x63, 0x49, 0x6e, 0x43, 0x64, 0x10, 0x9f, 0x18, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x61, + 0x6c, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x4c, 0x65, 0x61, 0x72, 0x6e, 0x10, + 0x81, 0x19, 0x12, 0x12, 0x0a, 0x0d, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x45, 0x72, 0x72, 0x44, + 0x61, 0x74, 0x61, 0x10, 0x82, 0x19, 0x12, 0x19, 0x0a, 0x14, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, + 0x55, 0x6e, 0x4c, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x42, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x10, 0x83, + 0x19, 0x12, 0x15, 0x0a, 0x10, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x65, 0x74, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x10, 0x84, 0x19, 0x12, 0x10, 0x0a, 0x0b, 0x54, 0x72, 0x6f, 0x6c, + 0x6c, 0x42, 0x75, 0x79, 0x4d, 0x61, 0x78, 0x10, 0xe5, 0x19, 0x12, 0x11, 0x0a, 0x0c, 0x54, 0x72, + 0x6f, 0x6c, 0x6c, 0x53, 0x65, 0x6c, 0x6c, 0x4d, 0x61, 0x78, 0x10, 0xe6, 0x19, 0x12, 0x16, 0x0a, + 0x11, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x78, 0x53, 0x65, 0x6c, 0x6c, 0x43, 0x6f, 0x75, + 0x6e, 0x74, 0x10, 0xe7, 0x19, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, + 0x78, 0x49, 0x74, 0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x10, 0xe8, 0x19, 0x12, 0x18, 0x0a, + 0x13, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x65, + 0x77, 0x61, 0x72, 0x64, 0x10, 0xe9, 0x19, 0x12, 0x19, 0x0a, 0x14, 0x48, 0x6f, 0x72, 0x6f, 0x73, + 0x63, 0x6f, 0x70, 0x65, 0x4e, 0x6f, 0x74, 0x54, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x4f, 0x6e, 0x10, + 0xc9, 0x1a, 0x12, 0x19, 0x0a, 0x14, 0x48, 0x6f, 0x72, 0x6f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x52, + 0x65, 0x73, 0x74, 0x43, 0x44, 0x4e, 0x6f, 0x45, 0x6e, 0x64, 0x10, 0xca, 0x1a, 0x12, 0x16, 0x0a, + 0x11, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x4e, 0x6f, 0x74, 0x46, 0x6f, 0x75, + 0x6e, 0x64, 0x10, 0xad, 0x1b, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, + 0x67, 0x65, 0x52, 0x65, 0x6e, 0x65, 0x77, 0x54, 0x69, 0x6d, 0x65, 0x10, 0xae, 0x1b, 0x12, 0x14, + 0x0a, 0x0f, 0x47, 0x72, 0x6f, 0x77, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, + 0x65, 0x10, 0x91, 0x1c, 0x12, 0x17, 0x0a, 0x12, 0x47, 0x72, 0x6f, 0x77, 0x74, 0x61, 0x73, 0x6b, + 0x41, 0x64, 0x76, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x10, 0x92, 0x1c, 0x12, 0x17, 0x0a, + 0x12, 0x50, 0x61, 0x79, 0x42, 0x75, 0x79, 0x4e, 0x75, 0x6d, 0x4e, 0x6f, 0x74, 0x45, 0x6e, 0x6f, + 0x75, 0x67, 0x68, 0x10, 0xf5, 0x1c, 0x12, 0x14, 0x0a, 0x0f, 0x50, 0x61, 0x79, 0x52, 0x65, 0x6e, + 0x65, 0x77, 0x54, 0x69, 0x6d, 0x65, 0x45, 0x72, 0x72, 0x10, 0xf6, 0x1c, 0x12, 0x14, 0x0a, 0x0f, + 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x10, + 0xd9, 0x1d, 0x12, 0x19, 0x0a, 0x14, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x4c, + 0x76, 0x4e, 0x6f, 0x74, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xda, 0x1d, 0x12, 0x16, 0x0a, + 0x11, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x4e, 0x6f, 0x41, 0x63, 0x63, 0x65, + 0x70, 0x74, 0x10, 0xdb, 0x1d, 0x12, 0x18, 0x0a, 0x13, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, + 0x73, 0x6b, 0x4e, 0x6f, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x10, 0xdc, 0x1d, 0x12, + 0x15, 0x0a, 0x10, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x46, 0x69, 0x6e, 0x69, + 0x68, 0x65, 0x64, 0x10, 0xdd, 0x1d, 0x12, 0x1c, 0x0a, 0x17, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, + 0x61, 0x73, 0x6b, 0x4c, 0x61, 0x73, 0x74, 0x55, 0x6e, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, + 0x64, 0x10, 0xde, 0x1d, 0x12, 0x1e, 0x0a, 0x19, 0x41, 0x63, 0x61, 0x64, 0x65, 0x6d, 0x79, 0x54, + 0x61, 0x73, 0x6b, 0x4e, 0x6f, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x73, + 0x6b, 0x10, 0xbd, 0x1e, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/utils/strings.go b/utils/strings.go index ba75ad482..631a913ff 100644 --- a/utils/strings.go +++ b/utils/strings.go @@ -39,6 +39,17 @@ func Find(slice []string, val string) (int, bool) { return -1, false } +func Deletex[T string | int32](slice []T, val T) []T { + result := make([]T, 0) + for _, v := range slice { + if v != val { + result = append(result, v) + } + } + return result +} + +// Deprecated: Use Deletex instead func DeleteString(list []string, ele string) []string { result := make([]string, 0) for _, v := range list { diff --git a/utils/utils_test.go b/utils/utils_test.go index 42a04bd06..0bff6a796 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -81,4 +81,10 @@ func TestCompre(t *testing.T){ a:=[]int32{1,2,4,5} b:=[]int32{1,2,4} fmt.Println(utils.ForContainer(a,b)) +} + +func TestDeletex(t *testing.T){ + a:=[]int32{1,2,3,4} + c:=utils.Deletex(a, 2) + fmt.Println(c) } \ No newline at end of file