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 - ) -