From cc9523d8c5a0ccd5c48774971a6ed001847f1d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Mon, 24 Sep 2018 11:40:09 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=20BUG.=20=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E6=A0=91=E4=BF=AE=E6=94=B9=E5=85=B3=E7=B3=BB=E8=A1=A8?= =?UTF-8?q?=E7=BB=B4=E6=8A=A4bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pigx/admin/mapper/SysDeptMapper.java | 7 ---- .../admin/mapper/SysDeptRelationMapper.java | 12 ++++++ .../service/impl/SysDeptServiceImpl.java | 11 +++--- .../main/resources/mapper/SysDeptMapper.xml | 19 ---------- .../mapper/SysDeptRelationMapper.xml | 37 +++++++++++++++++++ pom.xml | 2 +- 6 files changed, 56 insertions(+), 32 deletions(-) diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java index 9f7b12ff4..4ac7d3b8e 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java @@ -41,11 +41,4 @@ public interface SysDeptMapper extends BaseMapper { * @return 数据列表 */ List selectDeptDtoList(String delFlag); - - /** - * 删除部门关系表数据 - * - * @param id 部门ID - */ - void deleteDeptRealtion(Integer id); } 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 069c66bc4..cdbfb3bcd 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 @@ -31,5 +31,17 @@ import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation; * @since 2018-02-12 */ public interface SysDeptRelationMapper extends BaseMapper { + /** + * 删除部门关系表数据 + * + * @param id 部门ID + */ + void deleteAllDeptRealtion(Integer id); + /** + * 更改部分关系表数据 + * + * @param deptRelation + */ + void updateDeptRealtion(SysDeptRelation deptRelation); } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java index 62159c7a1..7f6ba9e81 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java @@ -100,7 +100,7 @@ public class SysDeptServiceImpl extends ServiceImpl impl sysDept.setUpdateTime(LocalDateTime.now()); sysDept.setDelFlag(CommonConstant.STATUS_DEL); this.deleteById(sysDept); - sysDeptMapper.deleteDeptRealtion(id); + sysDeptRelationMapper.deleteAllDeptRealtion(id); return Boolean.TRUE; } @@ -114,10 +114,11 @@ public class SysDeptServiceImpl extends ServiceImpl impl public Boolean updateDeptById(SysDept sysDept) { //更新部门状态 this.updateById(sysDept); - //删除部门关系 - sysDeptMapper.deleteDeptRealtion(sysDept.getDeptId()); - //新建部门关系 - this.insertDeptRelation(sysDept); + //更新部门关系 + SysDeptRelation relation = new SysDeptRelation(); + relation.setAncestor(sysDept.getParentId()); + relation.setDescendant(sysDept.getDeptId()); + sysDeptRelationMapper.updateDeptRealtion(relation); return Boolean.TRUE; } diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml index fdd683274..ecda851c6 100644 --- a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml @@ -35,25 +35,6 @@ dept_id AS deptId, parent_id AS parentId, name, order_num AS orderNum, create_time AS createTime, update_time AS updateTime, del_flag AS delFlag - - DELETE - FROM - sys_dept_relation - WHERE - descendant IN ( - SELECT - temp.descendant - FROM - ( - SELECT - descendant - FROM - sys_dept_relation - WHERE - ancestor = #{id} - ) temp - ) -