mirror of https://gitee.com/xiaonuobase/snowy
commit
d27d349b06
|
@ -56,7 +56,7 @@ public enum SysOrgExceptionEnum implements AbstractBaseExceptionEnum {
|
|||
/**
|
||||
* 该机构下有员工
|
||||
*/
|
||||
ORG_CANNOT_DELETE(4, "该机构下有员工,无法删除"),
|
||||
ORG_CANNOT_DELETE(4, "该机构或子机构下有员工,无法删除"),
|
||||
|
||||
/**
|
||||
* 父节点不能和本节点一致,请重新选择父节点
|
||||
|
|
|
@ -206,31 +206,35 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|||
SysOrg sysOrg = this.querySysOrg(sysOrgParam);
|
||||
Long id = sysOrg.getId();
|
||||
boolean superAdmin = LoginContextHolder.me().isSuperAdmin();
|
||||
|
||||
// 级联删除子节点
|
||||
List<Long> childIdList = this.getChildIdListById(id);
|
||||
childIdList.add(id);
|
||||
|
||||
childIdList.forEach(item ->{
|
||||
if (!superAdmin) {
|
||||
List<Long> dataScope = LoginContextHolder.me().getLoginUserDataScopeIdList();
|
||||
//数据范围为空
|
||||
if (ObjectUtil.isEmpty(dataScope)) {
|
||||
throw new PermissionException(PermissionExceptionEnum.NO_PERMISSION_OPERATE);
|
||||
} else if (!dataScope.contains(id)) {
|
||||
} else if (!dataScope.contains(item)) {
|
||||
//所操作的数据不在自己的数据范围内
|
||||
throw new PermissionException(PermissionExceptionEnum.NO_PERMISSION_OPERATE);
|
||||
}
|
||||
}
|
||||
// 该机构下有员工,则不能删
|
||||
boolean hasOrgEmp = sysEmpService.hasOrgEmp(id);
|
||||
boolean hasOrgEmp = sysEmpService.hasOrgEmp(item);
|
||||
if (hasOrgEmp) {
|
||||
throw new ServiceException(SysOrgExceptionEnum.ORG_CANNOT_DELETE);
|
||||
}
|
||||
|
||||
// 该附属机构下若有员工,则不能删除
|
||||
boolean hasExtOrgEmp = sysEmpExtOrgPosService.hasExtOrgEmp(id);
|
||||
boolean hasExtOrgEmp = sysEmpExtOrgPosService.hasExtOrgEmp(item);
|
||||
if (hasExtOrgEmp) {
|
||||
throw new ServiceException(SysOrgExceptionEnum.ORG_CANNOT_DELETE);
|
||||
}
|
||||
});
|
||||
|
||||
// 级联删除子节点
|
||||
List<Long> childIdList = this.getChildIdListById(id);
|
||||
childIdList.add(id);
|
||||
LambdaUpdateWrapper<SysOrg> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.in(SysOrg::getId, childIdList)
|
||||
.set(SysOrg::getStatus, CommonStatusEnum.DELETED.getCode());
|
||||
|
|
Loading…
Reference in New Issue