From 7fd96b335af7f9ca0fa3738cb525773a552ebfa1 Mon Sep 17 00:00:00 2001 From: genxium Date: Sun, 26 Feb 2023 23:33:47 +0800 Subject: [PATCH] Minor fix. --- battle_srv/api/v1/player.go | 2 +- battle_srv/models/player.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/battle_srv/api/v1/player.go b/battle_srv/api/v1/player.go index 85e2dca..22824a6 100644 --- a/battle_srv/api/v1/player.go +++ b/battle_srv/api/v1/player.go @@ -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)) } } diff --git a/battle_srv/models/player.go b/battle_srv/models/player.go index f4f92e2..9b01062 100644 --- a/battle_srv/models/player.go +++ b/battle_srv/models/player.go @@ -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 {