From c3d5d532cd3b7b6c68a10b3836f3d3937e5c4ce3 Mon Sep 17 00:00:00 2001 From: Echo <1711788888@qq.com> Date: Sun, 20 Jul 2025 02:11:19 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=20=E5=AE=8C=E5=96=84=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/user/user.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/service/user/user.go b/service/user/user.go index 4e3f59c..b9ac144 100644 --- a/service/user/user.go +++ b/service/user/user.go @@ -8,7 +8,6 @@ import ( common "git.echol.cn/loser/lckt/model/common/request" "git.echol.cn/loser/lckt/model/user" "git.echol.cn/loser/lckt/model/user/request" - "git.echol.cn/loser/lckt/utils/sms" "go.uber.org/zap" "golang.org/x/crypto/bcrypt" "math/rand" @@ -36,18 +35,19 @@ func (u *UserService) SendCode(req request.SendCodeReq) (err error) { result, err := rdb.Get(context.Background(), key).Result() if result != "" { global.GVA_LOG.Error("验证码发送过于频繁", zap.String("phone", req.Phone)) + err = fmt.Errorf("验证码发送过于频繁,请稍后再试") return } rand.New(rand.NewSource(time.Now().UnixNano())) verifyCode := fmt.Sprintf("%06v", rand.Int31n(1000000)) - if ok := sms.SendSMS(req.Phone, verifyCode); !ok { - global.GVA_LOG.Error("发送验证码失败") - return - } + //if ok := sms.SendSMS(req.Phone, verifyCode); !ok { + // global.GVA_LOG.Error("发送验证码失败") + // return + //} // - if err = rdb.Set(context.Background(), key, verifyCode, time.Duration(global.GVA_CONFIG.SMS.ExpireTime)*time.Second).Err(); err != nil { + if err = rdb.Set(context.Background(), key, verifyCode, 5*time.Minute).Err(); err != nil { global.GVA_LOG.Error("设置验证码缓存失败", zap.Error(err)) return }