3/21 提前存验证码1.0

dev_ksck_axxyy
wangwei 2 weeks ago
parent f4e323c230
commit 85a71fbb88

@ -112,8 +112,17 @@ public class RegisterController {
}
}
RestTemplate restTemplate = new RestTemplate();
int mobile_code = (int) ((Math.random() * 9 + 1) * 100000);
JSONObject json = new JSONObject();
json.put("memPhone", checkCodeRequest.getPhoneNum());
json.put("code", mobile_code);
json.put("createTime", System.currentTimeMillis() + "");
// 先将验证码存入 redis 中
redisUtil.set(Constant.CAPTCHAS + checkCodeRequest.getPhoneNum(), json, 300L);
RestTemplate restTemplate = new RestTemplate();
MultiValueMap<String, Object> postParameters = new LinkedMultiValueMap<>();
int time = 5;
String content = new String("您正在进行手机验证,验证码是" + mobile_code + "" + time + "分钟内有效。");
@ -126,17 +135,11 @@ public class RegisterController {
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(postParameters, headers);
String response = restTemplate.postForObject(Url, httpEntity, String.class);
if (response.contains("提交成功")) {
JSONObject json = new JSONObject();
json.put("memPhone", checkCodeRequest.getPhoneNum());
json.put("code", mobile_code);
json.put("createTime", System.currentTimeMillis() + "");
//验证码存入redis中
redisUtil.set(Constant.CAPTCHAS + checkCodeRequest.getPhoneNum(), json, 300L);
return ResultVOUtils.success("发送成功!");
} else {
// 如果短信发送失败,可考虑删除 Redis 中的验证码,这里简单返回错误信息
return ResultVOUtils.error(500, "验证码发送失败");
}
}
@GetMapping("salewarehouse/register/checkCompany")

Loading…
Cancel
Save