瀏覽代碼

bug修复

hecheng 3 年之前
父節點
當前提交
b2c8a3b74f

+ 1 - 2
zd-auth/src/main/java/com/zd/auth/controller/TokenController.java

@@ -197,8 +197,7 @@ public class TokenController {
                 redisTemplate.opsForValue().set(countKey,i+"",60,TimeUnit.MINUTES);
             }
         }
-        return R.ok(code);
-//        return stockService.sendSydSms(code, 2, null, form.getUsername());
+        return stockService.sendSydSms(code, 2, null, form.getUsername());
     }
 
     /**

+ 14 - 0
zd-modules/zd-modules-system/src/main/java/com/zd/system/controller/SysUserController.java

@@ -732,6 +732,20 @@ public class SysUserController extends BaseController {
         String code = RandomUtil.randomNumbers(6);
         redisTemplate.opsForValue().set(key, code, CODE_EXPIRATION, TimeUnit.MINUTES);
         logger.info("========================>{}<=========================", code);
+        String countKey=Constants.DEFAULT_CODE_KEY + "@" + phone+"_COUNT";
+        String count = redisTemplate.opsForValue().get(countKey);
+        if (StringUtils.isEmpty(count)){
+            redisTemplate.opsForValue().set(countKey,"1",60,TimeUnit.MINUTES);
+        }else {
+            if (count!=null){
+                int i=Integer.parseInt(count);
+                if (i>=5){
+                    throw new ServiceException("验证码发送超过限制,请一小时后再试",530);
+                }
+                i++;
+                redisTemplate.opsForValue().set(countKey,i+"",60,TimeUnit.MINUTES);
+            }
+        }
         return stockService.sendSydSms(code, 2, null, phone);
     }