diff --git a/cmd/robot/friend.go b/cmd/robot/friend.go index f17577b20..72c3335ea 100644 --- a/cmd/robot/friend.go +++ b/cmd/robot/friend.go @@ -23,46 +23,56 @@ var ( subType: friend.FriendSubTypeBlacklist, req: &pb.FriendBlackListReq{}, rsp: &pb.FriendBlackListResp{}, + // enabled: true, }, { //search mainType: string(comm.ModuleFriend), subType: friend.FriendSubTypeSearch, req: &pb.FriendSearchReq{ - NickName: "", //设置测试参数 + NickName: "乐谷745", //设置测试参数 }, - rsp: &pb.FriendSearchResp{}, + rsp: &pb.FriendSearchResp{}, // enabled: true, }, { //apply mainType: string(comm.ModuleFriend), subType: friend.FriendSubTypeApply, - req: &pb.FriendApplyReq{}, - rsp: &pb.FriendApplyResp{}, - // enabled: true, + req: &pb.FriendApplyReq{ + FriendId: "0_62c28ab569b7d416cf9eb8c7", + }, + rsp: &pb.FriendApplyResp{}, + // enabled: true, }, { //applylist mainType: string(comm.ModuleFriend), subType: friend.FriendSubTypeApplyList, req: &pb.FriendApplyListReq{}, rsp: &pb.FriendApplyListResp{}, + enabled: true, }, { //agree mainType: string(comm.ModuleFriend), subType: friend.FriendSubTypeAgree, - req: &pb.FriendAgreeReq{}, - rsp: &pb.FriendAgreeResp{}, + req: &pb.FriendAgreeReq{ + FriendIds: []string{"0_62c28ab569b7d416cf9eb8c7"}, + }, + rsp: &pb.FriendAgreeResp{}, + // enabled: true, }, { //refuse mainType: string(comm.ModuleFriend), subType: friend.FriendSubTypeRefuse, - req: &pb.FriendAgreeReq{}, - rsp: &pb.FriendAgreeResp{}, + req: &pb.FriendRefuseReq{ + FriendIds: []string{"0_62c28bcb69b7d416cf9eb8c9"}, + }, + rsp: &pb.FriendRefuseResp{}, + enabled: true, }, { //addblack mainType: string(comm.ModuleFriend), subType: friend.FriendSubTypeAddBlack, req: &pb.FriendBlackAddReq{ - FriendId: "0_62be9f40f67327fb53039b70", + FriendId: "0_62c26323e5cc5577d41bf591", }, rsp: &pb.FriendBlackAddResp{}, // enabled: true, @@ -72,6 +82,7 @@ var ( subType: friend.FriendSubTypeDelBlack, req: &pb.FriendDelBlackReq{}, rsp: &pb.FriendDelBlackResp{}, + // enabled: true, }, } ) diff --git a/cmd/robot/hero.go b/cmd/robot/hero.go index 06bb8f1f0..779d069ea 100644 --- a/cmd/robot/hero.go +++ b/cmd/robot/hero.go @@ -24,7 +24,7 @@ var ( fmt.Printf("%d- %v\n", (i + 1), v) } }, - enabled: true, + // enabled: true, }, { mainType: string(comm.ModuleHero), subType: hero.HeroSubTypeInfo, diff --git a/cmd/robot/user.go b/cmd/robot/user.go index b0b63b17f..56419ee4c 100644 --- a/cmd/robot/user.go +++ b/cmd/robot/user.go @@ -14,9 +14,9 @@ var user_builders = []*TestCase{ mainType: string(comm.ModuleUser), subType: user.UserSubTypeCreate, req: &pb.UserCreateReq{ //设置请求参数 - NickName: "乐谷6301", + NickName: "乐谷748", }, - rsp: &pb.UserCreateResp{}, + rsp: &pb.UserCreateResp{}, // enabled: true, }, { Desc: "添加资源", diff --git a/modules/friend/api_addblack.go b/modules/friend/api_addblack.go index 6fb568712..fe82cfb10 100644 --- a/modules/friend/api_addblack.go +++ b/modules/friend/api_addblack.go @@ -17,11 +17,15 @@ func (this *apiComp) AddblackCheck(session comm.IUserSession, req *pb.FriendBlac //加入黑名单 func (this *apiComp) Addblack(session comm.IUserSession, req *pb.FriendBlackAddReq) (code pb.ErrorCode, data proto.Message) { + if code = this.AddblackCheck(session, req); code != pb.ErrorCode_Success { + return + } + var ( err error self *pb.DBFriend target *pb.DBFriend - Resp *pb.FriendBlackAddResp + Resp *pb.FriendBlackAddResp ) defer func() { diff --git a/modules/friend/api_agree.go b/modules/friend/api_agree.go index a6a0225ed..e000fb719 100644 --- a/modules/friend/api_agree.go +++ b/modules/friend/api_agree.go @@ -18,11 +18,14 @@ func (this *apiComp) AgreeCheck(session comm.IUserSession, req *pb.FriendAgreeRe //单个/批量同意 func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (code pb.ErrorCode, data proto.Message) { + if code = this.AgreeCheck(session, req); code != pb.ErrorCode_Success { + return + } var ( err error self *pb.DBFriend target *pb.DBFriend - Resp *pb.FriendAgreeResp + Resp *pb.FriendAgreeResp optNum int32 ) diff --git a/modules/friend/api_apply.go b/modules/friend/api_apply.go index 444d30955..2820b4fc2 100644 --- a/modules/friend/api_apply.go +++ b/modules/friend/api_apply.go @@ -18,11 +18,15 @@ func (this *apiComp) ApplyCheck(session comm.IUserSession, req *pb.FriendApplyRe //好友申请 func (this *apiComp) Apply(session comm.IUserSession, req *pb.FriendApplyReq) (code pb.ErrorCode, data proto.Message) { + if code = this.ApplyCheck(session, req); code != pb.ErrorCode_Success { + return + } + var ( err error self *pb.DBFriend target *pb.DBFriend - Resp *pb.FriendApplyResp + Resp *pb.FriendApplyResp ) defer func() { @@ -45,14 +49,14 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.FriendApplyReq) (c //获取玩家自己好友数据 self = this.module.modelFriend.GetFriend(session.GetUserId()) - if self == nil || err != nil { + if self == nil { code = pb.ErrorCode_FriendSelfNoData return } //获取好友数据 target = this.module.modelFriend.GetFriend(req.FriendId) - if target == nil || err != nil { + if target == nil { code = pb.ErrorCode_FriendTargetNoData return } diff --git a/modules/friend/api_applylist.go b/modules/friend/api_applylist.go index b7c235208..eba214d88 100644 --- a/modules/friend/api_applylist.go +++ b/modules/friend/api_applylist.go @@ -3,19 +3,19 @@ package friend import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + + "google.golang.org/protobuf/proto" ) func (this *apiComp) ApplyListCheck(session comm.IUserSession, req *pb.FriendApplyListReq) (code pb.ErrorCode) { - return } //申请列表 -func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.FriendApplyListReq) (code pb.ErrorCode) { +func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.FriendApplyListReq) (code pb.ErrorCode, data proto.Message) { var ( - err error self *pb.DBFriend - Resp *pb.FriendApplyListResp + Resp *pb.FriendApplyListResp list []*pb.FriendBase ) @@ -31,7 +31,7 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.FriendApplyLis }() self = this.module.modelFriend.GetFriend(session.GetUserId()) - if self == nil || err != nil { + if self == nil { code = pb.ErrorCode_FriendSelfNoData return } diff --git a/modules/friend/api_blacklist.go b/modules/friend/api_blacklist.go index 91c9174d6..38f5c3ee9 100644 --- a/modules/friend/api_blacklist.go +++ b/modules/friend/api_blacklist.go @@ -13,8 +13,7 @@ func (this *apiComp) BlacklistCheck(session comm.IUserSession, req *pb.FriendBla //黑名单 func (this *apiComp) Blacklist(session comm.IUserSession, req *pb.FriendBlackListReq) (code pb.ErrorCode, data proto.Message) { - var ( - err error + var ( self *pb.DBFriend Resp *pb.FriendBlackListResp list []*pb.FriendBase @@ -33,7 +32,7 @@ func (this *apiComp) Blacklist(session comm.IUserSession, req *pb.FriendBlackLis }() self = this.module.modelFriend.GetFriend(session.GetUserId()) - if self == nil || err != nil { + if self == nil { code = pb.ErrorCode_FriendSelfNoData return } diff --git a/modules/friend/api_delblack.go b/modules/friend/api_delblack.go index bd4cbaf59..d82213416 100644 --- a/modules/friend/api_delblack.go +++ b/modules/friend/api_delblack.go @@ -17,10 +17,13 @@ func (this *apiComp) DelblackCheck(session comm.IUserSession, req *pb.FriendDelB //删除黑名单 func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackReq) (code pb.ErrorCode, data proto.Message) { + if code = this.DelblackCheck(session, req); code != pb.ErrorCode_Success { + return + } var ( err error self *pb.DBFriend - Resp *pb.FriendDelBlackResp + Resp *pb.FriendDelBlackResp ) defer func() { if code == pb.ErrorCode_Success { @@ -37,7 +40,7 @@ func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackR }() self = this.module.modelFriend.GetFriend(session.GetUserId()) - if self == nil || err != nil { + if self == nil { code = pb.ErrorCode_FriendSelfNoData return } diff --git a/modules/friend/api_refuse.go b/modules/friend/api_refuse.go index c84b7d14a..6cbc48db7 100644 --- a/modules/friend/api_refuse.go +++ b/modules/friend/api_refuse.go @@ -18,11 +18,13 @@ func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.FriendRefuse //单个/批量拒绝 func (this *apiComp) Refuse(session comm.IUserSession, req *pb.FriendRefuseReq) (code pb.ErrorCode, data proto.Message) { + if code = this.RefuseCheck(session, req); code != pb.ErrorCode_Success { + return + } //将申请人从申请列表中删除 var ( - err error self *pb.DBFriend - Resp *pb.FriendRefuseResp + Resp *pb.FriendRefuseResp optNum int32 ) defer func() { @@ -39,7 +41,7 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.FriendRefuseReq) //获取玩家自己好友数据 self = this.module.modelFriend.GetFriend(session.GetUserId()) - if self == nil || err != nil { + if self == nil { code = pb.ErrorCode_FriendSelfNoData return } diff --git a/modules/friend/api_search.go b/modules/friend/api_search.go index 6c649c314..de242de3b 100644 --- a/modules/friend/api_search.go +++ b/modules/friend/api_search.go @@ -17,8 +17,12 @@ func (this *apiComp) SearchCheck(session comm.IUserSession, req *pb.FriendSearch //搜索 func (this *apiComp) Search(session comm.IUserSession, req *pb.FriendSearchReq) (code pb.ErrorCode, data proto.Message) { + if code = this.SearchCheck(session, req); code != pb.ErrorCode_Success { + return + } + var ( - Resp *pb.FriendSearchResp + Resp *pb.FriendSearchResp friend *pb.FriendBase ) defer func() { diff --git a/modules/hero/api_info.go b/modules/hero/api_info.go index f303e20e1..5e7024a30 100644 --- a/modules/hero/api_info.go +++ b/modules/hero/api_info.go @@ -10,10 +10,17 @@ import ( //参数校验 func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.HeroInfoReq) (code pb.ErrorCode) { + if req.HeroId != "" { + code = pb.ErrorCode_ReqParameterError + } return } func (this *apiComp) Info(session comm.IUserSession, req *pb.HeroInfoReq) (code pb.ErrorCode, data proto.Message) { + if code = this.InfoCheck(session, req); code != pb.ErrorCode_Success { + return + } + rsp := &pb.HeroInfoResp{} defer func() { err := session.SendMsg(string(this.module.GetType()), HeroSubTypeInfo, rsp) diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 1b2cf080d..c97465a10 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -166,14 +166,11 @@ func (this *ModelHero) getHeroList(uid string) ([]*pb.DBHero, error) { } //更新装备 -func (this *ModelHero) setEquipment(uid, heroId string, equipIds []string) pb.ErrorCode { - hero := this.getOneHero(uid, heroId) - if hero == nil { - return pb.ErrorCode_HeroNoExist +func (this *ModelHero) setEquipment(uid, heroId string, equipIds []string) error { + update := map[string]interface{}{ + "equipID": equipIds, } - - hero.EquipID = equipIds - return pb.ErrorCode_Success + return this.moduleHero.modelHero.modifyHeroData(uid, heroId, update) } //合并属性即属性值累加 diff --git a/modules/hero/module.go b/modules/hero/module.go index b9e08397b..0acb29557 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -96,7 +96,11 @@ func (this *Hero) UpdateEquipment(hero *pb.DBHero, equip []*pb.DB_Equipment) (co this.modelHero.mergeMainProperty(hero.Uid, hero.Id, property) this.modelHero.mergeAddProperty(hero.Uid, hero.Id, addProperty) - return this.modelHero.setEquipment(hero.Uid, hero.Id, equipIds) + if err := this.modelHero.setEquipment(hero.Uid, hero.Id, equipIds); err != nil { + code = pb.ErrorCode_HeroEquipUpdate + return + } + return } //英雄列表 diff --git a/modules/user/api_create.go b/modules/user/api_create.go index 4bbb4cba1..db736d749 100644 --- a/modules/user/api_create.go +++ b/modules/user/api_create.go @@ -19,6 +19,9 @@ func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.UserCreateRe //创角 func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (code pb.ErrorCode, data proto.Message) { + if code = this.CreateCheck(session, req); code != pb.ErrorCode_Success { + return + } var err error defer utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), UserSubTypeCreate, req, nil) diff --git a/modules/user/api_login.go b/modules/user/api_login.go index 008052285..2f900849b 100644 --- a/modules/user/api_login.go +++ b/modules/user/api_login.go @@ -22,6 +22,9 @@ func (this *apiComp) LoginCheck(session comm.IUserSession, req *pb.UserLoginReq) //登录 func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (code pb.ErrorCode, data proto.Message) { + if code = this.LoginCheck(session, req); code != pb.ErrorCode_Success { + return + } var ( err error user *pb.DBUser @@ -40,7 +43,6 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod } }() - //从mgo查询user user, err = this.module.modelUser.User_FindByAccount(req.Sid, req.Account) if err != nil { diff --git a/modules/user/api_res.go b/modules/user/api_res.go index 91b76e42f..88f7e5605 100644 --- a/modules/user/api_res.go +++ b/modules/user/api_res.go @@ -15,6 +15,10 @@ func (this *apiComp) AddResCheck(session comm.IUserSession, req *pb.UserAddResRe } func (this *apiComp) AddRes(session comm.IUserSession, req *pb.UserAddResReq) (code pb.ErrorCode, data proto.Message) { + if code = this.AddResCheck(session, req); code != pb.ErrorCode_Success { + return + } + rsp := &pb.UserAddResResp{} defer func() { diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index c26a9ca0a..e385afb8c 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -79,6 +79,7 @@ const ( ErrorCode_HeroNotNeedResonate ErrorCode = 1308 // 不需要重置共鸣 ErrorCode_HeroNoEnergy ErrorCode = 1309 // 没有能量点数 ErrorCode_HeroCreate ErrorCode = 1310 // 创建卡失败 + ErrorCode_HeroEquipUpdate ErrorCode = 1311 //更新装备失败 // equipment ErrorCode_EquipmentOnFoundEquipment ErrorCode = 1400 // 未找到武器 ErrorCode_EquipmentLvlimitReached ErrorCode = 1401 // 武器等级已达上限 @@ -139,6 +140,7 @@ var ( 1308: "HeroNotNeedResonate", 1309: "HeroNoEnergy", 1310: "HeroCreate", + 1311: "HeroEquipUpdate", 1400: "EquipmentOnFoundEquipment", 1401: "EquipmentLvlimitReached", } @@ -195,6 +197,7 @@ var ( "HeroNotNeedResonate": 1308, "HeroNoEnergy": 1309, "HeroCreate": 1310, + "HeroEquipUpdate": 1311, "EquipmentOnFoundEquipment": 1400, "EquipmentLvlimitReached": 1401, } @@ -231,7 +234,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, 0xf2, 0x08, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0x88, 0x09, 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, @@ -298,12 +301,13 @@ var file_errorcode_proto_rawDesc = []byte{ 0x72, 0x6f, 0x4e, 0x6f, 0x74, 0x4e, 0x65, 0x65, 0x64, 0x52, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x10, 0x9c, 0x0a, 0x12, 0x11, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x4e, 0x6f, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x10, 0x9d, 0x0a, 0x12, 0x0f, 0x0a, 0x0a, 0x48, 0x65, 0x72, 0x6f, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x10, 0x9e, 0x0a, 0x12, 0x1e, 0x0a, 0x19, 0x45, 0x71, 0x75, 0x69, - 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4f, 0x6e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x45, 0x71, 0x75, 0x69, - 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0xf8, 0x0a, 0x12, 0x1c, 0x0a, 0x17, 0x45, 0x71, 0x75, 0x69, - 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x76, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x61, 0x63, - 0x68, 0x65, 0x64, 0x10, 0xf9, 0x0a, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x10, 0x9e, 0x0a, 0x12, 0x14, 0x0a, 0x0f, 0x48, 0x65, 0x72, 0x6f, + 0x45, 0x71, 0x75, 0x69, 0x70, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x10, 0x9f, 0x0a, 0x12, 0x1e, + 0x0a, 0x19, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4f, 0x6e, 0x46, 0x6f, 0x75, + 0x6e, 0x64, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0xf8, 0x0a, 0x12, 0x1c, + 0x0a, 0x17, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x76, 0x6c, 0x69, 0x6d, + 0x69, 0x74, 0x52, 0x65, 0x61, 0x63, 0x68, 0x65, 0x64, 0x10, 0xf9, 0x0a, 0x42, 0x06, 0x5a, 0x04, + 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/proto/errorcode.proto b/pb/proto/errorcode.proto index e519f654e..709e4b3ae 100644 --- a/pb/proto/errorcode.proto +++ b/pb/proto/errorcode.proto @@ -51,18 +51,18 @@ enum ErrorCode { ItemsGirdAmountUpper = 1203; //背包格子容量已达上限 // hero - HeroNoExist = 1300; //英雄不存在 - HeroNoEnough = 1301; //英雄数量不足 - HeroMaxLv = 1302; //英雄达到最大等级 - HeroInitCreat = 1303; //初始化英雄 - - HeroColorErr = 1304; // 品质不匹配 - HeroSkillUpErr = 1305;// 技能升级失败 - HeroMaxResonate = 1306; // 达到最大共鸣次数 - HeroNoResonate = 1307; // 没有共鸣 + HeroNoExist = 1300; //英雄不存在 + HeroNoEnough = 1301; //英雄数量不足 + HeroMaxLv = 1302; //英雄达到最大等级 + HeroInitCreat = 1303; //初始化英雄 + HeroColorErr = 1304; // 品质不匹配 + HeroSkillUpErr = 1305; // 技能升级失败 + HeroMaxResonate = 1306; // 达到最大共鸣次数 + HeroNoResonate = 1307; // 没有共鸣 HeroNotNeedResonate = 1308; // 不需要重置共鸣 - HeroNoEnergy = 1309; // 没有能量点数 - HeroCreate = 1310; // 创建卡失败 + HeroNoEnergy = 1309; // 没有能量点数 + HeroCreate = 1310; // 创建卡失败 + HeroEquipUpdate = 1311; //更新装备失败 // equipment EquipmentOnFoundEquipment = 1400; // 未找到武器