<?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.system.mapper.SysDictDataMapper">

    <resultMap type="SysDictData" id="SysDictDataResult">
        <id property="dictCode" column="dict_code"/>
        <result property="dictSort" column="dict_sort"/>
        <result property="dictLabel" column="dict_label"/>
        <result property="dictValue" column="dict_value"/>
        <result property="dictType" column="dict_type"/>
        <result property="cssClass" column="css_class"/>
        <result property="listClass" column="list_class"/>
        <result property="isDefault" column="is_default"/>
        <result property="status" column="status"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <select id="queryValueTextByKey" resultType="java.lang.String">
        select s.dict_value from sys_dict_data s where s.dict_type = #{code} and s.dict_label = #{key}
    </select>


    <select id="dictList" resultType="java.util.Map">
        select
        t.label,
        t.value,
        t.enginClassification,
        t.enginType,

        CONCAT_WS('/', (SELECT dict_name from sys_dict_type WHERE dict_type = t.enginType), (SELECT dict_name from sys_dict_type WHERE dict_type = t.enginClassification), t.label) AS name


        from (
        SELECT
        dict_label as label,
        dict_value as value,
        dict_type as enginClassification,
        'old_renovation' as enginType
        FROM
        sys_dict_data
        WHERE
        dict_type = 'old_renovation_indoor_engin' UNION ALL
        SELECT
        dict_label as label,
        dict_value as value,
        dict_type as enginClassification,
        'old_renovation' as enginType
        FROM
        sys_dict_data
        WHERE
        dict_type = 'old_renovation_courtyard_engin' UNION ALL
        SELECT
        dict_label as label,
        dict_value as value,
        dict_type as enginClassification,
        'old_renovation' as enginType
        FROM
        sys_dict_data
        WHERE
        dict_type = 'old_renovation_overhead' UNION ALL
        SELECT
        dict_label as label,
        dict_value as value,
        dict_type as enginClassification,
        'new_built' as enginType
        FROM
        sys_dict_data
        WHERE
        dict_type = 'new_built_indoor_engin' UNION ALL
        SELECT
        dict_label as label,
        dict_value as value,
        dict_type as enginClassification,
        'new_built' as enginType
        FROM
        sys_dict_data
        WHERE
        dict_type = 'new_built_courtyard' UNION ALL
        SELECT
        dict_label as label,
        dict_value as value,
        dict_type as enginClassification,
        'new_built' as enginType
        FROM
        sys_dict_data
        WHERE
        dict_type = 'new_built_overhead'
        UNION ALL
        SELECT
        dict_label as label,
        dict_value as value,
        dict_type as enginClassification,
        'pipe_jack' as enginType
        FROM
        sys_dict_data
        WHERE
        dict_type = 'pipe_jack'
        UNION ALL
        SELECT
        dict_label as label,
        dict_value as value,
        dict_type as enginClassification,
        'engineering_infrastructure' as enginType
        FROM
        sys_dict_data
        WHERE
        dict_type = 'engineering_infrastructure'
        ) as t where 1=1
        <if test="enginType != null and enginType.length > 0">
            and t.enginType in
            <foreach item="item" index="index" collection="enginType" open="(" separator="," close=")">
                #{item}
            </foreach>

        </if>
    </select>
</mapper>
