发送验证码

// 发送验证码
@RequestMapping(value = "sendCode")
@ResponseBody
public Object sendCode(String phone) {
Random random = new Random();
String value = String.format("%s%s%s%s%s%s", random.nextInt(10), random.nextInt(10), random.nextInt(10),
random.nextInt(10), random.nextInt(10), random.nextInt(10));
if (JuheSmsUtil.getRequest2(phone,"48733",value)) {
//发送验证码成功以后 要把验证码保存起来,登录的时候 校验验证码是否正确
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String firstTime=format.format(new Date());
logger.info("发送验证码:"+firstTime);
String stampValue[]=new String[2];
stampValue[0]=value;
stampValue[1]=firstTime;
map.put(phone,stampValue);
return JsonUtil.successMessage("发送成功");
} else {
return JsonUtil.failMessage("发送失败");
}
}
posted @ 2018-01-29 10:00  Birdgeduan  阅读(280)  评论(0编辑  收藏  举报