|
@@ -28,6 +28,8 @@ import org.springframework.stereotype.Component;
|
|
|
*/
|
|
|
@Component
|
|
|
public class VerFacade {
|
|
|
+
|
|
|
+ public final static int SMS_MINS = 3000; //短信验证码间隔为3分钟 //TODO 时间间隔先调大了,之后改为3
|
|
|
@Autowired
|
|
|
private ImgVerService imgVerService;
|
|
|
@Autowired
|
|
@@ -69,10 +71,6 @@ public class VerFacade {
|
|
|
*/
|
|
|
public Boolean getSmsVerification(SmsVerCreatVO smsVerCreatVO){
|
|
|
//参数验证
|
|
|
- if (null == smsVerCreatVO){
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "短信验证码创建信息不能为空!");
|
|
|
- }
|
|
|
if (StringUtil.isBlank(smsVerCreatVO.getImgId())){
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
"图片验证码唯一标志不能为空!");
|
|
@@ -102,7 +100,7 @@ public class VerFacade {
|
|
|
//验证是否超过三分钟
|
|
|
SwsVerInfo swsVerInfoCheck = smsVerService.getSmsVerification(smsVerCreatVO.getMobile());
|
|
|
if (null != swsVerInfoCheck){
|
|
|
- if (DateUtil.after(DateUtil.addMinutes(swsVerInfoCheck.getCreateTime(), 3),
|
|
|
+ if (DateUtil.after(DateUtil.addMinutes(swsVerInfoCheck.getCreateTime(), VerFacade.SMS_MINS),
|
|
|
DateUtil.now())){
|
|
|
throw new CommonException(ServiceErrorCode.SMS_SEND_ERROR,
|
|
|
"同一用户三分钟之内不能重复发送验证短信,请三分钟之后再次发送!");
|
|
@@ -132,9 +130,13 @@ public class VerFacade {
|
|
|
*/
|
|
|
public Boolean getSmsWithResetPassword(SmsVerCreatVO smsVerCreatVO){
|
|
|
//参数验证
|
|
|
- if (null == smsVerCreatVO){
|
|
|
+ if (StringUtil.isBlank(smsVerCreatVO.getImgId())){
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "短信验证码创建信息不能为空!");
|
|
|
+ "图片验证码唯一标志不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtil.isBlank(smsVerCreatVO.getCode())){
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
+ "图片验证码不能为空!");
|
|
|
}
|
|
|
if (StringUtil.isBlank(smsVerCreatVO.getMobile())){
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
@@ -152,7 +154,7 @@ public class VerFacade {
|
|
|
//验证是否超过三分钟
|
|
|
SwsVerInfo swsVerInfoCheck = smsVerService.getSmsVerification(smsVerCreatVO.getMobile());
|
|
|
if (null != swsVerInfoCheck){
|
|
|
- if (DateUtil.after(DateUtil.addMinutes(swsVerInfoCheck.getCreateTime(), 3),
|
|
|
+ if (DateUtil.after(DateUtil.addMinutes(swsVerInfoCheck.getCreateTime(), 3000), //TODO 方便测试先加大时间间隔
|
|
|
DateUtil.now())){
|
|
|
throw new CommonException(ServiceErrorCode.SMS_SEND_ERROR,
|
|
|
"同一用户三分钟之内不能重复发送验证短信,请三分钟之后再次发送!");
|
|
@@ -170,10 +172,11 @@ public class VerFacade {
|
|
|
return smsVerService.createSmsVerification(swsVerInfo);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 验证短信码
|
|
|
* @param smsVerVerVO 短信验证码验证输入信息
|
|
|
- * @return 用户信息是否注册到数据库
|
|
|
+ * @return 校验短信验证码是否通过
|
|
|
*/
|
|
|
public Boolean verifySmsVerification(SmsVerVerVO smsVerVerVO){
|
|
|
//参数验证
|
|
@@ -181,14 +184,14 @@ public class VerFacade {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
"短信验证码验证输入信息不能为空!");
|
|
|
}
|
|
|
- if (StringUtil.isBlank(smsVerVerVO.getImgId())){
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "图片验证码唯一标志不能为空!");
|
|
|
- }
|
|
|
- if (StringUtil.isBlank(smsVerVerVO.getCode())){
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "图片验证码不能为空!");
|
|
|
- }
|
|
|
+// if (StringUtil.isBlank(smsVerVerVO.getImgId())){
|
|
|
+// throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
+// "图片验证码唯一标志不能为空!");
|
|
|
+// }
|
|
|
+// if (StringUtil.isBlank(smsVerVerVO.getCode())){
|
|
|
+// throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
+// "图片验证码不能为空!");
|
|
|
+// }
|
|
|
if (StringUtil.isBlank(smsVerVerVO.getMobile())){
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
"用户电话不能为空!");
|
|
@@ -202,17 +205,17 @@ public class VerFacade {
|
|
|
"请输入正确的手机号!");
|
|
|
}
|
|
|
//验证图片验证码
|
|
|
- ImgVerInfo imgVerInfo = new ImgVerInfo();
|
|
|
- BeanUtil.copyProperties(smsVerVerVO, imgVerInfo);
|
|
|
- Boolean imgVerRes = imgVerService.verifyImgVerification(imgVerInfo);
|
|
|
- if (imgVerRes){
|
|
|
- User bean = userFacade.getUserInfo(smsVerVerVO.getMobile());
|
|
|
- if (bean != null){
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "该号码已经被注册!");
|
|
|
- }
|
|
|
- } else {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "输入图形验证码有误!");
|
|
|
- }
|
|
|
+// ImgVerInfo imgVerInfo = new ImgVerInfo();
|
|
|
+// BeanUtil.copyProperties(smsVerVerVO, imgVerInfo);
|
|
|
+// Boolean imgVerRes = imgVerService.verifyImgVerification(imgVerInfo);
|
|
|
+// if (imgVerRes){
|
|
|
+// User bean = userFacade.getUserInfo(smsVerVerVO.getMobile());
|
|
|
+// if (bean != null){
|
|
|
+// throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "该号码已经被注册!");
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "输入图形验证码有误!");
|
|
|
+// }
|
|
|
//验证用户短信信息
|
|
|
SwsVerInfo swsVerInfo = new SwsVerInfo();
|
|
|
swsVerInfo.setMobile(smsVerVerVO.getMobile());
|
|
@@ -224,5 +227,4 @@ public class VerFacade {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|