|
@@ -3,10 +3,10 @@ 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;
|
|
|
-import com.diagbot.exception.ErrorCode;
|
|
|
+import com.diagbot.exception.ServiceErrorCode;
|
|
|
import com.diagbot.idc.VisibleIdCreater;
|
|
|
import com.diagbot.service.ImgVerService;
|
|
|
import com.diagbot.service.SmsVerService;
|
|
@@ -19,7 +19,6 @@ import com.diagbot.vo.SmsVerCreatVO;
|
|
|
import com.diagbot.vo.SmsVerVerVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
-import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
/**
|
|
|
* @Description: 用户验证业务层
|
|
@@ -70,23 +69,23 @@ public class VerFacade {
|
|
|
public Boolean getSmsVerification(SmsVerCreatVO smsVerCreatVO){
|
|
|
//参数验证
|
|
|
if (null == smsVerCreatVO){
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_NULL,
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
"短信验证码创建信息不能为空!");
|
|
|
}
|
|
|
if (StringUtil.isBlank(smsVerCreatVO.getImgId())){
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_NULL,
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
"图片验证码唯一标志不能为空!");
|
|
|
}
|
|
|
if (StringUtil.isBlank(smsVerCreatVO.getCode())){
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_NULL,
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
"图片验证码不能为空!");
|
|
|
}
|
|
|
if (StringUtil.isBlank(smsVerCreatVO.getMobile())){
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_NULL,
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
"用户电话不能为空!");
|
|
|
}
|
|
|
if (!RegexValidateUtil.checkMobileNumber(smsVerCreatVO.getMobile())){
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_ERROR,
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR,
|
|
|
"用户电话格式错误!");
|
|
|
}
|
|
|
//验证图片验证码
|
|
@@ -97,7 +96,7 @@ public class VerFacade {
|
|
|
//todo 验证该用户是否被注册
|
|
|
Boolean isReg = false;
|
|
|
if (isReg){
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_ERROR, "该号码已经被注册!");
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "该号码已经被注册!");
|
|
|
}
|
|
|
|
|
|
//验证是否超过两分钟
|
|
@@ -105,12 +104,12 @@ public class VerFacade {
|
|
|
if (null != swsVerInfoCheck){
|
|
|
if (DateUtil.after(DateUtil.addMinutes(swsVerInfoCheck.getCreateTime(), 2),
|
|
|
DateUtil.now())){
|
|
|
- throw new CommonException(ErrorCode.SMS_SEND_ERROR,
|
|
|
+ throw new CommonException(ServiceErrorCode.SMS_SEND_ERROR,
|
|
|
"同一用户两分钟之内不能重复发送验证短信,请两分钟之后再次发送!");
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_ERROR, "图片验证码错误!");
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "图片验证码错误!");
|
|
|
}
|
|
|
|
|
|
//发送短信
|
|
@@ -132,27 +131,27 @@ public class VerFacade {
|
|
|
public Boolean verifySmsVerification(SmsVerVerVO smsVerVerVO){
|
|
|
//参数验证
|
|
|
if (null == smsVerVerVO){
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_NULL,
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
"短信验证码验证输入信息不能为空!");
|
|
|
}
|
|
|
if (StringUtil.isBlank(smsVerVerVO.getImgId())){
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_NULL,
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
"图片验证码唯一标志不能为空!");
|
|
|
}
|
|
|
if (StringUtil.isBlank(smsVerVerVO.getCode())){
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_NULL,
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
"图片验证码不能为空!");
|
|
|
}
|
|
|
if (StringUtil.isBlank(smsVerVerVO.getMobile())){
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_NULL,
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
"用户电话不能为空!");
|
|
|
}
|
|
|
if (StringUtil.isBlank(smsVerVerVO.getSmsCode())){
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_NULL,
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
"短信验证码不能为空!");
|
|
|
}
|
|
|
if (!RegexValidateUtil.checkMobileNumber(smsVerVerVO.getMobile())){
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_ERROR,
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR,
|
|
|
"用户电话格式错误!");
|
|
|
}
|
|
|
//验证图片验证码
|
|
@@ -163,10 +162,10 @@ public class VerFacade {
|
|
|
//todo 验证该用户是否被注册
|
|
|
Boolean isReg = false;
|
|
|
if (isReg){
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_ERROR, "该号码已经被注册!");
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "该号码已经被注册!");
|
|
|
}
|
|
|
} else {
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_ERROR, "图片验证码错误!");
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "图片验证码错误!");
|
|
|
}
|
|
|
//验证用户短信信息
|
|
|
SwsVerInfo swsVerInfo = new SwsVerInfo();
|
|
@@ -174,7 +173,7 @@ public class VerFacade {
|
|
|
swsVerInfo.setCode(smsVerVerVO.getSmsCode());
|
|
|
Boolean smsVer = smsVerService.verifySmsVerification(swsVerInfo);
|
|
|
if (!smsVer){
|
|
|
- throw new CommonException(ErrorCode.PARAM_IS_ERROR, "短信验证未通过!");
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "短信验证未通过!");
|
|
|
}
|
|
|
//todo 将用户信息加入数据库
|
|
|
Boolean registSuccess = true;
|