查询接口调整
This commit is contained in:
parent
232a0fc1e5
commit
c247137d7e
@ -344,15 +344,17 @@ func (this *Hero) CreateMonster(heroCid string, star, lv int32) (hero *pb.DBHero
|
||||
|
||||
// 只通过唯一id 查询英雄信息
|
||||
func (this *Hero) QueryCrossHeroinfo(oid string) (hero *pb.DBHero, err error) {
|
||||
|
||||
if this.modelHero.moduleHero.IsCross() {
|
||||
for _, tag := range db.GetServerTags() {
|
||||
conn, err1 := db.ServerDBConn(tag) // 遍历连接对象
|
||||
if err1 != nil {
|
||||
continue
|
||||
}
|
||||
filter := bson.M{
|
||||
|
||||
sr := conn.Mgo.FindOne(comm.TableHero, bson.M{
|
||||
"_id": oid,
|
||||
}
|
||||
sr := conn.Mgo.FindOne(comm.TableHero, filter)
|
||||
})
|
||||
hero = &pb.DBHero{}
|
||||
if err = sr.Decode(hero); err != nil {
|
||||
if err != mongo.ErrNoDocuments {
|
||||
@ -360,6 +362,18 @@ func (this *Hero) QueryCrossHeroinfo(oid string) (hero *pb.DBHero, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // 不是跨服就查本服
|
||||
if res := this.modelHero.DB.FindOne(comm.TableHero, bson.M{
|
||||
"_id": oid,
|
||||
}); res == nil {
|
||||
hero = &pb.DBHero{}
|
||||
if err = res.Decode(hero); err != nil {
|
||||
if err != mongo.ErrNoDocuments {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user