查看装备空值校验
This commit is contained in:
parent
4695503e2e
commit
0ad64739dd
@ -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 {
|
if hero, err = this.module.modelForum.watchHero(req.Stag, req.Uid, req.HerocId); err != nil {
|
||||||
code = pb.ErrorCode_HeroNoExist
|
code = pb.ErrorCode_HeroNoExist
|
||||||
}
|
}
|
||||||
if equip, err = this.module.modelForum.watchHeroEquip(req.Stag, req.Uid, hero.EquipID...); err != nil {
|
equip = this.module.modelForum.watchHeroEquip(req.Stag, req.Uid, hero.EquipID...)
|
||||||
code = pb.ErrorCode_EquipmentOnFoundEquipment
|
|
||||||
}
|
|
||||||
session.SendMsg(string(this.module.GetType()), "watchhero", &pb.ForumWatchHeroResp{
|
session.SendMsg(string(this.module.GetType()), "watchhero", &pb.ForumWatchHeroResp{
|
||||||
Hero: hero,
|
Hero: hero,
|
||||||
EquipID: equip,
|
EquipID: equip,
|
||||||
|
@ -156,16 +156,15 @@ func (this *modelForumComp) watchHero(stage string, uid string, herocid string)
|
|||||||
return
|
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 (
|
if tcoon, err := db.ServerDBConn(stage); err == nil {
|
||||||
tcoon *db.DBConn
|
for _, id := range equipIds {
|
||||||
)
|
|
||||||
if tcoon, err = db.ServerDBConn(stage); err != nil {
|
if id == "" {
|
||||||
this.module.Errorf("stage:%s err:%v", stage, err)
|
equips = append(equips, nil)
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
for id := range equipIds {
|
|
||||||
sr := tcoon.Mgo.FindOne(comm.TableEquipment, bson.M{
|
sr := tcoon.Mgo.FindOne(comm.TableEquipment, bson.M{
|
||||||
"_id": id,
|
"_id": id,
|
||||||
})
|
})
|
||||||
@ -176,6 +175,8 @@ func (this *modelForumComp) watchHeroEquip(stage string, uid string, equipIds ..
|
|||||||
this.module.Errorf("find hero equip error: %v", err)
|
this.module.Errorf("find hero equip error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.module.Errorf("stage:%s err:%v", stage, err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user