Commit b12263f3 authored by fangxinjiang's avatar fangxinjiang

代码优化-fxj

parent 992d316a
......@@ -103,5 +103,8 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
List<SysDept> cspDelDeptIds(@Param("projectNo") String projectNo);
void updateAllAncestors(@Param("projectNo")String projectNo, @Param("oldStr")String oldStr, @Param("newStr")String newStr);
void updateAllAncestors(@Param("projectNo")String projectNo,
@Param("oldStr")String oldStr,
@Param("newStr")String newStr,
@Param("deptId")String deptId);
}
......@@ -630,8 +630,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
String newStr = parentDept.getAncestors()+","+parentDept.getDeptId();
updateEntity.setParentId(parentDept.getDeptId());
updateEntity.setAncestors(parentDept.getAncestors()+","+parentDept.getDeptId());
baseMapper.updateById(updateEntity);
baseMapper.updateAllAncestors(parentDept.getProjectNo(),oldStr,newStr);
int res = baseMapper.updateById(updateEntity);
if (res > 0){
baseMapper.updateAllAncestors(parentDept.getProjectNo(),oldStr,newStr,updateEntity.getDeptId());
}
List<DeptSortVo> moveVos = dept.getDeptSortList();
baseMapper.batchUpdateSort(moveVos);
......
......@@ -177,7 +177,8 @@
</select>
<update id="updateAllAncestors">
update sys_dept set ancestors = REPLACE(ancestors,#{oldStr},#{newStr}) where project_no = #{projectNo} and ancestors like concat(#{oldStr},',', '%')
update sys_dept set ancestors = REPLACE(ancestors,#{oldStr},#{newStr})
where project_no = #{projectNo} and ancestors like concat(#{oldStr},',', '%') and dept_id != #{deptId}
</update>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment