|
@@ -16,10 +16,8 @@ import com.lantone.common.exception.Asserts;
|
|
|
import com.lantone.common.util.DateUtil;
|
|
|
import com.lantone.common.util.ListUtil;
|
|
|
import com.lantone.common.util.SysUserUtils;
|
|
|
-import com.lantone.common.vo.AddAuthRoleVO;
|
|
|
import com.lantone.common.vo.AddAuthSoftwareVO;
|
|
|
import com.lantone.common.vo.AddAuthVO;
|
|
|
-import com.lantone.common.vo.DataAuthDetailVO;
|
|
|
import com.lantone.common.vo.GetDataAuthPageVO;
|
|
|
import com.lantone.common.vo.GetDoctorPageVO;
|
|
|
import com.lantone.common.vo.UpdateAuthVO;
|
|
@@ -27,6 +25,7 @@ import com.lantone.dblayermbg.entity.DataAuth;
|
|
|
import com.lantone.dblayermbg.entity.DataAuthDetail;
|
|
|
import com.lantone.dblayermbg.entity.Dept;
|
|
|
import com.lantone.dblayermbg.entity.Hospital;
|
|
|
+import com.lantone.dblayermbg.entity.Menu;
|
|
|
import com.lantone.dblayermbg.entity.RoleSoftwareDataAuth;
|
|
|
import com.lantone.dblayermbg.entity.SoftwareDataAuth;
|
|
|
import com.lantone.dblayermbg.facade.DataAuthDetailFacade;
|
|
@@ -36,6 +35,8 @@ import com.lantone.dblayermbg.facade.DoctorFacade;
|
|
|
import com.lantone.dblayermbg.facade.HospitalFacade;
|
|
|
import com.lantone.dblayermbg.facade.RoleSoftwareDataAuthFacade;
|
|
|
import com.lantone.dblayermbg.facade.SoftwareDataAuthFacade;
|
|
|
+import com.lantone.dblayermbg.service.impl.DataAuthDetailServiceImpl;
|
|
|
+import com.lantone.dblayermbg.service.impl.RoleSoftwareDataAuthServiceImpl;
|
|
|
import com.lantone.security.enums.DataAuthDataTypeEnum;
|
|
|
import com.lantone.security.enums.DataAuthDetailTypeEnum;
|
|
|
import com.lantone.security.enums.HospitalTypeEnum;
|
|
@@ -50,15 +51,14 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * @ClassName: DataAuthHandleFacade
|
|
|
* @Description:数据权限操作facade
|
|
|
* @Author songxl
|
|
|
* @Date 2021/7/21
|
|
|
- * @Version 1.0
|
|
|
*/
|
|
|
@Component
|
|
|
public class DataAuthManagementFacade {
|
|
@@ -115,11 +115,11 @@ public class DataAuthManagementFacade {
|
|
|
}
|
|
|
}
|
|
|
//4.插入新建数据权限与系统的关系
|
|
|
- saveServiceDataAuth(updateAuthVO.getUpdateDataAuthVO().getSoftwareVOS(), updateAuthVO.getRoles(), updateAuthVO.getUpdateDataAuthVO().getId());
|
|
|
+ return saveServiceDataAuth(updateAuthVO.getUpdateDataAuthVO().getSoftwareVOS(), updateAuthVO.getRoles(), updateAuthVO.getUpdateDataAuthVO().getId());
|
|
|
} else {
|
|
|
Asserts.fail("数据权限修改失败");
|
|
|
}
|
|
|
- return true;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -153,26 +153,27 @@ public class DataAuthManagementFacade {
|
|
|
*/
|
|
|
public boolean deleteDataAuth(Long Id) {
|
|
|
//1.删除数据权限
|
|
|
- boolean dataAuthdelete = dataAuthFacade.remove(new UpdateWrapper<DataAuth>()
|
|
|
- .eq("id", Id)
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey()));
|
|
|
+ boolean dataAuthdelete = dataAuthFacade.update(new UpdateWrapper<DataAuth>()
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey())
|
|
|
+ .eq("id", Id));
|
|
|
if (dataAuthdelete) {
|
|
|
- //2.获取该权限 系统与数据权限信息关联表(sys_service_data_auth)的关联id
|
|
|
- List<Long> serviceDataAuthIDS = softwareDataAuthFacade.list(new QueryWrapper<SoftwareDataAuth>()
|
|
|
- .eq("data_auth_id", Id)
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())).stream().map(SoftwareDataAuth::getId).collect(Collectors.toList());
|
|
|
- //3.通过serviceDataAuthIDS 删除sys_role_service_data_auth和sys_service_data_auth和sys_data_auth_detail 对应关系
|
|
|
- if (ListUtil.isNotEmpty(serviceDataAuthIDS)) {
|
|
|
- if (deleteServiceDataAuth(serviceDataAuthIDS)) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- Asserts.fail("数据权限与系统关系删除失败");
|
|
|
- }
|
|
|
- }
|
|
|
+// //2.获取该权限 系统与数据权限信息关联表(sys_service_data_auth)的关联id
|
|
|
+// List<Long> serviceDataAuthIDS = softwareDataAuthFacade.list(new QueryWrapper<SoftwareDataAuth>()
|
|
|
+// .eq("data_auth_id", Id)
|
|
|
+// .eq("is_deleted", IsDeleteEnum.N.getKey())).stream().map(SoftwareDataAuth::getId).collect(Collectors.toList());
|
|
|
+// //3.通过serviceDataAuthIDS 删除sys_role_service_data_auth和sys_service_data_auth和sys_data_auth_detail 对应关系
|
|
|
+// if (ListUtil.isNotEmpty(serviceDataAuthIDS)) {
|
|
|
+// if (deleteServiceDataAuth(serviceDataAuthIDS)) {
|
|
|
+// return true;
|
|
|
+// } else {
|
|
|
+// Asserts.fail("数据权限与系统关系删除失败");
|
|
|
+// }
|
|
|
+// }
|
|
|
+ return true;
|
|
|
} else {
|
|
|
Asserts.fail("数据权限删除失败");
|
|
|
}
|
|
|
- return true;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -187,68 +188,78 @@ public class DataAuthManagementFacade {
|
|
|
dataAuth.setGmtCreate(DateUtil.now());
|
|
|
dataAuth.setCreator(SysUserUtils.getCurrentPrincipleId());
|
|
|
if (dataAuthFacade.save(dataAuth)) {
|
|
|
- //2.插入新建数据权限与系统的关系
|
|
|
- saveServiceDataAuth(addAuthVO.getAddDataAuthVO().getSoftwareVOS(), addAuthVO.getRoles(), dataAuth.getId());
|
|
|
+ //2.插入新建数据权限与系统的关系 sys_software_data_auth
|
|
|
+ return saveServiceDataAuth(addAuthVO.getAddDataAuthVO().getSoftwareVOS(), addAuthVO.getRoles(), dataAuth.getId());
|
|
|
} else {
|
|
|
Asserts.fail("数据权限插入失败");
|
|
|
}
|
|
|
- return true;
|
|
|
+ return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @Description插入新建数据权限与系统的关系
|
|
|
* @param softwareVOS
|
|
|
* @param roles
|
|
|
* @param dataAuthId
|
|
|
+ * @Description插入新建数据权限与系统的关系
|
|
|
* @Return void
|
|
|
*/
|
|
|
- private void saveServiceDataAuth(List<AddAuthSoftwareVO> softwareVOS, List<AddAuthRoleVO> roles, Long dataAuthId) {
|
|
|
-
|
|
|
- for (AddAuthSoftwareVO sysServiceVO : softwareVOS) {
|
|
|
- SoftwareDataAuth serviceDataAuth = new SoftwareDataAuth();
|
|
|
- serviceDataAuth.setSoftwareId(sysServiceVO.getId());
|
|
|
- serviceDataAuth.setDataAuthId(dataAuthId);
|
|
|
- serviceDataAuth.setGmtCreate(DateUtil.now());
|
|
|
- serviceDataAuth.setCreator("1");
|
|
|
- // serviceDataAuth.setCreator(Long.parseLong(SysUserUtils.getCurrentPrincipleID()));
|
|
|
- boolean serviceDataAuthInsert = softwareDataAuthFacade.save(serviceDataAuth);
|
|
|
- if (serviceDataAuthInsert) {
|
|
|
- //1.获取上一步插入时新生成的数据权限名称与系统关联编号service_data_auth _id
|
|
|
- Long serviceDataAuthId = softwareDataAuthFacade.list(new QueryWrapper<SoftwareDataAuth>()
|
|
|
- .eq("software_id", sysServiceVO.getId())
|
|
|
- .eq("data_auth_id", dataAuthId)
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())).get(0).getId();
|
|
|
-
|
|
|
+ private boolean saveServiceDataAuth(List<AddAuthSoftwareVO> softwareVOS, List<Long> roles, Long dataAuthId) {
|
|
|
+ AtomicBoolean out = new AtomicBoolean(false);
|
|
|
+ softwareVOS.stream().forEach(softwareVO->{
|
|
|
+ SoftwareDataAuth softwareDataAuth = new SoftwareDataAuth();
|
|
|
+ softwareDataAuth.setSoftwareId(softwareVO.getId());
|
|
|
+ softwareDataAuth.setDataAuthId(dataAuthId);
|
|
|
+ softwareDataAuth.setGmtCreate(DateUtil.now());
|
|
|
+ softwareDataAuth.setCreator(SysUserUtils.getCurrentPrincipleId()+"");
|
|
|
+ if (softwareDataAuthFacade.save(softwareDataAuth)) {
|
|
|
//2.插入数据权限系统关联表与角色管理sys_role_service_data_auth
|
|
|
- for (AddAuthRoleVO role : roles) {
|
|
|
+ List<RoleSoftwareDataAuth> roleSoftwareDataAuths = new ArrayList<>();
|
|
|
+ for (Long roleId : roles) {
|
|
|
RoleSoftwareDataAuth roleServiceDataAuth = new RoleSoftwareDataAuth();
|
|
|
- roleServiceDataAuth.setRoleId(role.getId());
|
|
|
- roleServiceDataAuth.setSoftwareDataAuthId(serviceDataAuthId);
|
|
|
+ roleServiceDataAuth.setRoleId(roleId);
|
|
|
+ roleServiceDataAuth.setSoftwareDataAuthId(softwareDataAuth.getId());
|
|
|
roleServiceDataAuth.setGmtCreate(DateUtil.now());
|
|
|
- roleServiceDataAuth.setCreator("1");
|
|
|
- // roleServiceDataAuth.setCreator(Long.parseLong(SysUserUtils.getCurrentPrincipleID()));
|
|
|
- if (!roleSoftwareDataAuthFacade.save(roleServiceDataAuth)) {
|
|
|
- Asserts.fail("角色对应服务数据权限关系插入失败");
|
|
|
- }
|
|
|
+ roleServiceDataAuth.setCreator(SysUserUtils.getCurrentPrincipleId());
|
|
|
+ roleSoftwareDataAuths.add(roleServiceDataAuth);
|
|
|
}
|
|
|
- //3.插入数据权限详细信息。sys_data_auth_detail
|
|
|
- for (DataAuthDetailVO dataAuthDetailVO : sysServiceVO.getDataAuthDetailVOS()) {
|
|
|
- DataAuthDetail dataAuthDetail = new DataAuthDetail();
|
|
|
- BeanUtils.copyProperties(dataAuthDetailVO, dataAuthDetail);
|
|
|
- // dataAuthDetail.setCreator(Long.parseLong(SysUserUtils.getCurrentPrincipleID()));
|
|
|
- dataAuthDetail.setGmtCreate(DateUtil.now());
|
|
|
- dataAuthDetail.setCreator("1");
|
|
|
- dataAuthDetail.setSoftwareDataAuthId(serviceDataAuthId);
|
|
|
- if (!dataAuthDetailFacade.save(dataAuthDetail)) {
|
|
|
- Asserts.fail("数据权限明细插入失败");
|
|
|
+ if (new RoleSoftwareDataAuthServiceImpl().saveBatch(roleSoftwareDataAuths)) {
|
|
|
+ //3.插入数据权限详细信息。sys_data_auth_detail
|
|
|
+ //自定义时
|
|
|
+ List<DataAuthDetail> dataAuthDetails = new ArrayList<>();
|
|
|
+ if (ListUtil.isNotEmpty(softwareVO.getDataAuthDetail().getDetailIds())
|
|
|
+ && softwareVO.getDataAuthDetail().getDetailType() != null) {
|
|
|
+ softwareVO.getDataAuthDetail().getDetailIds().stream().forEach(id -> {
|
|
|
+ DataAuthDetail dataAuthDetail = new DataAuthDetail();
|
|
|
+ BeanUtils.copyProperties(softwareVO.getDataAuthDetail(), dataAuthDetail);
|
|
|
+ dataAuthDetail.setGmtCreate(DateUtil.now());
|
|
|
+ dataAuthDetail.setCreator(SysUserUtils.getCurrentPrincipleId() + "");
|
|
|
+ dataAuthDetail.setSoftwareDataAuthId(softwareDataAuth.getId());
|
|
|
+ dataAuthDetail.setDetailId(id);
|
|
|
+ dataAuthDetails.add(dataAuthDetail);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ DataAuthDetail dataAuthDetail = new DataAuthDetail();
|
|
|
+ BeanUtils.copyProperties(softwareVO.getDataAuthDetail(), dataAuthDetail);
|
|
|
+ dataAuthDetail.setGmtCreate(DateUtil.now());
|
|
|
+ dataAuthDetail.setCreator(SysUserUtils.getCurrentPrincipleId() + "");
|
|
|
+ dataAuthDetail.setSoftwareDataAuthId(softwareDataAuth.getId());
|
|
|
+ dataAuthDetails.add(dataAuthDetail);
|
|
|
+ }
|
|
|
+ if(new DataAuthDetailServiceImpl().saveBatch(dataAuthDetails)){
|
|
|
+ out.set(true);
|
|
|
+ }else {
|
|
|
+ Asserts.fail("数据权限详情插入失败");
|
|
|
}
|
|
|
+ } else {
|
|
|
+ Asserts.fail("角色对应服务数据权限关系插入失败");
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
Asserts.fail("服务对应数据权限关系插入失败");
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
+ return out.get();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -318,8 +329,8 @@ public class DataAuthManagementFacade {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @Description 获取组织-科室信息以及自定义科室
|
|
|
* @param dataAuthDetailDTO
|
|
|
+ * @Description 获取组织-科室信息以及自定义科室
|
|
|
* @Return void
|
|
|
*/
|
|
|
public void getDeptDetial(DataAuthDetailDTO dataAuthDetailDTO) {
|
|
@@ -340,9 +351,9 @@ public class DataAuthManagementFacade {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @Description取对应医院的科室信息
|
|
|
* @param hospitalDTO
|
|
|
* @param dataAuthDetailDTO
|
|
|
+ * @Description取对应医院的科室信息
|
|
|
* @Return void
|
|
|
*/
|
|
|
private void getDeptInfo(HospitalDTO hospitalDTO, DataAuthDetailDTO dataAuthDetailDTO) {
|
|
@@ -377,8 +388,8 @@ public class DataAuthManagementFacade {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @Description 获取医院对应的子医院信息
|
|
|
* @param hospitalDTOS
|
|
|
+ * @Description 获取医院对应的子医院信息
|
|
|
* @Return void
|
|
|
*/
|
|
|
private void getAllHospitalDTO(List<HospitalDTO> hospitalDTOS) {
|