linwe
2024-05-29 c10d6358b9f014375a13821465bc978d0c0da22e
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
37
38
39
40
41
<?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="org.springblade.modules.issueClazz.mapper.IssueClazzMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="issueClazzResultMap" type="org.springblade.modules.issueClazz.entity.IssueClazzEntity">
    </resultMap>
 
 
    <select id="selectIssueClazzPage" resultMap="issueClazzResultMap">
        select * from jczz_issue_clazz where is_deleted = 0
    </select>
 
    <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
        <id column="id" property="id"/>
<!--        <result column="parent_id" property="parentId"/>-->
        <result column="title" property="title"/>
        <result column="value" property="value"/>
        <result column="key" property="key"/>
        <result column="has_children" property="hasChildren"/>
    </resultMap>
 
 
    <select id="tree" resultMap="treeNodeResultMap">
        SELECT
            id,
            NAME AS title,
            id AS "value",
            id AS "key",
            parentId
        FROM
            ( SELECT CODE id, NAME, parent_code parentId FROM jczz_issue_clazz ORDER BY parentId, id ) org_query,
            ( SELECT @id := '10' ) initialisation
        WHERE
            ( FIND_IN_SET( parentId, @id ) > 0 OR FIND_IN_SET( id, @id ) > 0 )
          AND @id := CONCAT( @id, ',', id)
 
    </select>
 
 
</mapper>