From 8d08a26cc4594f2bc20781508dafd1671f12b997 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 20 Oct 2022 18:22:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E9=94=AE=E6=9F=A5=E8=AF=A2=E5=A4=9A?= =?UTF-8?q?=E5=90=8D=E8=8B=B1=E9=9B=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/api_info.go | 15 +++++++++------ pb/hero_msg.pb.go | 32 ++++++++++++++++---------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/modules/hero/api_info.go b/modules/hero/api_info.go index f9d6fb93a..e5234f38a 100644 --- a/modules/hero/api_info.go +++ b/modules/hero/api_info.go @@ -12,7 +12,7 @@ import ( //参数校验 func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.HeroInfoReq) (code pb.ErrorCode) { - if req.HeroId == "" { + if len(req.HeroId) == 0 { code = pb.ErrorCode_ReqParameterError } return @@ -22,7 +22,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.HeroInfoReq) (code var ( uid string ) - hero := &pb.DBHero{} + if code = this.InfoCheck(session, req); code != pb.ErrorCode_Success { return } @@ -38,10 +38,13 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.HeroInfoReq) (code if b { if conn, err := db.ServerDBConn(tag); err == nil { dbModel := db.NewDBModel(comm.TableHero, time.Hour, conn) - if err = dbModel.GetListObj(uid, req.HeroId, hero); err == nil { - rsp.Base = hero - } else { - this.module.Errorf("err:%v", err) + for _, v := range req.HeroId { + hero := &pb.DBHero{} + if err = dbModel.GetListObj(uid, v, hero); err == nil { + rsp.Base = append(rsp.Base, hero) + } else { + this.module.Errorf("err:%v", err) + } } } } diff --git a/pb/hero_msg.pb.go b/pb/hero_msg.pb.go index d1ddadbc3..4da5f19e6 100644 --- a/pb/hero_msg.pb.go +++ b/pb/hero_msg.pb.go @@ -26,8 +26,8 @@ type HeroInfoReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - HeroId string `protobuf:"bytes,1,opt,name=heroId,proto3" json:"heroId"` //英雄唯一ID - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` // uid 查自己不传也可以 + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` // uid 查自己不传也可以 + HeroId []string `protobuf:"bytes,2,rep,name=heroId,proto3" json:"heroId"` //英雄唯一ID } func (x *HeroInfoReq) Reset() { @@ -62,13 +62,6 @@ func (*HeroInfoReq) Descriptor() ([]byte, []int) { return file_hero_hero_msg_proto_rawDescGZIP(), []int{0} } -func (x *HeroInfoReq) GetHeroId() string { - if x != nil { - return x.HeroId - } - return "" -} - func (x *HeroInfoReq) GetUid() string { if x != nil { return x.Uid @@ -76,12 +69,19 @@ func (x *HeroInfoReq) GetUid() string { return "" } +func (x *HeroInfoReq) GetHeroId() []string { + if x != nil { + return x.HeroId + } + return nil +} + type HeroInfoResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Base *DBHero `protobuf:"bytes,1,opt,name=base,proto3" json:"base"` + Base []*DBHero `protobuf:"bytes,1,rep,name=base,proto3" json:"base"` } func (x *HeroInfoResp) Reset() { @@ -116,7 +116,7 @@ func (*HeroInfoResp) Descriptor() ([]byte, []int) { return file_hero_hero_msg_proto_rawDescGZIP(), []int{1} } -func (x *HeroInfoResp) GetBase() *DBHero { +func (x *HeroInfoResp) GetBase() []*DBHero { if x != nil { return x.Base } @@ -1803,11 +1803,11 @@ var file_hero_hero_msg_proto_rawDesc = []byte{ 0x0a, 0x13, 0x68, 0x65, 0x72, 0x6f, 0x2f, 0x68, 0x65, 0x72, 0x6f, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x68, 0x65, 0x72, 0x6f, 0x2f, 0x68, 0x65, 0x72, 0x6f, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x37, 0x0a, 0x0b, 0x48, 0x65, 0x72, - 0x6f, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, - 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, - 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, - 0x69, 0x64, 0x22, 0x2b, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, - 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x6f, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, + 0x72, 0x6f, 0x49, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, + 0x49, 0x64, 0x22, 0x2b, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, + 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x22, 0x0d, 0x0a, 0x0b, 0x48, 0x65, 0x72, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x2b, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1b,