Commit 8d5db633 authored by 技术部-任文超's avatar 技术部-任文超

添加文案:1分钟内不能重复获取验证码

parent 76d966df
......@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.TimeUnit;
......@@ -224,6 +225,14 @@ public class SmsController implements IBaseController {
return JsonResult.buildErrorStateResult("手机号格式有误", null);
}
String verificationPhoneCountKey = Constants.REDIS_SMS_CODE_COUNT + phoneNo;
String expireMillionsesscondString = redisTemplate.opsForValue().get(verificationPhoneCountKey);
if(StringUtils.isNotBlank(expireMillionsesscondString)){
long expireMillionsesscond = Long.parseLong(expireMillionsesscondString);
Long now = System.currentTimeMillis();
if ((now + (Constants.ONE_DAY - 60) * 1000) > expireMillionsesscond) {
return JsonResult.buildErrorStateResult("1分钟内不能重复获取验证码", null);
}
}
Long getPhoneVerificationCount = redisTemplate.opsForHash().increment(verificationPhoneCountKey, Constants.REDIS_SMS_CODE_COUNT, 1);
redisTemplate.expire(verificationPhoneCountKey, Constants.ONE_DAY,TimeUnit.SECONDS);
......
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