Commit bd2f6a3d authored by honghy's avatar honghy

校验是否可以发送验证码,不用筛选场景

parent 29f287d6
......@@ -57,17 +57,17 @@ public class SmsCodeServiceImpl implements SmsCodeService {
private String createSmsCode(String mobile, String nodeValue, String ip) {
// 校验是否可以发送验证码,不用筛选场景
SmsCodeDO lastSmsCode = smsCodeMapper.selectLastByMobile(mobile, null, null);
// if (lastSmsCode != null) {
// if (lastSmsCode.getTodayIndex() >= smsCodeProperties.getSendMaximumQuantityPerDay()) { // 超过当天发送的上限。
// throw ServiceExceptionUtil.exception(SMS_CODE_EXCEED_SEND_MAXIMUM_QUANTITY_PER_DAY);
// }
// if (System.currentTimeMillis() - lastSmsCode.getCreateTime().getTime()
// < smsCodeProperties.getSendFrequency().toMillis()) { // 发送过于频繁
// throw ServiceExceptionUtil.exception(SMS_CODE_SEND_TOO_FAST);
// }
// // TODO 芋艿:提升,每个 IP 每天可发送数量
// // TODO 芋艿:提升,每个 IP 每小时可发送数量
// }
if (lastSmsCode != null) {
if (lastSmsCode.getTodayIndex() >= smsCodeProperties.getSendMaximumQuantityPerDay()) { // 超过当天发送的上限。
throw ServiceExceptionUtil.exception(SMS_CODE_EXCEED_SEND_MAXIMUM_QUANTITY_PER_DAY);
}
if (System.currentTimeMillis() - lastSmsCode.getCreateTime().getTime()
< smsCodeProperties.getSendFrequency().toMillis()) { // 发送过于频繁
throw ServiceExceptionUtil.exception(SMS_CODE_SEND_TOO_FAST);
}
// TODO 芋艿:提升,每个 IP 每天可发送数量
// TODO 芋艿:提升,每个 IP 每小时可发送数量
}
// 创建验证码记录
String code = String.valueOf(randomInt(smsCodeProperties.getBeginCode(), smsCodeProperties.getEndCode() + 1));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment