liding
3 天以前 49e1bc66ebaf696ebd3fc3ed33d65c8795fd3cde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.business.mapper.TreeMapper">
 
        <!-- 通用查询映射结果 -->
        <resultMap id="BaseResultMap" type="com.ruoyi.business.entity.Tree">
                    <id column="id" property="id" />
                <result column="deleted" property="deleted" />
                <result column="create_by" property="createBy" />
                <result column="create_time" property="createTime" />
                <result column="update_by" property="updateBy" />
                <result column="update_time" property="updateTime" />
                    <result column="name" property="name" />
                    <result column="parent_id" property="parentId" />
        </resultMap>
 
        <!-- 通用查询结果列 -->
        <sql id="Base_Column_List">
                deleted,
                create_by,
                create_time,
                update_by,
                update_time,
            id, name, parent_id
        </sql>
    <select id="listRecursiveSubNodeIds" resultType="java.lang.Long">
        WITH RECURSIVE sub_nodes AS (
            SELECT id FROM tree WHERE parent_id = #{treeId}
            UNION ALL
            SELECT t.id FROM tree t
                                 JOIN sub_nodes s ON t.parent_id = s.id
        )
        SELECT id FROM sub_nodes
    </select>
 
</mapper>