From 6794c7c1ec3920093dba71c75792d604d071b57b Mon Sep 17 00:00:00 2001 From: zeb <936152864@qq.com> Date: Sun, 18 Dec 2022 19:10:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=80=90eiam-console=E3=80=91=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E7=AE=A1=E7=90=86/=E7=BB=84=E7=BB=87=E4=B8=8E?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=A1=B5=E9=9D=A2=EF=BC=8C=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E8=8A=82=E7=82=B9=E5=88=B0=E5=85=B6=E5=AE=83?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=90=8E=EF=BC=8C=E5=88=A4=E6=96=AD=E5=B9=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=84=E7=BB=87=E8=8A=82=E7=82=B9=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E5=89=8D=E7=9A=84=E7=88=B6=E8=8A=82=E7=82=B9=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E4=B8=BA=E5=8F=B6=E5=AD=90=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/impl/OrganizationServiceImpl.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/service/account/impl/OrganizationServiceImpl.java b/eiam-console/src/main/java/cn/topiam/employee/console/service/account/impl/OrganizationServiceImpl.java index 5b303234..f8318823 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/service/account/impl/OrganizationServiceImpl.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/service/account/impl/OrganizationServiceImpl.java @@ -19,6 +19,7 @@ package cn.topiam.employee.console.service.account.impl; import java.util.*; +import liquibase.pro.packaged.L; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -256,6 +257,7 @@ public class OrganizationServiceImpl implements OrganizationService { Optional organization = organizationRepository.findById(id); if (organization.isPresent()) { OrganizationEntity entity = organization.get(); + String oldParentId = entity.getParentId(); Optional parent = organizationRepository.findById(parentId); if (parent.isPresent()) { if (parent.get().getLeaf()) { @@ -270,12 +272,16 @@ public class OrganizationServiceImpl implements OrganizationService { entity.setDisplayPath(StringUtils.defaultString(parent.get().getDisplayPath()) + SEPARATE + entity.getName()); } - // 判断当前节点下是否还存在子节点,不存在更改此节点为叶子节点 - List childList = organizationRepository.findByParentId(id); - if (CollectionUtils.isEmpty(childList)) { - entity.setLeaf(true); - } organizationRepository.save(entity); + // 判断旧的父节点下是否还存在子节点,不存在更改此节点为叶子节点 + List childList = organizationRepository.findByParentId(oldParentId); + if (CollectionUtils.isEmpty(childList)) { + Optional oldParentOrganization = organizationRepository.findById(oldParentId); + if (oldParentOrganization.isPresent()) { + oldParentOrganization.get().setLeaf(true); + organizationRepository.save(oldParentOrganization.get()); + } + } //存在子组织,递归更改子组织 path 和 displayPath recursiveUpdateChildNodePathAndDisplayPath(entity.getId()); return true;