linwe
2024-05-16 afda600cf257b5a0eb6ae099a80282d21f971958
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
42
<?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
            code,
            name AS title,
            code AS "value",
            code AS "key",
            parent_code
        FROM
            ( SELECT * FROM jczz_issue_clazz ORDER BY parent_code, code )
                org_query,
            ( SELECT @id := 10 ) initialisation
        WHERE
            (FIND_IN_SET( parent_code, @id ) > 0 or FIND_IN_SET( code, @id ) > 0)
          AND @id := CONCAT(@id,',',code)
 
    </select>
 
 
</mapper>