Bläddra i källkod

拆分超管修改用户信息和修改机构信息接口

wangfeng 6 år sedan
förälder
incheckning
499cc3b6e4

+ 39 - 3
user-service/src/main/java/com/diagbot/facade/UserFacade.java

@@ -48,6 +48,8 @@ import com.diagbot.util.ListUtil;
 import com.diagbot.util.RegexValidateUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.util.UserUtils;
+import com.diagbot.vo.AmendOrgVO;
+import com.diagbot.vo.AmendUserInfoVO;
 import com.diagbot.vo.BaseIdVO;
 import com.diagbot.vo.ImgVerVerVO;
 import com.diagbot.vo.OrganizationVO;
@@ -725,6 +727,8 @@ public class UserFacade extends UserServiceImpl {
         userMap.put("type", userInfoOrganizationsVO.getType());
         userMap.put("position", userInfoOrganizationsVO.getPosition());
         userMap.put("userId", userInfoOrganizationsVO.getUserId());
+        userMap.put("orgId", userInfoOrganizationsVO.getOrgId());
+        userMap.put("orgSubNum", userInfoOrganizationsVO.getOrgSubNum());
         boolean res = updateUserInfoAll(userMap);
         if (!res) {
             throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL);
@@ -788,7 +792,7 @@ public class UserFacade extends UserServiceImpl {
      * @param userAndOrganizationVO
      * @return 添加用户信息和机构信息管理员
      */
-    public RespDTO<UserAndOrganizationVO> addUserInfos(UserAndOrganizationVO userAndOrganizationVO) {
+    public RespDTO<Boolean> addUserInfos(UserAndOrganizationVO userAndOrganizationVO) {
         // TODO 先查找机构,获取机构id,再注册用户,返回用户id, 取到用户id和 机构id ,查询用户机构关联表,在进行绑定
         // User user = new User();
         // 验证用户是否存在
@@ -838,12 +842,12 @@ public class UserFacade extends UserServiceImpl {
             userOrganization.setOrganizationId(userAndOrganizationVO.getOrganizationid());// 机构id
             userOrganization.setUserId(userId);// 用户id
 
-            userOrganizationFacade.save(userOrganization);
+            res = userOrganizationFacade.save(userOrganization);
         } else {
             throw new CommonException(CommonErrorCode.INSERT_DATA_FAILED);
         }
 
-        return RespDTO.onSuc(userAndOrganizationVO);
+        return RespDTO.onSuc(res);
     }
 
 
@@ -1235,6 +1239,38 @@ public class UserFacade extends UserServiceImpl {
 	        ex.exportExcelNew("用户信息详情", listName, listId, list,response);
 		
 	}
+
+    //超管修改用户信息
+	public RespDTO<Boolean> updateUserInfos(AmendUserInfoVO amendUserInfoVO) {
+		 Map<String, Object> amendUserInfo = new HashMap<String, Object>();
+		 amendUserInfo.put("modifier", UserUtils.getCurrentPrincipleID());
+		 amendUserInfo.put("gmtModified", DateUtil.now());
+		 amendUserInfo.put("email", amendUserInfoVO.getEmail());
+		 amendUserInfo.put("userId", amendUserInfoVO.getUserId());
+		 amendUserInfo.put("autPosition",amendUserInfoVO.getAutPosition());
+		 amendUserInfo.put("linKman",amendUserInfoVO.getLinKman());
+	        boolean res = updateUserInfo(amendUserInfo);
+	        if (!res) {
+	            throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL);
+	        }
+	        return RespDTO.onSuc(res);
+	}
+
+    //超管修改机构信息
+	public RespDTO<Boolean> updateOrganizations(AmendOrgVO amendOrgVO) {
+		 Map<String, Object> amendOrg = new HashMap<String, Object>();
+		 amendOrg.put("modifier", UserUtils.getCurrentPrincipleID());
+		 amendOrg.put("gmtModified", DateUtil.now());
+		 amendOrg.put("address", amendOrgVO.getOrgAddress());
+		 amendOrg.put("type", amendOrgVO.getOrgType());
+		 amendOrg.put("orgId", amendOrgVO.getOrgId());
+		 amendOrg.put("orgSubNum", amendOrgVO.getOrgSubNum());
+	        boolean res = updateOrganizations(amendOrg);
+	        if (!res) {
+	            throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL);
+	        }
+	        return RespDTO.onSuc(res);
+	}
     
     
 }

+ 4 - 0
user-service/src/main/java/com/diagbot/mapper/UserMapper.java

@@ -73,5 +73,9 @@ public interface UserMapper extends BaseMapper<User> {
     public IPage<UserOrgizationProductDTO> queryVerifiedUserOrganizationProduct(Page page, @Param("userOrg")  CustomerDTO userInfo);
     
     public IPage<AuthenticationDTO> queryAuthentication(Page page, @Param("authen")  CustomerDTO userInfo);
+    
+    public boolean updateUserInfo (@Param("amendUserInfo") Map<String, Object> amendUserInfo);
+    
+    public boolean updateOrganizations (@Param("amendOrg") Map<String, Object> amendOrg);
 
 }

+ 3 - 0
user-service/src/main/java/com/diagbot/service/UserService.java

@@ -70,4 +70,7 @@ public interface UserService extends IService<User> {
     
     public IPage<AuthenticationDTO> queryAuthentication(Page page,  CustomerDTO userInfo);
 
+    public boolean updateUserInfo (Map<String, Object> amendUserInfo);
+    
+    public boolean updateOrganizations (Map<String, Object> amendOrg);
 }

+ 12 - 0
user-service/src/main/java/com/diagbot/service/impl/UserServiceImpl.java

@@ -133,6 +133,18 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 		
 		return baseMapper.queryAuthentication(page, userInfo);
 	}
+
+	@Override
+	public boolean updateUserInfo(Map<String, Object> amendUserInfo) {
+		// TODO Auto-generated method stub
+		return baseMapper.updateUserInfo(amendUserInfo);
+	}
+
+	@Override
+	public boolean updateOrganizations(Map<String, Object> amendOrg) {
+		// TODO Auto-generated method stub
+		return baseMapper.updateOrganizations(amendOrg);
+	}
 	
 
 

+ 26 - 0
user-service/src/main/java/com/diagbot/vo/AmendOrgVO.java

@@ -0,0 +1,26 @@
+package com.diagbot.vo;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.validation.constraints.NotNull;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 
+ * @author wangfeng
+ * @Description: 修改机构信息
+ * @date 2018年10月15日 上午9:55:38
+ */
+@Getter
+@Setter
+public class AmendOrgVO {
+
+    @NotNull(message = "请输入机构id!")
+	 private Long orgId;//机构ID
+	 private Integer orgType;//机构属性
+	 private String orgAddress;//机构地址
+	 private Integer orgSubNum;//下属机构数量
+}

+ 25 - 0
user-service/src/main/java/com/diagbot/vo/AmendUserInfoVO.java

@@ -0,0 +1,25 @@
+package com.diagbot.vo;
+
+import java.util.Date;
+
+import javax.validation.constraints.NotNull;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 
+ * @author wangfeng
+ * @Description: 修改超管信息
+ * @date 2018年10月15日 上午9:55:10
+ */
+@Getter
+@Setter
+public class AmendUserInfoVO {
+	
+	@NotNull(message = "请输入用户id!")
+	private Long userId;//用户ID
+    private String linKman;//联系人
+    private String email;// 邮箱
+    private String autPosition;//岗位信息
+}

+ 1 - 1
user-service/src/main/java/com/diagbot/vo/UserAndOrganizationVO.java

@@ -31,7 +31,7 @@ public class UserAndOrganizationVO {
     /**
      * 用户名
      */
-    @Pattern(regexp = "^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\\d{8}$", message = "请输入手机号!")
+   // @Pattern(regexp = "^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\\d{8}$", message = "请输入手机号!")
     private String userName;
 
     /**

+ 3 - 1
user-service/src/main/java/com/diagbot/vo/UserInfoOrganizationsVO.java

@@ -16,10 +16,12 @@ import java.io.Serializable;
 public class UserInfoOrganizationsVO implements Serializable {
 
     private String email;//邮箱
+    private String linKman;//联系人
     private String principal;//负责人
     private String address;//单位地址
     private Integer type;//机构属性
     private String position;//岗位部门
-    @NotNull(message = "请输入用户id!")
+    private Integer orgSubNum;//下属机构数量
     private Long userId;//用户id
+    private Long orgId;//机构id
 }

+ 22 - 1
user-service/src/main/java/com/diagbot/web/UserInfoController.java

@@ -1,6 +1,7 @@
 package com.diagbot.web;
 
 import java.util.List;
+import java.util.Map;
 
 import javax.validation.Valid;
 
@@ -8,6 +9,7 @@ import com.diagbot.vo.UserInfoPagVO;
 import com.diagbot.vo.UserOrganProductPageVO;
 import com.diagbot.vo.UsernameVO;
 
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -30,6 +32,8 @@ import com.diagbot.facade.OrganizationFacade;
 import com.diagbot.facade.UserAuthenticationFacade;
 import com.diagbot.facade.UserFacade;
 import com.diagbot.facade.UserOrganizationFacade;
+import com.diagbot.vo.AmendOrgVO;
+import com.diagbot.vo.AmendUserInfoVO;
 import com.diagbot.vo.BaseIdVO;
 import com.diagbot.vo.OrganizationNameVO;
 import com.diagbot.vo.OrganizationVO;
@@ -78,6 +82,7 @@ public class UserInfoController {
     @PostMapping("/updateUserInfoAll")
     @SysLogger("updateUserInfoAll")
     @Transactional
+    @ApiIgnore
     public RespDTO<UserInfoOrganizationsVO> updateUserInfoAll(
             @Valid @RequestBody UserInfoOrganizationsVO userInfoOrganizationsVO) {
         return userFacade.updateUserInfoAlls(userInfoOrganizationsVO);
@@ -123,7 +128,7 @@ public class UserInfoController {
     @PostMapping("/addUserInfo")
     @SysLogger("addUserInfo")
     @Transactional
-    public RespDTO<UserAndOrganizationVO> addUserInfo(@Valid @RequestBody UserAndOrganizationVO userAndOrganizationVO) {
+    public RespDTO<Boolean> addUserInfo(@Valid @RequestBody UserAndOrganizationVO userAndOrganizationVO) {
 
         return userFacade.addUserInfos(userAndOrganizationVO);
     }
@@ -172,5 +177,21 @@ public class UserInfoController {
 		return userFacade.queryAuthentications(userAndOrgPageVO,userAndOrgPageVO.getOrgName(),userAndOrgPageVO.getUserName(),userAndOrgPageVO.getStartTime(),userAndOrgPageVO.getEndTime());
 	} 
     
+    @ApiOperation(value = "超管信息修改接口[by:wangfeng]", notes = "用户id必传")
+    @PostMapping("/updateUserInfo")
+    @SysLogger("updateUserInfo")
+    @Transactional
+    public RespDTO<Boolean> updateUserInfo (@RequestBody AmendUserInfoVO amendUserInfoVO){
+		return userFacade.updateUserInfos(amendUserInfoVO);
+    	
+    }
     
+    @ApiOperation(value = "机构信息修改接口[by:wangfeng]", notes = "机构id必传")
+    @PostMapping("/updateOrganizations")
+    @SysLogger("updateOrganizations")
+    @Transactional
+    public RespDTO<Boolean> updateOrganization (@RequestBody AmendOrgVO amendOrgVO){
+		return userFacade.updateOrganizations(amendOrgVO);
+    	
+    }
 }

+ 55 - 0
user-service/src/main/resources/mapper/UserMapper.xml

@@ -413,4 +413,59 @@
         AND aut.status = 2
         ORDER BY u.gmt_create DESC
     </select>
+	<update id="updateUserInfo" parameterType="java.util.Map">
+	UPDATE
+	sys_user a
+	JOIN sys_user_authentication b ON a.id = b.user_id
+	<trim prefix="set" suffixOverrides=",">
+		<if test="amendUserInfo.linKman != null">
+			a.linkman = #{amendUserInfo.linKman},
+		</if>
+		<if test="amendUserInfo.email != null">
+			a.email = #{amendUserInfo.email},
+		</if>
+		<if test="amendUserInfo.autPosition != null">
+			b.position = #{amendUserInfo.autPosition},
+		</if>
+		<if test="amendUserInfo.gmtModified != null">
+			a.gmt_modified =#{amendUserInfo.gmtModified},
+		</if>
+		<if test="amendUserInfo.gmtModified != null">
+			b.gmt_modified = #{amendUserInfo.gmtModified},
+		</if>
+		<if test="amendUserInfo.modifier != null">
+			a.modifier = #{amendUserInfo.modifier},
+		</if>
+		<if test="amendUserInfo.modifier != null">
+			b.modifier = #{amendUserInfo.modifier}
+		</if>
+	</trim>
+	WHERE
+	a.is_deleted = "N"
+	AND b.is_deleted = "N"
+	AND a.id = #{amendUserInfo.userId}
+    </update>
+	<update id="updateOrganizations" parameterType="java.util.Map">
+		UPDATE sys_organization a
+		<trim prefix="set" suffixOverrides=",">
+			<if test="amendOrg.address != null">
+				a.address = #{amendOrg.address},
+			</if>
+			<if test="amendOrg.type != null">
+				a.type = #{amendOrg.type},
+			</if>
+			<if test="amendOrg.subMum != null">
+				a.sub_num = #{amendOrg.subMum},
+			</if>
+			<if test="amendOrg.gmtModified != null">
+				a.gmt_modified =#{amendOrg.gmtModified},
+			</if>
+			<if test="amendOrg.modifier != null">
+				a.modifier =#{amendOrg.modifier}
+			</if>
+		</trim>
+		WHERE
+		a.is_deleted = "N"
+		AND a.id = #{amendOrg.orgId}
+	</update>
 </mapper>