接口部分
/**
* 发送验证码
* @param request
* @param response
* @param loginName 手机号
* @param type 类型
* @return
* @throws Exception
*/
@RequestMapping(value = "sendmessage")
public JsonResult sendmessage(HttpServletRequest request, HttpServletResponse response, String loginName,String type) throws Exception {
//手机号存在则直接返回
SingleInstance singleInstance = SingleInstance.getInstance();
User userExist = this.userService.loginByloginName(loginName);
//检查是否已经注册过了
if(userExist!=null&&type.equals("register")){
throw new MyException(ResultCode.ERROR_USER_ADDFALIE);
}
int one = (int) Math.floor(Math.random()*10);
int two = (int) Math.floor(Math.random()*10);
int three = (int) Math.floor(Math.random()*10);
int four = (int) Math.floor(Math.random()*10);
//随机生成的4位安全码
String securityCode = one+""+two+""+three+""+four;
//手机号+类型做为key
String key = loginName+"_"+type;
//短信发送验证码
singleInstance.concurrentHashMap.put(key,securityCode);
JavaSmsApi.tplSendSms(JavaSmsApi.apikey,JavaSmsApi.tpl_id,securityCode,loginName);
return new JsonResult(ResultCode.SUCCESS);
} /**
* 发送验证码
* @param reque