一键查询多名英雄信息

This commit is contained in:
meixiongfeng 2022-10-20 18:22:09 +08:00
parent 991a1e6bfd
commit 8d08a26cc4
2 changed files with 25 additions and 22 deletions

View File

@ -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,13 +38,16 @@ 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
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)
}
}
}
}
session.SendMsg(string(this.module.GetType()), HeroSubTypeInfo, rsp)
return

View File

@ -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,