码迷,mamicode.com
首页 > 其他好文 > 详细

发送验证码

时间:2018-01-29 15:33:42      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:dom   else   return   format   amp   first   led   date   post   

// 发送验证码
@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("发送失败");
}
}

发送验证码

标签:dom   else   return   format   amp   first   led   date   post   

原文地址:https://www.cnblogs.com/duanqiao123/p/8375998.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!