一键查询多名英雄信息
This commit is contained in:
parent
991a1e6bfd
commit
8d08a26cc4
@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.HeroInfoReq) (code pb.ErrorCode) {
|
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
|
code = pb.ErrorCode_ReqParameterError
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -22,7 +22,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.HeroInfoReq) (code
|
|||||||
var (
|
var (
|
||||||
uid string
|
uid string
|
||||||
)
|
)
|
||||||
hero := &pb.DBHero{}
|
|
||||||
if code = this.InfoCheck(session, req); code != pb.ErrorCode_Success {
|
if code = this.InfoCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -38,10 +38,13 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.HeroInfoReq) (code
|
|||||||
if b {
|
if b {
|
||||||
if conn, err := db.ServerDBConn(tag); err == nil {
|
if conn, err := db.ServerDBConn(tag); err == nil {
|
||||||
dbModel := db.NewDBModel(comm.TableHero, time.Hour, conn)
|
dbModel := db.NewDBModel(comm.TableHero, time.Hour, conn)
|
||||||
if err = dbModel.GetListObj(uid, req.HeroId, hero); err == nil {
|
for _, v := range req.HeroId {
|
||||||
rsp.Base = hero
|
hero := &pb.DBHero{}
|
||||||
} else {
|
if err = dbModel.GetListObj(uid, v, hero); err == nil {
|
||||||
this.module.Errorf("err:%v", err)
|
rsp.Base = append(rsp.Base, hero)
|
||||||
|
} else {
|
||||||
|
this.module.Errorf("err:%v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ type HeroInfoReq struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
HeroId string `protobuf:"bytes,1,opt,name=heroId,proto3" json:"heroId"` //英雄唯一ID
|
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` // uid 查自己不传也可以
|
||||||
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` // uid 查自己不传也可以
|
HeroId []string `protobuf:"bytes,2,rep,name=heroId,proto3" json:"heroId"` //英雄唯一ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *HeroInfoReq) Reset() {
|
func (x *HeroInfoReq) Reset() {
|
||||||
@ -62,13 +62,6 @@ func (*HeroInfoReq) Descriptor() ([]byte, []int) {
|
|||||||
return file_hero_hero_msg_proto_rawDescGZIP(), []int{0}
|
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 {
|
func (x *HeroInfoReq) GetUid() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Uid
|
return x.Uid
|
||||||
@ -76,12 +69,19 @@ func (x *HeroInfoReq) GetUid() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *HeroInfoReq) GetHeroId() []string {
|
||||||
|
if x != nil {
|
||||||
|
return x.HeroId
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type HeroInfoResp struct {
|
type HeroInfoResp struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
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() {
|
func (x *HeroInfoResp) Reset() {
|
||||||
@ -116,7 +116,7 @@ func (*HeroInfoResp) Descriptor() ([]byte, []int) {
|
|||||||
return file_hero_hero_msg_proto_rawDescGZIP(), []int{1}
|
return file_hero_hero_msg_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *HeroInfoResp) GetBase() *DBHero {
|
func (x *HeroInfoResp) GetBase() []*DBHero {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Base
|
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,
|
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,
|
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,
|
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,
|
0x6f, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18,
|
||||||
0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64,
|
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65,
|
||||||
0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75,
|
0x72, 0x6f, 0x49, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f,
|
||||||
0x69, 0x64, 0x22, 0x2b, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65,
|
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, 0x01, 0x28, 0x0b,
|
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,
|
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,
|
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,
|
0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1b,
|
||||||
|
Loading…
Reference in New Issue
Block a user