From 97f65558417c1d9505abdd5b39c5e282b84a0381 Mon Sep 17 00:00:00 2001 From: lbw Date: Thu, 16 Dec 2021 09:56:53 +0800 Subject: [PATCH] =?UTF-8?q?:card=5Ffile=5Fbox:=20=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9B=B8=E5=85=B3=E7=9A=84=E5=8F=98?= =?UTF-8?q?=E5=8C=96=20close=20#3457=20=E3=80=90=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91=E6=9B=B4=E6=96=B0=E9=83=A8=E9=97=A8=E5=85=B3=E7=B3=BB?= =?UTF-8?q?SQL=20=E6=8B=86=E5=88=86=E4=B8=BA=E5=A4=9A=E4=B8=AASQL=20?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=EF=BC=8C=E6=8F=90=E9=AB=98=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E5=85=BC=E5=AE=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pigx-gateway/src/main/resources/bootstrap.yml | 2 +- .../admin/mapper/SysDeptRelationMapper.java | 16 ++-- .../impl/SysDeptRelationServiceImpl.java | 6 +- .../mapper/SysDeptRelationMapper.xml | 76 +++++++++---------- 4 files changed, 50 insertions(+), 50 deletions(-) diff --git a/pigx-gateway/src/main/resources/bootstrap.yml b/pigx-gateway/src/main/resources/bootstrap.yml index 83045b213..afd6b6fa2 100644 --- a/pigx-gateway/src/main/resources/bootstrap.yml +++ b/pigx-gateway/src/main/resources/bootstrap.yml @@ -14,4 +14,4 @@ spring: shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} profiles: - active: @profiles.active@ \ No newline at end of file + active: @profiles.active@ diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java index 85637841f..9250bb62e 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java @@ -35,15 +35,21 @@ import org.apache.ibatis.annotations.Mapper; public interface SysDeptRelationMapper extends PigxBaseMapper { /** - * 删除部门关系表数据 + * 删除部门 > 删除所有关联此部门子节点的闭包关系 * @param id 部门ID */ - void deleteDeptRelationsById(Long id); + void deleteDeptRelationsByDeptId(Long id); /** - * 更改部分关系表数据 - * @param deptRelation + * 删除节点数据 + * @param deptRelation 关系节点 */ - void updateDeptRelations(SysDeptRelation deptRelation); + void deleteDeptRelations(SysDeptRelation deptRelation); + + /** + * 新增节点数据 + * @param deptRelation 关系节点 + */ + void insertDeptRelations(SysDeptRelation deptRelation); } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptRelationServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptRelationServiceImpl.java index 70209d9a8..4e7dd22b2 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptRelationServiceImpl.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptRelationServiceImpl.java @@ -79,7 +79,7 @@ public class SysDeptRelationServiceImpl extends ServiceImpl - - - - - - - - - ancestor, descendant - - - - - DELETE FROM sys_dept_relation - WHERE - descendant IN ( SELECT temp.descendant FROM - ( SELECT descendant FROM sys_dept_relation WHERE ancestor = #{descendant} ) temp ) - AND ancestor IN ( SELECT temp.ancestor FROM ( SELECT ancestor FROM - sys_dept_relation WHERE descendant = #{descendant} AND ancestor != descendant ) temp ); + + + DELETE FROM sys_dept_relation + WHERE + descendant IN ( SELECT temp.descendant FROM + ( SELECT descendant FROM sys_dept_relation WHERE ancestor = #{descendant} ) temp ) + AND ancestor IN ( SELECT temp.ancestor FROM ( SELECT ancestor FROM + sys_dept_relation WHERE descendant = #{descendant} AND ancestor != descendant ) temp ) + + + INSERT INTO sys_dept_relation (ancestor, descendant) SELECT a.ancestor, b.descendant FROM sys_dept_relation a - CROSS JOIN sys_dept_relation b + CROSS JOIN sys_dept_relation b WHERE a.descendant = #{ancestor} - AND b.ancestor = #{descendant}; - + AND b.ancestor = #{descendant} + - - - DELETE - FROM - sys_dept_relation - WHERE - descendant IN ( - SELECT - temp.descendant - FROM - ( - SELECT - descendant - FROM - sys_dept_relation - WHERE - ancestor = #{id} - ) temp - ) - + + + DELETE + FROM + sys_dept_relation + WHERE + descendant IN ( + SELECT + temp.descendant + FROM + ( + SELECT + descendant + FROM + sys_dept_relation + WHERE + ancestor = #{id} + ) temp + ) +