|
@@ -1,24 +1,23 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
import com.diagbot.dto.QueryAuthProgressDTO;
|
|
|
import com.diagbot.dto.UserAuthenticationDTO;
|
|
|
-import com.diagbot.dto.UserAuthenticationRespDTO;
|
|
|
import com.diagbot.entity.Organization;
|
|
|
import com.diagbot.entity.User;
|
|
|
import com.diagbot.entity.UserAuthentication;
|
|
|
import com.diagbot.enums.AuthStatusEnum;
|
|
|
import com.diagbot.enums.OrganizationTypeEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.impl.UserAuthenticationServiceImpl;
|
|
|
import com.diagbot.util.UserUtils;
|
|
|
import com.diagbot.vo.UserAuthenticationVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @Description:用户认证业务层
|
|
@@ -32,38 +31,38 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
|
|
|
@Autowired
|
|
|
private OrganizationFacade organizationFacade;
|
|
|
|
|
|
- public UserAuthenticationRespDTO userAuthentication(UserAuthenticationVO userAuthenticationVO) {
|
|
|
- UserAuthenticationRespDTO userAuthenticationRespDTO = new UserAuthenticationRespDTO();
|
|
|
+ /**
|
|
|
+ * @Description:用户认证
|
|
|
+ * @author: zhaops
|
|
|
+ * @time: 2018/9/13 19:30
|
|
|
+ */
|
|
|
+ public UserAuthenticationDTO userAuthentication(UserAuthenticationVO userAuthenticationVO) {
|
|
|
+ UserAuthenticationDTO userAuthenticationDTO = new UserAuthenticationDTO();
|
|
|
Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
|
|
|
User user_old = userFacade.getById(userId);
|
|
|
User user = userFacade.findByName(userAuthenticationVO.getUserName());
|
|
|
if (user == null) {
|
|
|
- userAuthenticationRespDTO.setMsg("用户【" + userAuthenticationVO.getUserName() + "】不存在,不允许验证!");
|
|
|
- userAuthenticationRespDTO.setIsSuccess(false);
|
|
|
- return userAuthenticationRespDTO;
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
+ "用户【" + userAuthenticationVO.getUserName() + "】不存在,不允许验证");
|
|
|
} else if (user.getId() != userId) {
|
|
|
- userAuthenticationRespDTO.setMsg("登录用户【" + user_old.getUsername() + "】与验证用户【" + user.getUsername() + "】不符,不允许验证!");
|
|
|
- userAuthenticationRespDTO.setIsSuccess(false);
|
|
|
- return userAuthenticationRespDTO;
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "登录用户【" + user_old.getUsername() + "】与验证用户【" + user.getUsername() + "】不符,不允许验证");
|
|
|
}
|
|
|
|
|
|
//判断该用户是否有关联机构
|
|
|
Organization organization_old = organizationFacade.getByUserId(userId);
|
|
|
if (organization_old == null) {
|
|
|
- userAuthenticationRespDTO.setMsg("当前用户没有关联机构,不允许验证!");
|
|
|
- userAuthenticationRespDTO.setIsSuccess(false);
|
|
|
- return userAuthenticationRespDTO;
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
+ "当前用户没有关联机构,不允许验证");
|
|
|
}
|
|
|
//更新机构信息
|
|
|
Organization organization = organizationFacade.getByName(userAuthenticationVO.getOrganization());
|
|
|
if (organization == null) {
|
|
|
- userAuthenticationRespDTO.setMsg("找不到机构【" + userAuthenticationVO.getOrganization() + "】!");
|
|
|
- userAuthenticationRespDTO.setIsSuccess(false);
|
|
|
- return userAuthenticationRespDTO;
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
+ "找不到机构【" + userAuthenticationVO.getOrganization() + "】");
|
|
|
} else if (organization.getId() != organization_old.getId()) {
|
|
|
- userAuthenticationRespDTO.setMsg("当前用户已关联到机构【" + organization_old.getName() + "】,不允许修改机构!");
|
|
|
- userAuthenticationRespDTO.setIsSuccess(false);
|
|
|
- return userAuthenticationRespDTO;
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "当前用户已关联到机构【" + organization_old.getName() + "】,不允许修改机构");
|
|
|
}
|
|
|
organization.setAddress(userAuthenticationVO.getOrganizationAddress());
|
|
|
organization.setPrincipal(userAuthenticationVO.getOrganizationPrincipal());
|
|
@@ -81,13 +80,11 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
|
|
|
userAuthentication.setGmtCreate(new Date());
|
|
|
userAuthentication.setUserId(userId);
|
|
|
} else if (userAuthentication.getStatus() == 1) {
|
|
|
- userAuthenticationRespDTO.setMsg("用户【" + user.getUsername() + "】已认证,不允许重复认证!");
|
|
|
- userAuthenticationRespDTO.setIsSuccess(false);
|
|
|
- return userAuthenticationRespDTO;
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "用户【" + user.getUsername() + "】已认证,不允许重复认证");
|
|
|
} else if (userAuthentication.getStatus() == 2) {
|
|
|
- userAuthenticationRespDTO.setMsg("认证申请已提交,请耐心等待……");
|
|
|
- userAuthenticationRespDTO.setIsSuccess(false);
|
|
|
- return userAuthenticationRespDTO;
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "认证申请已提交,无需重复提交");
|
|
|
}
|
|
|
userAuthentication.setModifier(userId.toString());
|
|
|
userAuthentication.setGmtModified(new Date());
|
|
@@ -95,16 +92,17 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
|
|
|
userAuthentication.setStatus(2); //状态设为认证中
|
|
|
this.saveOrUpdate(userAuthentication);
|
|
|
|
|
|
- userAuthenticationRespDTO.setMsg("认证申请已提交成功,请耐心等待1~2个工作日");
|
|
|
- userAuthenticationRespDTO.setIsSuccess(true);
|
|
|
- UserAuthenticationDTO userAuthenticationDTO = new UserAuthenticationDTO();
|
|
|
userAuthenticationDTO.setUser(user);
|
|
|
userAuthenticationDTO.setOrganization(organization);
|
|
|
userAuthenticationDTO.setUserAuthentication(userAuthentication);
|
|
|
- userAuthenticationRespDTO.setUserAuthenticationDTO(userAuthenticationDTO);
|
|
|
- return userAuthenticationRespDTO;
|
|
|
+ return userAuthenticationDTO;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Description:获取用户认证信息
|
|
|
+ * @author: zhaops
|
|
|
+ * @time: 2018/9/13 19:30
|
|
|
+ */
|
|
|
public UserAuthenticationDTO getuserAuthenticationInfo() {
|
|
|
Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
|
|
|
User user = userFacade.getById(userId);
|
|
@@ -122,6 +120,11 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
|
|
|
return userAuthenticationDTO;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Description:获取用户认证状态
|
|
|
+ * @author: zhaops
|
|
|
+ * @time: 2018/9/13 19:30
|
|
|
+ */
|
|
|
public Map<Integer, Object> getUserAuthenticationStatus() {
|
|
|
Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
|
|
|
UserAuthentication userAuthentication = this.getByUserId(userId);
|
|
@@ -152,13 +155,12 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
|
|
|
public QueryAuthProgressDTO queryAuthProgress() {
|
|
|
Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
|
|
|
UserAuthentication userAuthentication = this.getByUserId(userId);
|
|
|
-
|
|
|
+
|
|
|
QueryAuthProgressDTO queryAuthProgressDTO = new QueryAuthProgressDTO();
|
|
|
queryAuthProgressDTO.setStatus(userAuthentication.getStatus());
|
|
|
queryAuthProgressDTO.setIsReject(userAuthentication.getIsReject());
|
|
|
queryAuthProgressDTO.setRejectComment(userAuthentication.getRejectComment());
|
|
|
-
|
|
|
+
|
|
|
return queryAuthProgressDTO;
|
|
|
}
|
|
|
-
|
|
|
}
|