瀏覽代碼

Merge remote-tracking branch 'origin/dev/ez-security210625' into dev/ez-security210625

chengyao 3 年之前
父節點
當前提交
6c2bc68c23

+ 3 - 0
common/src/main/java/com/lantone/common/vo/AddHospitalVO.java

@@ -5,6 +5,7 @@ import lombok.Data;
 
 import javax.validation.Valid;
 import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.util.Date;
@@ -59,9 +60,11 @@ public class AddHospitalVO  implements Serializable {
 
     @ApiModelProperty(value = "组织管理员用户",required = true)
     @Valid
+    @NotNull(message = "管理用户信息不能为空")
     private AddHospitalUserVO addHospitalUserVO;
 
     @ApiModelProperty(value = "系统服务对象",required = true)
     @Valid
+    @NotEmpty(message = "管理用户系统服务不能为空")
     private List<AddRoleSoftwareVO> softwares;
 }

+ 4 - 0
common/src/main/java/com/lantone/common/vo/UpdateHospitalVO.java

@@ -5,6 +5,7 @@ import lombok.Data;
 
 import javax.validation.Valid;
 import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.util.Date;
@@ -51,8 +52,11 @@ public class UpdateHospitalVO implements Serializable {
 
     @ApiModelProperty(value = "组织管理员用户",required = true)
     @Valid
+    @NotNull(message = "管理用户信息不能为空")
     private AddHospitalUserVO addHospitalUserVO;
 
     @ApiModelProperty(value = "系统服务对象",required = true)
+    @NotEmpty(message = "管理用户系统服务不能为空")
+    @Valid
     private List<AddRoleSoftwareVO> softwares;
 }

+ 12 - 2
security-center/src/main/java/com/lantone/security/facade/HospitalManagementFacade.java

@@ -249,7 +249,11 @@ public class HospitalManagementFacade {
     private boolean deleteHUserAndRole(Long hospitalId) {
 
         //1.获取用户id
-        List<Long> userIds = hospitalUserFacade.getBaseMapper().getHospitalUserById(hospitalId, hospitalFacade.getById(hospitalId).getName() + "管理员");
+        Hospital hospital = hospitalFacade.getById(hospitalId);
+        if (hospital == null) {
+            Asserts.fail("组织不存在");
+        }
+        List<Long> userIds = hospitalUserFacade.getBaseMapper().getHospitalUserById(hospitalId, hospital.getName() + "管理员");
         if (ListUtil.isEmpty(userIds)) {
             Asserts.fail("该组织的管理用户不存在,请联系管理员~");
         }
@@ -432,6 +436,9 @@ public class HospitalManagementFacade {
                 Asserts.fail("该组织的管理用户存在多个,请联系管理员~");
             }
             User user = userFacade.getById(userIds.get(0));
+            if (user == null) {
+                Asserts.fail("组织管理用户不存在~");
+            }
             GetHospitalUserDTO getHospitalUserDTO = new GetHospitalUserDTO();
             user.setPassword(user.getPassword());
             BeanUtils.copyProperties(user, getHospitalUserDTO);
@@ -446,7 +453,10 @@ public class HospitalManagementFacade {
             }
             getHospitalByIdDTO.setGetRoleDTO(roleManagementFacade.getRoleById(roleIds.get(0), "0"));
         }
-        getHospitalByIdDTO.setParentName(hospitalFacade.getById(getHospitalByIdDTO.getParentId()).getName());
+        Hospital parentHospital = hospitalFacade.getById(getHospitalByIdDTO.getParentId());
+        if (parentHospital != null) {
+            getHospitalByIdDTO.setParentName(parentHospital.getName());
+        }
         return getHospitalByIdDTO;
     }
 

+ 1 - 1
security-center/src/main/java/com/lantone/security/facade/RoleManagementFacade.java

@@ -184,7 +184,7 @@ public class RoleManagementFacade {
         } else {
             if (ListUtil.isNotEmpty(roles)) {
                 roles.stream().forEach(role -> {
-                    if (id != role.getId()) {
+                    if (!id.equals( role.getId())) {
                         Asserts.fail("该角色已存在请重新输入");
                     }
                 });

+ 14 - 1
security-center/src/main/java/com/lantone/security/facade/UserManagementFacade.java

@@ -210,6 +210,9 @@ public class UserManagementFacade {
             //修改时判断
         } else {
             User userTemp = userFacade.getById(user.getId());
+            if (userTemp == null) {
+                Asserts.fail("用户不存,请刷新重试~");
+            }
             //用户名没有变动
             if (!user.getUsername().equals(userTemp.getUsername())) {
                 if (userFacade.list(new QueryWrapper<User>()
@@ -476,6 +479,9 @@ public class UserManagementFacade {
      */
     public List<GetHospitalTreeDTO> getLoginUserHospitalTree() {
         Hospital hospital = hospitalFacade.getById(SysUserUtils.getCurrentHospitalId());
+        if (hospital == null) {
+            Asserts.fail("登录用户组织不存在,请联系管理员~");
+        }
         //获取当前医院的树状结构
         List<GetHospitalTreeDTO> hospitalTrees = hospitalFacade.getBaseMapper()
                 .getHospitalTreeInfo(SysUserUtils.getCurrentHospitalId(), StatusEnum.Enable.getKey());
@@ -590,6 +596,9 @@ public class UserManagementFacade {
         BeanUtils.copyProperties(user, getUserDTO);
         //2.获取当前用户的组织类型
         Hospital hospital = hospitalFacade.getById(SysUserUtils.getCurrentHospitalId());
+        if (hospital == null) {
+            Asserts.fail("该用户所属组织不存在请刷新重试~");
+        }
         //3.获取查询用户的科室id列表、医院id列表
         List<Long> hospitals = hospitalUserFacade.list(new QueryWrapper<HospitalUser>()
                 .eq("user_id", userId)
@@ -746,7 +755,11 @@ public class UserManagementFacade {
         out.put("jump", jumpFlag);
         out.put("software", userSoftwareHospitals);
         UserInfoDTO userInfo = new UserInfoDTO();
-        BeanUtils.copyProperties(userFacade.getById(SysUserUtils.getCurrentPrincipleId()), userInfo);
+        User user = userFacade.getById(SysUserUtils.getCurrentPrincipleId());
+        if (user == null) {
+            Asserts.fail("用户不存在,请联系管理员~");
+        }
+        BeanUtils.copyProperties(user, userInfo);
         out.put("userInfo", userInfo);
         return out;
     }