查看装备空值校验

This commit is contained in:
meixiongfeng 2022-11-17 19:58:35 +08:00
parent 4695503e2e
commit 0ad64739dd
2 changed files with 20 additions and 21 deletions

View File

@ -28,9 +28,7 @@ func (this *apiComp) WatchHero(session comm.IUserSession, req *pb.ForumWatchHero
if hero, err = this.module.modelForum.watchHero(req.Stag, req.Uid, req.HerocId); err != nil {
code = pb.ErrorCode_HeroNoExist
}
if equip, err = this.module.modelForum.watchHeroEquip(req.Stag, req.Uid, hero.EquipID...); err != nil {
code = pb.ErrorCode_EquipmentOnFoundEquipment
}
equip = this.module.modelForum.watchHeroEquip(req.Stag, req.Uid, hero.EquipID...)
session.SendMsg(string(this.module.GetType()), "watchhero", &pb.ForumWatchHeroResp{
Hero: hero,
EquipID: equip,

View File

@ -156,16 +156,15 @@ func (this *modelForumComp) watchHero(stage string, uid string, herocid string)
return
}
func (this *modelForumComp) watchHeroEquip(stage string, uid string, equipIds ...string) (equips []*pb.DB_Equipment, err error) {
func (this *modelForumComp) watchHeroEquip(stage string, uid string, equipIds ...string) (equips []*pb.DB_Equipment) {
var (
tcoon *db.DBConn
)
if tcoon, err = db.ServerDBConn(stage); err != nil {
this.module.Errorf("stage:%s err:%v", stage, err)
return
if tcoon, err := db.ServerDBConn(stage); err == nil {
for _, id := range equipIds {
if id == "" {
equips = append(equips, nil)
continue
}
for id := range equipIds {
sr := tcoon.Mgo.FindOne(comm.TableEquipment, bson.M{
"_id": id,
})
@ -176,6 +175,8 @@ func (this *modelForumComp) watchHeroEquip(stage string, uid string, equipIds ..
this.module.Errorf("find hero equip error: %v", err)
}
}
} else {
this.module.Errorf("stage:%s err:%v", stage, err)
}
return
}