diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysDeptMapper.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysDeptMapper.java index 1491b33b..03c74d3b 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysDeptMapper.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysDeptMapper.java @@ -39,10 +39,4 @@ public interface SysDeptMapper extends BaseMapper { * @return 数据列表 */ List selectDeptDtoList(String delFlag); - - /** - * 删除部门关系表数据 - * @param id 部门ID - */ - void deleteDeptRealtion(Integer id); } \ No newline at end of file diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysDeptRelationMapper.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysDeptRelationMapper.java index 1750b227..10c79daf 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysDeptRelationMapper.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysDeptRelationMapper.java @@ -29,5 +29,17 @@ import com.github.pig.admin.model.entity.SysDeptRelation; * @since 2018-02-12 */ public interface SysDeptRelationMapper extends BaseMapper { + /** + * 删除部门关系表数据 + * + * @param id 部门ID + */ + void deleteAllDeptRealtion(Integer id); + /** + * 更改部分关系表数据 + * + * @param deptRelation + */ + void updateDeptRealtion(SysDeptRelation deptRelation); } \ No newline at end of file diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysDeptServiceImpl.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysDeptServiceImpl.java index b8ed9929..abe8672d 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysDeptServiceImpl.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysDeptServiceImpl.java @@ -98,7 +98,7 @@ public class SysDeptServiceImpl extends ServiceImpl impl sysDept.setUpdateTime(new Date()); sysDept.setDelFlag(CommonConstant.STATUS_DEL); this.deleteById(sysDept); - sysDeptMapper.deleteDeptRealtion(id); + sysDeptRelationMapper.deleteAllDeptRealtion(id); return Boolean.TRUE; } @@ -112,10 +112,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 null; } diff --git a/pig-modules/pig-upms-service/src/main/resources/mapper/SysDeptMapper.xml b/pig-modules/pig-upms-service/src/main/resources/mapper/SysDeptMapper.xml index 196c91c4..80d01c78 100644 --- a/pig-modules/pig-upms-service/src/main/resources/mapper/SysDeptMapper.xml +++ b/pig-modules/pig-upms-service/src/main/resources/mapper/SysDeptMapper.xml @@ -33,25 +33,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 - ) -