From 79fb4b27ebbd883f509d3117ccf580562ccb17c1 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 16 Mar 2023 13:52:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9F=A5=E8=AF=A2=E8=8B=B1?= =?UTF-8?q?=E9=9B=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 3 +++ modules/hero/module.go | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/comm/imodule.go b/comm/imodule.go index b265b84cf..7690aeb58 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -100,6 +100,9 @@ type ( // 教习登记 RegisterInstructor(session IUserSession, heroOid []string, registerId int32) (code pb.ErrorCode) + + // 跨服查询英雄详细信息 + QueryCrossMultipleHeroinfo(oid []string) (hero []*pb.DBHero, err error) } //玩家 diff --git a/modules/hero/module.go b/modules/hero/module.go index cc8970b54..a0ccb82ca 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -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 +}