zhanghua
2023-09-08 7ef4892f9f24f941aca37e6b3991b808a0aca619
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?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.ycl.mapper.dict.DataDictionaryMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.entity.dict.DataDictionary">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="code" property="code"/>
        <result column="type_name" property="typeName"/>
        <result column="type_code" property="typeCode"/>
        <result column="parent_id" property="parentId"/>
        <result column="level" property="level"/>
        <result column="remark" property="remark"/>
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id
        , name, code, type_name,type_code,parent_id,level,remark
    </sql>
 
    <resultMap id="settingsResultMap" type="com.ycl.vo.IllegalBuildingSettingVO">
        <id column="number" property="number"/>
        <result column="type" property="type"/>
        <result column="typeFirst" property="typeFirst"/>
        <result column="typeSecond" property="typeSecond"/>
        <result column="typeThird" property="typeThird"/>
    </resultMap>
 
    <resultMap id="VoMap" type="com.ycl.vo.dict.DataDictionaryVo" extends="BaseResultMap">
        <collection property="children" javaType="ArrayList" ofType="com.ycl.entity.dict.DataDictionary">
            <result column="c_id" property="id"/>
            <result column="c_name" property="name"/>
            <result column="c_code" property="code"/>
            <result column="c_level" property="level"/>
            <result column="c_remark" property="remark"/>
        </collection>
    </resultMap>
 
    <select id="listDataDictionaryPage" resultType="com.ycl.vo.IllegalBuildingSettingVO">
        SELECT
        d1.id AS number,
        d1.`name` AS type,
        d2.`name` AS typeFirst
        FROM
        `ums_data_dictionary` AS d1
        JOIN ums_data_dictionary AS d2 ON d1.parent_id = d2.id
        <where>
            d1.`level` = '2'
            AND d1.type_code = '06'
            <if test="keyWord !=null and keyWord !=''">
                AND (d1.`name` LIKE '%${keyWord}%'
                or d2.`name` LIKE '%${keyWord}%')
                or d2.`name` LIKE '%${keyWord}%')
            </if>
 
        </where>
    </select>
 
    <select id="listViolationPage" resultType="com.ycl.vo.ViolationSettingVO">
        SELECT
        d1.id AS number,
        d1.`name` AS type,
        d2.`name` AS typeFirst,
        d3.`name` AS typeSecond,
        d4.`name` AS typeThird
        FROM `ums_data_dictionary` AS d1
        LEFT JOIN ums_data_dictionary AS d2 ON d1.parent_id = d2.id
        LEFT JOIN ums_data_dictionary AS d3 ON d2.parent_id = d3.id
        LEFT JOIN ums_data_dictionary AS d4 ON d3.parent_id = d4.id
        <where>
            d1.`level` = '4'
            AND d1.type_code = '01'
            <if test="keyWord !=null and keyWord !=''">
                AND (d1.`name` LIKE '%${keyWord}%'
                or d2.`name` LIKE '%${keyWord}%'
                or d3.`name` LIKE '%${keyWord}%'
                or d4.`name` LIKE '%${keyWord}%'
                )
            </if>
 
        </where>
 
        ORDER BY d1.parent_id,d2.parent_id,d3.parent_id,d4.parent_id
    </select>
 
    <select id="queryTreeType" resultMap="VoMap">
        SELECT p.*, c.id c_id, c.`name` c_name, c.`code` c_code, c.`level` c_level, c.remark c_remark
        FROM ums_data_dictionary p
                 LEFT JOIN ums_data_dictionary c on p.id = c.parent_id
        WHERE p.`type_code` = #{typeCode}
          and p.`level` = #{level}
        ORDER BY p.id, c.id
    </select>
 
</mapper>