@@ -43,4 +43,21 @@ public interface SharePathMapper extends BaseMapperX<SharePathDO> {
// 添加节点及其子节点的新祖先关系
void addNewAncestors(@Param("nodeId") Long nodeId, @Param("newParentId") Long newParentId);
-}
+
+ // 查询该节点的所有子节点信息
+ List<Long> findAllDescendants(@Param("ancestorId") Long ancestorId);
+ // 查询该节点的顺序号小于该节点兄弟节点
+ List<Long> findLessSortedSiblings(@Param("descendantId") Long descendantId);
+}
@@ -58,4 +58,20 @@
UNION ALL
SELECT #{nodeId} as ancestor, descendant, depth + 1, 0 FROM distri_share_path WHERE ancestor = #{nodeId};
</insert>
+ <!-- 查询某节点的所有后代节点 -->
+ <select id="findAllDescendants" resultType="long">
+ SELECT descendant
+ FROM distri_share_path
+ WHERE ancestor = #{ancestorId}
+ </select>
+ <!-- 查询排序号小于当前节点的兄弟节点 -->
+ <select id="findLessSortedSiblings" resultType="long">
+ SELECT a.descendant
+ FROM distri_share_path a
+ JOIN distri_share_path b ON a.ancestor = b.ancestor
+ WHERE b.descendant = #{descendantId} AND a.sort < b.sort
</mapper>
@@ -3,7 +3,7 @@ spring:
name: feifan-server
profiles:
- active: pro
+ active: local
main:
allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。