批量查询英雄数据
This commit is contained in:
parent
aa8ed33406
commit
037cebe1ac
@ -141,7 +141,7 @@ type (
|
||||
RegisterInstructor(session IUserSession, heroOid []string, registerId int32) (errdata *pb.ErrorData)
|
||||
|
||||
// 跨服查询英雄详细信息
|
||||
QueryCrossMultipleHeroinfo(oid []string) (hero []*pb.DBHero, err error)
|
||||
QueryCrossMultipleHeroinfo(uid string, oid []string) (hero []*pb.DBHero, err error)
|
||||
|
||||
AddHeroFetterAttribute(session IUserSession, attr map[string][]*cfg.Gameatr)
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package hero
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
@ -693,44 +692,17 @@ func (this *Hero) RegisterInstructor(session comm.IUserSession, heroOid []string
|
||||
}
|
||||
|
||||
// 只通过唯一id 查询英雄信息
|
||||
func (this *Hero) QueryCrossMultipleHeroinfo(oid []string) (hero []*pb.DBHero, err error) {
|
||||
func (this *Hero) QueryCrossMultipleHeroinfo(uid string, oid []string) (hero []*pb.DBHero, err error) {
|
||||
if this.IsCross() {
|
||||
for _, tag := range db.GetServerTags() {
|
||||
conn, err1 := db.ServerDBConn(tag) // 遍历连接对象
|
||||
if err1 != nil {
|
||||
continue
|
||||
if tag, _, b := utils.UIdSplit(uid); b {
|
||||
if conn, err := db.ServerDBConn(tag); err == nil {
|
||||
dbModel := db.NewDBModel(tag, comm.TableMail, conn)
|
||||
err = dbModel.GetListObjs(uid, oid, &hero)
|
||||
}
|
||||
result := make([]bson.M, 0)
|
||||
|
||||
for _, v := range oid {
|
||||
result = append(result, bson.M{"_id": v})
|
||||
}
|
||||
sr, _ := conn.Mgo.Find(comm.TableHero, bson.M{"$or": result})
|
||||
for sr.Next(context.TODO()) {
|
||||
_hero := &pb.DBHero{}
|
||||
if err = sr.Decode(_hero); err != nil {
|
||||
this.modelHero.module.Errorf("find hero error: %v", err)
|
||||
}
|
||||
hero = append(hero, _hero)
|
||||
}
|
||||
return
|
||||
}
|
||||
} else { // 不是跨服就查本服 注意 这个接口是给跨服玩法调用 理论上这个分支是不会执行的
|
||||
|
||||
result := make([]bson.M, 0)
|
||||
for _, v := range oid {
|
||||
result = append(result, bson.M{"_id": v})
|
||||
}
|
||||
sr, _ := this.modelHero.DB.Find(comm.TableHero, bson.M{"$or": result})
|
||||
for sr.Next(context.TODO()) {
|
||||
_hero := &pb.DBHero{}
|
||||
if err = sr.Decode(_hero); err != nil {
|
||||
this.modelHero.module.Errorf("find hero error: %v", err)
|
||||
}
|
||||
hero = append(hero, _hero)
|
||||
}
|
||||
} else {
|
||||
hero, err = this.modelHero.getHeros(uid, oid)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ func (this *apiComp) Enrolled(session comm.IUserSession, req *pb.PracticeEnrolle
|
||||
}
|
||||
|
||||
} else {
|
||||
if hero, err = this.module.ModuleHero.QueryCrossMultipleHeroinfo(req.Hero); err != nil {
|
||||
if hero, err = this.module.ModuleHero.QueryCrossMultipleHeroinfo(session.GetUserId(), req.Hero); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
|
Loading…
Reference in New Issue
Block a user