验证码限制次数

This commit is contained in:
张松 2025-03-10 13:48:44 +08:00
parent 6773c10fa5
commit 0622e86cbf
2 changed files with 7 additions and 1 deletions

View File

@ -32,8 +32,13 @@ public class CommonServiceImpl implements CommonService {
if (StrUtil.isBlank(sysUser.getPhone())) {
throw new ApiNotPrintException("账号未绑定手机号");
}
String key = RedisCst.SMS_CODE + sysUser.getPhone() + ":" + type;
Object val = redisService.get(key);
if (val != null) {
throw new ApiNotPrintException("请勿频繁获取");
}
int code = RandomUtil.randomInt(100000, 1000000);
redisService.set(RedisCst.SMS_CODE + sysUser.getPhone() + ":" + type, code, 300);
redisService.set(key, code, 300);
smsService.sendCode(sysUser.getPhone(), String.valueOf(code));
return true;
}

View File

@ -159,6 +159,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
}
shopInfo.setOperationPwd(SecureUtil.md5(shopInfoEditDTO.getOperationPwd()));
redisService.del(key);
}
return updateById(shopInfo);
}