|
@@ -229,7 +229,7 @@ func (this *UserController) GetVerifyCode() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- phoneCountKey := utils.CACHE_ACCESS_PHONE_COUNT_LOGIN_CODE + req.Email
|
|
|
+ phoneCountKey := utils.CACHE_ACCESS_PHONE_COUNT_LOGIN_CODE + req.AreaCode + req.Phone
|
|
|
resCount, _ := go_redis.RedisInt(phoneCountKey)
|
|
|
if resCount > utils.VerifyCodeSendLimit {
|
|
|
br.Msg = fmt.Sprintf("一天最多获取%s次,已超限", strconv.Itoa(utils.VerifyCodeSendLimit))
|
|
@@ -263,19 +263,14 @@ func (this *UserController) GetVerifyCode() {
|
|
|
return
|
|
|
}
|
|
|
br.Msg = "发送成功"
|
|
|
- isExist := go_redis.IsExist(phoneKey)
|
|
|
- if isExist {
|
|
|
- go_redis.Incr(phoneKey)
|
|
|
- go_redis.Incr(phoneCountKey)
|
|
|
- } else {
|
|
|
- go_redis.SetNX(phoneKey, 1, time.Minute*15)
|
|
|
- go_redis.SetNX(phoneCountKey, 1, utils.SetKeyExpireToday())
|
|
|
+ phoneVerifyCahcheSvc := &services.VerifyCacheIncrService{}
|
|
|
+ err = phoneVerifyCahcheSvc.VerifyCacheIncr(phoneKey, 15*int(time.Minute.Seconds()))
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Info("验证码手机号临时缓存失败", err.Error())
|
|
|
}
|
|
|
- isExist = go_redis.IsExist(phoneCountKey)
|
|
|
- if isExist {
|
|
|
- go_redis.Incr(phoneCountKey)
|
|
|
- } else {
|
|
|
- go_redis.SetNX(phoneCountKey, 1, utils.SetKeyExpireToday())
|
|
|
+ err = phoneVerifyCahcheSvc.VerifyCacheIncr(phoneCountKey, int(utils.SetKeyExpireToday().Seconds()))
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Info("验证码手机号当日缓存失败", err.Error())
|
|
|
}
|
|
|
}
|
|
|
case 2:
|
|
@@ -330,17 +325,14 @@ func (this *UserController) GetVerifyCode() {
|
|
|
return
|
|
|
}
|
|
|
br.Msg = "发送成功"
|
|
|
- isExist := go_redis.IsExist(emailKey)
|
|
|
- if isExist {
|
|
|
- go_redis.Incr(emailKey)
|
|
|
- } else {
|
|
|
- go_redis.SetNX(emailKey, 1, time.Minute*15)
|
|
|
+ emailVerifyCahcheSvc := &services.VerifyCacheIncrService{}
|
|
|
+ err = emailVerifyCahcheSvc.VerifyCacheIncr(emailKey, 15*int(time.Minute.Seconds()))
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Info("验证码邮箱临时缓存失败, err:", err.Error())
|
|
|
}
|
|
|
- isExist = go_redis.IsExist(emailCountKey)
|
|
|
- if isExist {
|
|
|
- go_redis.Incr(emailCountKey)
|
|
|
- } else {
|
|
|
- go_redis.SetNX(emailCountKey, 1, utils.SetKeyExpireToday())
|
|
|
+ err = emailVerifyCahcheSvc.VerifyCacheIncr(emailCountKey, int(utils.SetKeyExpireToday().Seconds()))
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Info("验证码邮箱当日缓存失败, err:", err.Error())
|
|
|
}
|
|
|
} else {
|
|
|
br.Msg = "发送失败"
|