批量查询英雄接口
This commit is contained in:
parent
16c820858f
commit
79fb4b27eb
@ -100,6 +100,9 @@ type (
|
||||
|
||||
// 教习登记
|
||||
RegisterInstructor(session IUserSession, heroOid []string, registerId int32) (code pb.ErrorCode)
|
||||
|
||||
// 跨服查询英雄详细信息
|
||||
QueryCrossMultipleHeroinfo(oid []string) (hero []*pb.DBHero, err error)
|
||||
}
|
||||
|
||||
//玩家
|
||||
|
@ -935,3 +935,42 @@ func (this *Hero) DrawCardContinuousRestrictionCamp(cardId string, race map[int3
|
||||
}
|
||||
return card
|
||||
}
|
||||
|
||||
// 只通过唯一id 查询英雄信息
|
||||
func (this *Hero) QueryCrossMultipleHeroinfo(oid []string) (hero []*pb.DBHero, err error) {
|
||||
if this.IsCross() {
|
||||
for _, tag := range db.GetServerTags() {
|
||||
conn, err1 := db.ServerDBConn(tag) // 遍历连接对象
|
||||
if err1 != nil {
|
||||
continue
|
||||
}
|
||||
for _, v := range oid {
|
||||
sr := conn.Mgo.FindOne(comm.TableHero, bson.M{
|
||||
"_id": v,
|
||||
})
|
||||
_hero := &pb.DBHero{}
|
||||
if err = sr.Decode(hero); err != nil {
|
||||
this.modelHero.moduleHero.Errorf("find hero error: %v", err)
|
||||
}
|
||||
hero = append(hero, _hero)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
} else { // 不是跨服就查本服 注意 这个接口是给跨服玩法调用 理论上这个分支是不会执行的
|
||||
for _, v := range oid {
|
||||
if res := this.modelHero.DB.FindOne(comm.TableHero, bson.M{
|
||||
"_id": v,
|
||||
}); res == nil {
|
||||
_hero := &pb.DBHero{}
|
||||
if err = res.Decode(hero); err != nil {
|
||||
this.modelHero.moduleHero.Errorf("find hero error: %v", err)
|
||||
return
|
||||
}
|
||||
hero = append(hero, _hero)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user