mirror of https://gitee.com/topiam/eiam
fix: 【eiam-console】账户管理/组织与用户页面,移动组织节点到其它节点后,判断并修改组织节点移动前的父节点是否为叶子节点
parent
9646438a87
commit
6794c7c1ec
|
@ -19,6 +19,7 @@ package cn.topiam.employee.console.service.account.impl;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import liquibase.pro.packaged.L;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -256,6 +257,7 @@ public class OrganizationServiceImpl implements OrganizationService {
|
||||||
Optional<OrganizationEntity> organization = organizationRepository.findById(id);
|
Optional<OrganizationEntity> organization = organizationRepository.findById(id);
|
||||||
if (organization.isPresent()) {
|
if (organization.isPresent()) {
|
||||||
OrganizationEntity entity = organization.get();
|
OrganizationEntity entity = organization.get();
|
||||||
|
String oldParentId = entity.getParentId();
|
||||||
Optional<OrganizationEntity> parent = organizationRepository.findById(parentId);
|
Optional<OrganizationEntity> parent = organizationRepository.findById(parentId);
|
||||||
if (parent.isPresent()) {
|
if (parent.isPresent()) {
|
||||||
if (parent.get().getLeaf()) {
|
if (parent.get().getLeaf()) {
|
||||||
|
@ -270,12 +272,16 @@ public class OrganizationServiceImpl implements OrganizationService {
|
||||||
entity.setDisplayPath(StringUtils.defaultString(parent.get().getDisplayPath())
|
entity.setDisplayPath(StringUtils.defaultString(parent.get().getDisplayPath())
|
||||||
+ SEPARATE + entity.getName());
|
+ SEPARATE + entity.getName());
|
||||||
}
|
}
|
||||||
// 判断当前节点下是否还存在子节点,不存在更改此节点为叶子节点
|
|
||||||
List<OrganizationEntity> childList = organizationRepository.findByParentId(id);
|
|
||||||
if (CollectionUtils.isEmpty(childList)) {
|
|
||||||
entity.setLeaf(true);
|
|
||||||
}
|
|
||||||
organizationRepository.save(entity);
|
organizationRepository.save(entity);
|
||||||
|
// 判断旧的父节点下是否还存在子节点,不存在更改此节点为叶子节点
|
||||||
|
List<OrganizationEntity> childList = organizationRepository.findByParentId(oldParentId);
|
||||||
|
if (CollectionUtils.isEmpty(childList)) {
|
||||||
|
Optional<OrganizationEntity> oldParentOrganization = organizationRepository.findById(oldParentId);
|
||||||
|
if (oldParentOrganization.isPresent()) {
|
||||||
|
oldParentOrganization.get().setLeaf(true);
|
||||||
|
organizationRepository.save(oldParentOrganization.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
//存在子组织,递归更改子组织 path 和 displayPath
|
//存在子组织,递归更改子组织 path 和 displayPath
|
||||||
recursiveUpdateChildNodePathAndDisplayPath(entity.getId());
|
recursiveUpdateChildNodePathAndDisplayPath(entity.getId());
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue