异常处理

This commit is contained in:
meixiongfeng 2024-01-19 22:54:54 +08:00
parent 0960ffa71d
commit 8ad0d55dcb

View File

@ -50,16 +50,16 @@ func (this *apiComp) GetAssistHero(session comm.IUserSession, req *pb.FriendGetA
leftCount = int32(comm.AssistHeroCount - len(list.Data)) leftCount = int32(comm.AssistHeroCount - len(list.Data))
// localNum, _ := this.module.modelFriend.DB.CountDocuments(core.SqlTable(this.module.modelFriend.TableName), bson.M{}) // localNum, _ := this.module.modelFriend.DB.CountDocuments(core.SqlTable(this.module.modelFriend.TableName), bson.M{})
// randomIndex := comm.GetRandNum(0, int32(localNum)) // randomIndex := comm.GetRandNum(0, int32(localNum))
cur, err := this.module.modelFriend.DB.Find(core.SqlTable(this.module.modelFriend.TableName), bson.M{"assistHeroId": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(0)).SetLimit(int64(leftCount))) //.skip(1).limit(1) // cur, err := this.module.modelFriend.DB.Find(core.SqlTable(this.module.modelFriend.TableName), bson.M{"assistHeroId": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(0)).SetLimit(int64(leftCount))) //.skip(1).limit(1)
for cur.Next(context.TODO()) { // for cur.Next(context.TODO()) {
tmp := &pb.DBFriend{} // tmp := &pb.DBFriend{}
if err = cur.Decode(tmp); err == nil { // if err = cur.Decode(tmp); err == nil {
if session.GetUserId() != tmp.Uid { // if session.GetUserId() != tmp.Uid {
list.Data[tmp.Uid] = tmp.Info.Name // list.Data[tmp.Uid] = tmp.Info.Name
heros = append(heros, tmp.Hero) // heros = append(heros, tmp.Hero)
} // }
} // }
} // }
err = this.module.modelAssist.Add(session.GetUserId(), list) err = this.module.modelAssist.Add(session.GetUserId(), list)
session.SendMsg(string(this.module.GetType()), "getassisthero", &pb.FriendGetAssistHeroResp{ session.SendMsg(string(this.module.GetType()), "getassisthero", &pb.FriendGetAssistHeroResp{