zhaowenxuan
2025-07-15 6a4e3a5c4c34fdef0accc93d8a077ab016d15250
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>