@PostMapping("/sendMsg")
public R msg(@RequestBody User user, HttpSession session) {
String phone = user.getPhone();//获取手机号属性
if (StringUtils.isNotEmpty(phone)) {
//获取长度为4的随机数字验证码
String code = ValidateCodeUtils.generateValidateCode(4).toString();
log.info("验证码: {}", code);//打印验证码在控制台
session.setAttribute(phone, code);//记住登录状态
}
return R.error("手机号有误");
}
随机生成四位数验证码
最新推荐文章于 2024-07-11 12:41:54 发布
2803

被折叠的 条评论
为什么被折叠?



