diff --git a/api/controller/Login.go b/api/controller/Login.go index 7f5c836..60f7d77 100644 --- a/api/controller/Login.go +++ b/api/controller/Login.go @@ -50,7 +50,7 @@ func (r *Login) Login(c *gin.Context) { return } - code, _ := global.Redis.Get(c, "login_code_count_"+req.Mobile).Result() + code, _ := global.Redis.Get(c, "login_code_"+req.Mobile).Result() if code == "" { responses.FailWithMessage("验证码失效", c) return @@ -64,6 +64,7 @@ func (r *Login) Login(c *gin.Context) { } } + return // 开始事务 tx := global.Db.Begin() defer func() { diff --git a/api/service/Public.go b/api/service/Public.go index ceb6118..1344f4e 100644 --- a/api/service/Public.go +++ b/api/service/Public.go @@ -18,7 +18,7 @@ type PublicService struct { // GetPhoneCode 获取手机验证码 func (r *PublicService) GetPhoneCode(scene int, phone string) (bool, error) { - var sendCodeCount int // // 获取验证码最大次数 + sendCodeCount := 1 // // 获取验证码最大次数 var code string // 验证码 var templateCode string // 短信模版 @@ -62,7 +62,7 @@ func (r *PublicService) GetPhoneCode(scene int, phone string) (bool, error) { // 记录发送次数 if sendCodeCount != 0 { - _, err = global.Redis.Set(context.Background(), "login_code_count_"+phone, time.Now().Unix(), 60*5*time.Second).Result() + _, err = global.Redis.Set(context.Background(), "login_code_count_"+phone, sendCodeCount, 60*5*time.Second).Result() if err != nil { return false, errors.New("验证码发送失败,请您稍后再试") }