|
@@ -33,7 +33,11 @@ import com.diagbot.util.RegexValidateUtil;
|
|
|
import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.util.UserUtils;
|
|
|
import com.diagbot.vo.ImgVerVerVO;
|
|
|
+import com.diagbot.vo.OrganizationVO;
|
|
|
+import com.diagbot.vo.UserAndOrganizationVO;
|
|
|
import com.diagbot.vo.UserExportVO;
|
|
|
+import com.diagbot.vo.UserInfoAuditVO;
|
|
|
+import com.diagbot.vo.UserInfoOrganizationsVO;
|
|
|
import com.diagbot.vo.UserSaveVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
@@ -42,6 +46,7 @@ import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.util.ArrayList;
|
|
@@ -50,6 +55,8 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
+
|
|
|
/**
|
|
|
* @Description: 用户业务层
|
|
|
* @author: gaodm
|
|
@@ -512,4 +519,136 @@ public class UserFacade extends UserServiceImpl {
|
|
|
|
|
|
|
|
|
}
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param userInfoOrganizationsVO
|
|
|
+ * @return 修改用户信息和机构信息
|
|
|
+ */
|
|
|
+ public RespDTO<UserInfoOrganizationsVO> updateUserInfoAlls(UserInfoOrganizationsVO userInfoOrganizationsVO) {
|
|
|
+ Map<String, Object> userMap = new HashMap<String, Object>();
|
|
|
+ userMap.put("modifier", UserUtils.getCurrentPrincipleID());
|
|
|
+ userMap.put("gmtModified", DateUtil.now());
|
|
|
+ userMap.put("email", userInfoOrganizationsVO.getEmail());
|
|
|
+ userMap.put("principal", userInfoOrganizationsVO.getPrincipal());
|
|
|
+ userMap.put("address", userInfoOrganizationsVO.getAddress());
|
|
|
+ userMap.put("type", userInfoOrganizationsVO.getType());
|
|
|
+ userMap.put("position", userInfoOrganizationsVO.getPosition());
|
|
|
+ userMap.put("userId", userInfoOrganizationsVO.getUserId());
|
|
|
+ boolean res = updateUserInfoAll(userMap);
|
|
|
+ if (!res) {
|
|
|
+ throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL);
|
|
|
+ }
|
|
|
+ return RespDTO.onSuc(res);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param userInfoAuditVO
|
|
|
+ * @return 审核用户信息和机构信息
|
|
|
+ */
|
|
|
+ public RespDTO<Boolean> auditUserInfoAlls(UserInfoAuditVO userInfoAuditVO) {
|
|
|
+ Map<String, Object> auditMap = new HashMap<String, Object>();
|
|
|
+ auditMap.put("userId", userInfoAuditVO.getUserId());
|
|
|
+ auditMap.put("modifier", UserUtils.getCurrentPrincipleID());
|
|
|
+ auditMap.put("gmtModified", DateUtil.now());
|
|
|
+ auditMap.put("isReject", userInfoAuditVO.getIsReject());
|
|
|
+ auditMap.put("rejectComment", userInfoAuditVO.getRejectComment());
|
|
|
+ auditMap.put("rejectType", userInfoAuditVO.getRejectType());
|
|
|
+ // TODO 审核前先验证该用户的的认证状态
|
|
|
+ boolean res = auditUserInfoAll(auditMap);
|
|
|
+
|
|
|
+ if (!res) {
|
|
|
+ throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL);
|
|
|
+ }
|
|
|
+ return RespDTO.onSuc(res);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param organizationVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public RespDTO<Boolean> addOrganizations(OrganizationVO organizationVO) {
|
|
|
+
|
|
|
+ String organizationName = organizationVO.getOrganizationName();
|
|
|
+ List<Organization> organizationList = organizationFacade.findOrganization(organizationName);
|
|
|
+ if (organizationList.size() > 0) {
|
|
|
+ return RespDTO.onSuc("该机构存在");
|
|
|
+ }
|
|
|
+ Organization organization = new Organization();
|
|
|
+ organization.setName(organizationVO.getOrganizationName());
|
|
|
+ organization.setType(organizationVO.getType());
|
|
|
+ organization.setPrincipal(organizationVO.getPrincipal());
|
|
|
+ organization.setSubNum(organizationVO.getSubNum());
|
|
|
+ organization.setAddress(organizationVO.getAddress());
|
|
|
+ organization.setGmtCreate(DateUtil.now());
|
|
|
+ organization.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
+ // organization.setCreator("5");
|
|
|
+
|
|
|
+ boolean res = organizationFacade.save(organization);
|
|
|
+
|
|
|
+ // System.out.println(GsonUtil.toJson(organization));
|
|
|
+ if (!res) {
|
|
|
+ throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL);
|
|
|
+ }
|
|
|
+ return RespDTO.onSuc(res);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param userAndOrganizationVO
|
|
|
+ * @return 添加用户信息和机构信息管理员
|
|
|
+ */
|
|
|
+ public RespDTO<UserAndOrganizationVO> addUserInfos(UserAndOrganizationVO userAndOrganizationVO) {
|
|
|
+ // TODO 先查找机构,获取机构id,再注册用户,返回用户id, 取到用户id和 机构id ,查询用户机构关联表,在进行绑定
|
|
|
+ // User user = new User();
|
|
|
+ // 验证用户是否存在
|
|
|
+ String username = userAndOrganizationVO.getUserName();
|
|
|
+ User userData = getUserInfo(username);
|
|
|
+ // System.out.println(user);
|
|
|
+ if (userData != null) {
|
|
|
+ return RespDTO.onSuc("该用户存在");
|
|
|
+ }
|
|
|
+ // 验证机构是否被绑定
|
|
|
+ UserOrganization userORG = new UserOrganization();
|
|
|
+ userORG.setOrganizationId(userAndOrganizationVO.getOrganizationid());
|
|
|
+
|
|
|
+ List<UserOrganization> userOrganizationData = userOrganizationFacade.getAgencyPersonnel(userORG);
|
|
|
+ if (userOrganizationData.size() > 0) {
|
|
|
+ return RespDTO.onSuc("该机构绑定了用户!");
|
|
|
+ }
|
|
|
+
|
|
|
+ User user = new User();
|
|
|
+ user.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
+ user.setUsername(userAndOrganizationVO.getUserName());
|
|
|
+ PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
|
|
|
+ String entryPassword = passwordEncoder.encode(userAndOrganizationVO.getPassWord());
|
|
|
+ user.setPassword(entryPassword);
|
|
|
+ user.setLinkman(userAndOrganizationVO.getLinkman());
|
|
|
+ user.setGmtCreate(DateUtil.now());
|
|
|
+ user.setEmail(userAndOrganizationVO.getEmail());
|
|
|
+ boolean res = save(user);
|
|
|
+ if (res == true) {
|
|
|
+ Long userId = user.getId();
|
|
|
+ // 用户信息的认证
|
|
|
+ UserAuthentication userAuthentication = new UserAuthentication();
|
|
|
+ userAuthentication.setCreator(UserUtils.getCurrentPrincipleID());//
|
|
|
+ // 创建人Id
|
|
|
+ userAuthentication.setGmtCreate(DateUtil.now());// 记录创建时间
|
|
|
+ userAuthentication.setPosition(userAndOrganizationVO.getPosition());// 岗位信息
|
|
|
+ userAuthentication.setUserId(userId);// 用户id
|
|
|
+ userAuthentication.setIsReject(1);// 是否通过认证 0:未通过,1:已通过
|
|
|
+ userAuthentication.setStatus(1);// 认证状态(0:未认证,1:已认证,2:认证中)
|
|
|
+ userAuthenticationFacade.save(userAuthentication);
|
|
|
+
|
|
|
+ // 用户信息和机构信息的绑定
|
|
|
+ UserOrganization userOrganization = new UserOrganization();
|
|
|
+ userOrganization.setCreator(UserUtils.getCurrentPrincipleID());//
|
|
|
+ // 创建人Id
|
|
|
+ userOrganization.setGmtCreate(DateUtil.now());
|
|
|
+ userOrganization.setOrganizationId(userAndOrganizationVO.getOrganizationid());// 机构id
|
|
|
+ userOrganization.setUserId(userId);// 用户id
|
|
|
+
|
|
|
+ userOrganizationFacade.save(userOrganization);
|
|
|
+ }
|
|
|
+
|
|
|
+ return RespDTO.onSuc("绑定成功");
|
|
|
+ }
|
|
|
}
|