zhaowenxuan
2025-07-02 c01d278ca57650e57c235f96ab448292653db024
ltkj-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -396,5 +396,18 @@
              )}
    </select>
    <select id="getDeptTreeById" resultType="java.lang.Long">
        WITH RECURSIVE dept_tree AS (
            SELECT dept_id
            FROM sys_dept
            WHERE dept_id = #{deptId}
            UNION ALL
            SELECT d.dept_id
            FROM sys_dept d
                     INNER JOIN dept_tree dt ON d.parent_id = dt.dept_id
        )
        SELECT dept_id FROM dept_tree;
    </select>
</mapper>