|
@@ -2,9 +2,6 @@ package com.lantone.security.facade;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
-import com.diagbot.enums.IsDeleteEnum;
|
|
|
-import com.diagbot.exception.CommonErrorCode;
|
|
|
-import com.diagbot.exception.CommonException;
|
|
|
import com.lantone.common.dto.DataAuthDTO;
|
|
|
import com.lantone.common.dto.DataAuthDetailDTO;
|
|
|
import com.lantone.common.dto.DeptDTO;
|
|
@@ -12,6 +9,7 @@ import com.lantone.common.dto.HospitalDTO;
|
|
|
import com.lantone.common.dto.RoleDTO;
|
|
|
import com.lantone.common.dto.ServiceRoleDataAuthDetailDTO;
|
|
|
import com.lantone.common.dto.SysServiceDTO;
|
|
|
+import com.lantone.common.exception.Asserts;
|
|
|
import com.lantone.common.util.DateUtil;
|
|
|
import com.lantone.common.util.ListUtil;
|
|
|
import com.lantone.common.util.StringUtil;
|
|
@@ -36,6 +34,7 @@ import com.lantone.security.enums.CRUDEnum;
|
|
|
import com.lantone.security.enums.DataAuthDataTypeEnum;
|
|
|
import com.lantone.security.enums.DataAuthDetailTypeEnum;
|
|
|
import com.lantone.security.enums.HospitalTypeEnum;
|
|
|
+import com.lantone.security.enums.IsDeleteEnum;
|
|
|
import com.lantone.security.enums.ServiceEnum;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -88,15 +87,16 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
return addDataAuth(serviceDataAuthVO);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, e.toString());
|
|
|
+ Asserts.fail(e.toString());
|
|
|
}
|
|
|
} else if (CRUDEnum.UPDATE.getKey() == serviceDataAuthVO.getType()) {
|
|
|
return updateDataAuth(serviceDataAuthVO);
|
|
|
} else if (CRUDEnum.DELETE.getKey() == serviceDataAuthVO.getType()) {
|
|
|
return deleteDataAuth(serviceDataAuthVO);
|
|
|
} else {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "操作码错误");
|
|
|
+ Asserts.fail("操作码错误");
|
|
|
}
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -122,16 +122,16 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
|
|
|
if (ListUtil.isNotEmpty(serviceDataAuthIDS)) {
|
|
|
//3.获取该权限关联的角色id
|
|
|
-// List<Long> roleIDS = roleServiceDataAuthFacade.list(new QueryWrapper<RoleServiceDataAuth>()
|
|
|
-// .in("service_data_auth_id", serviceDataAuthIDS)
|
|
|
-// .eq("is_deleted", IsDeleteEnum.N.getKey())).stream().map(RoleServiceDataAuth::getRoleId).collect(Collectors.toList());
|
|
|
+ // List<Long> roleIDS = roleServiceDataAuthFacade.list(new QueryWrapper<RoleServiceDataAuth>()
|
|
|
+ // .in("service_data_auth_id", serviceDataAuthIDS)
|
|
|
+ // .eq("is_deleted", IsDeleteEnum.N.getKey())).stream().map(RoleServiceDataAuth::getRoleId).collect(Collectors.toList());
|
|
|
|
|
|
//4.通过serviceDataAuthIDS 删除sys_role_service_data_auth和sys_service_data_auth和sys_data_auth_detail 对应关系
|
|
|
if (deleteServiceDataAuth(serviceDataAuthIDS)) {
|
|
|
//5.插入新建数据权限与系统的关系
|
|
|
saveServiceDataAuth(serviceDataAuthVO, serviceDataAuthVO.getDataAuthVO().getId());
|
|
|
} else {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "数据权限与系统关系删除失败");
|
|
|
+ Asserts.fail("数据权限与系统关系删除失败");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -139,7 +139,7 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
|
|
|
|
|
|
} else {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "数据权限修改失败");
|
|
|
+ Asserts.fail("数据权限修改失败");
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -163,11 +163,12 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
.in("id", serviceDataAuthIDS)
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey()));
|
|
|
} else {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "数据权限与系统、角色关联关系删除失败");
|
|
|
+ Asserts.fail("数据权限与系统、角色关联关系删除失败");
|
|
|
}
|
|
|
} else {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "系统数据权限与数据权限明细关联关系删除失败");
|
|
|
+ Asserts.fail("系统数据权限与数据权限明细关联关系删除失败");
|
|
|
}
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -209,7 +210,7 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
saveServiceDataAuth(serviceDataAuthVO, dataAuthId);
|
|
|
|
|
|
} else {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "数据权限插入失败");
|
|
|
+ Asserts.fail("数据权限插入失败");
|
|
|
}
|
|
|
return true;
|
|
|
|
|
@@ -248,7 +249,7 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
roleServiceDataAuth.setCreator(1l);
|
|
|
// roleServiceDataAuth.setCreator(Long.parseLong(SysUserUtils.getCurrentPrincipleID()));
|
|
|
if (!roleServiceDataAuthFacade.save(roleServiceDataAuth)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "角色对应服务数据权限关系插入失败");
|
|
|
+ Asserts.fail("角色对应服务数据权限关系插入失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -261,12 +262,12 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
dataAuthDetail.setCreateTime(DateUtil.now());
|
|
|
dataAuthDetail.setServiceDataAuthId(serviceDataAuthId);
|
|
|
if (!dataAuthDetailFacade.save(dataAuthDetail)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "数据权限明细插入失败");
|
|
|
+ Asserts.fail("数据权限明细插入失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "服务对应数据权限关系插入失败");
|
|
|
+ Asserts.fail("服务对应数据权限关系插入失败");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -281,35 +282,35 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
*/
|
|
|
private void inputParamCheck(ServiceDataAuthVO serviceDataAuthVO) {
|
|
|
if (serviceDataAuthVO == null) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "入参为空");
|
|
|
+ Asserts.fail("入参为空");
|
|
|
}
|
|
|
if (serviceDataAuthVO.getType() == 0) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "操作码为空");
|
|
|
+ Asserts.fail("操作码为空");
|
|
|
}
|
|
|
switch (serviceDataAuthVO.getType()) {
|
|
|
case 1:
|
|
|
if (StringUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getAuthName())) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "数据权限名称为空");
|
|
|
+ Asserts.fail("数据权限名称为空");
|
|
|
}
|
|
|
if (ListUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getServiceVOS())) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "数据权限对应系统未选择");
|
|
|
+ Asserts.fail("数据权限对应系统未选择");
|
|
|
}
|
|
|
if (ListUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getServiceVOS().get(0).getDataAuthDetailVOS())) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "系统对应数据权限明细未选择");
|
|
|
+ Asserts.fail("系统对应数据权限明细未选择");
|
|
|
}
|
|
|
break;
|
|
|
case 2:
|
|
|
if (serviceDataAuthVO.getDataAuthVO().getId() == null) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "数据权限ID为空");
|
|
|
+ Asserts.fail("数据权限ID为空");
|
|
|
}
|
|
|
if (StringUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getAuthName())) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "数据权限名称为空");
|
|
|
+ Asserts.fail("数据权限名称为空");
|
|
|
}
|
|
|
if (ListUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getServiceVOS())) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "数据权限对应系统未选择");
|
|
|
+ Asserts.fail("数据权限对应系统未选择");
|
|
|
}
|
|
|
if (ListUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getServiceVOS().get(0).getDataAuthDetailVOS())) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "系统对应数据权限明细未选择");
|
|
|
+ Asserts.fail("系统对应数据权限明细未选择");
|
|
|
}
|
|
|
break;
|
|
|
case 3:
|
|
@@ -379,7 +380,7 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
});
|
|
|
dataAuthDTO.setSysServiceDTOS(sysServiceDTOS);
|
|
|
} else {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请检查角色id或数据权限id");
|
|
|
+ Asserts.fail("请检查角色id或数据权限id");
|
|
|
}
|
|
|
|
|
|
return dataAuthDTO;
|