|
@@ -3,6 +3,7 @@ package com.diagbot.facade;
|
|
|
import com.diagbot.dto.ImgVerCreatDTO;
|
|
|
import com.diagbot.entity.ImgVerInfo;
|
|
|
import com.diagbot.entity.SwsVerInfo;
|
|
|
+import com.diagbot.entity.User;
|
|
|
import com.diagbot.enums.VisibleIdTypeEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
@@ -86,30 +87,29 @@ public class VerFacade {
|
|
|
}
|
|
|
if (!RegexValidateUtil.checkMobileNumber(smsVerCreatVO.getMobile())){
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_ERROR,
|
|
|
- "用户电话格式错误!");
|
|
|
+ "请输入正确的手机号!");
|
|
|
}
|
|
|
//验证图片验证码
|
|
|
ImgVerInfo imgVerInfo = new ImgVerInfo();
|
|
|
BeanUtil.copyProperties(smsVerCreatVO, imgVerInfo);
|
|
|
Boolean imgVerRes = imgVerService.verifyImgVerification(imgVerInfo);
|
|
|
if (imgVerRes){
|
|
|
- //todo 验证该用户是否被注册
|
|
|
- Boolean isReg = false;
|
|
|
- if (isReg){
|
|
|
+ User bean = userFacade.getUserInfo(smsVerCreatVO.getMobile());
|
|
|
+ if (bean != null){
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "该号码已经被注册!");
|
|
|
}
|
|
|
|
|
|
- //验证是否超过两分钟
|
|
|
+ //验证是否超过三分钟
|
|
|
SwsVerInfo swsVerInfoCheck = smsVerService.getSmsVerification(smsVerCreatVO.getMobile());
|
|
|
if (null != swsVerInfoCheck){
|
|
|
- if (DateUtil.after(DateUtil.addMinutes(swsVerInfoCheck.getCreateTime(), 2),
|
|
|
+ if (DateUtil.after(DateUtil.addMinutes(swsVerInfoCheck.getCreateTime(), 3),
|
|
|
DateUtil.now())){
|
|
|
throw new CommonException(ServiceErrorCode.SMS_SEND_ERROR,
|
|
|
- "同一用户两分钟之内不能重复发送验证短信,请两分钟之后再次发送!");
|
|
|
+ "同一用户三分钟之内不能重复发送验证短信,请三分钟之后再次发送!");
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "图片验证码错误!");
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "输入图形验证码有误!");
|
|
|
}
|
|
|
|
|
|
//发送短信
|
|
@@ -124,7 +124,7 @@ public class VerFacade {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 验证短信码并且注册为新的用户
|
|
|
+ * 验证短信码
|
|
|
* @param smsVerVerVO 短信验证码验证输入信息
|
|
|
* @return 用户信息是否注册到数据库
|
|
|
*/
|
|
@@ -152,20 +152,19 @@ public class VerFacade {
|
|
|
}
|
|
|
if (!RegexValidateUtil.checkMobileNumber(smsVerVerVO.getMobile())){
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_ERROR,
|
|
|
- "用户电话格式错误!");
|
|
|
+ "请输入正确的手机号!");
|
|
|
}
|
|
|
//验证图片验证码
|
|
|
ImgVerInfo imgVerInfo = new ImgVerInfo();
|
|
|
BeanUtil.copyProperties(smsVerVerVO, imgVerInfo);
|
|
|
Boolean imgVerRes = imgVerService.verifyImgVerification(imgVerInfo);
|
|
|
if (imgVerRes){
|
|
|
- //todo 验证该用户是否被注册
|
|
|
- Boolean isReg = false;
|
|
|
- if (isReg){
|
|
|
+ User bean = userFacade.getUserInfo(smsVerVerVO.getMobile());
|
|
|
+ if (bean != null){
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "该号码已经被注册!");
|
|
|
}
|
|
|
} else {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "图片验证码错误!");
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "输入图形验证码有误!");
|
|
|
}
|
|
|
//验证用户短信信息
|
|
|
SwsVerInfo swsVerInfo = new SwsVerInfo();
|
|
@@ -173,11 +172,9 @@ public class VerFacade {
|
|
|
swsVerInfo.setCode(smsVerVerVO.getSmsCode());
|
|
|
Boolean smsVer = smsVerService.verifySmsVerification(swsVerInfo);
|
|
|
if (!smsVer){
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "短信验证未通过!");
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "短信验证码输入有误,请重新输入!");
|
|
|
}
|
|
|
- //todo 将用户信息加入数据库
|
|
|
- Boolean registSuccess = true;
|
|
|
- return registSuccess;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
|