Minor fix.

This commit is contained in:
genxium 2023-02-26 23:33:47 +08:00
parent 8cd5f1d475
commit 7fd96b335a
2 changed files with 10 additions and 4 deletions

View File

@ -89,10 +89,10 @@ func (p *playerController) SMSCaptchaGet(c *gin.Context) {
var succRet int
if Conf.General.ServerEnv == SERVER_ENV_TEST {
player, err := models.GetPlayerByName(req.Num)
Logger.Info("A new SmsCaptcha record is needed for: ", zap.String("key", redisKey), zap.Any("player", player))
if nil == err && nil != player {
pass = true
succRet = Constants.RetCode.IsTestAcc
Logger.Info("A new SmsCaptcha record is needed for: ", zap.String("key", redisKey), zap.Any("player", player))
}
}

View File

@ -77,13 +77,14 @@ func getPlayer(cond sq.Eq) (*Player, error) {
return nil, err
}
rows, err := storage.MySQLManagerIns.Queryx(query, args...)
if err != nil {
if nil != err {
return nil, err
}
cols, err := rows.Columns()
if nil != err {
panic(err)
}
cnt := 0
for rows.Next() {
// TODO: Do it more elegantly, but by now I don't have time to learn reflection of Golang
vals := rowValues(rows, cols)
@ -105,9 +106,14 @@ func getPlayer(cond sq.Eq) (*Player, error) {
}
}
Logger.Debug("Queried player from db", zap.Any("cond", cond), zap.Any("p", p), zap.Any("pd", pd), zap.Any("cols", cols), zap.Any("rowValues", vals))
cnt++
}
if 0 < cnt {
p.PlayerDownsync = pd
return &p, nil
} else {
return nil, nil
}
p.PlayerDownsync = pd
return &p, nil
}
func (p *Player) Insert(tx *sqlx.Tx) error {