<?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.interfaces.mapper.MdDataSetMapper">

    <resultMap type="com.ruoyi.interfaces.domain.MdDataSet" id="MdDataSetResult">
        <result property="dsCode"    column="DS_CODE"    />
        <result property="cateId"    column="CATE_ID"    />
        <result property="dsName"    column="DS_NAME"    />
        <result property="dsType"    column="DS_TYPE"    />
        <result property="dsSort"    column="DS_SORT"    />
        <result property="dsIcon"    column="DS_ICON"    />
        <result property="dsNote"    column="DS_NOTE"    />
    </resultMap>

    <sql id="selectMdDataSetVo">
        select DS_CODE, CATE_ID, DS_NAME, DS_TYPE, DS_SORT, DS_ICON, DS_NOTE from md_data_set
    </sql>

    <select id="selectMdDataSetList" parameterType="com.ruoyi.interfaces.domain.MdDataSet" resultMap="MdDataSetResult">
        <include refid="selectMdDataSetVo"/>
        <where>
            <if test="dsName != null  and dsName != ''"> and DS_NAME like concat('%', #{dsName}, '%')</if>
            <if test="dsType != null  and dsType != ''"> and DS_TYPE = #{dsType}</if>
            <if test="dsSort != null "> and DS_SORT = #{dsSort}</if>
            <if test="dsIcon != null  and dsIcon != ''"> and DS_ICON = #{dsIcon}</if>
            <if test="dsNote != null  and dsNote != ''"> and DS_NOTE = #{dsNote}</if>
        </where>
        order by DS_SORT
    </select>

    <select id="selectMdDataSetByDsCode" parameterType="String" resultMap="MdDataSetResult">
        <include refid="selectMdDataSetVo"/>
        where DS_CODE = #{dsCode}
    </select>

    <insert id="insertMdDataSet" parameterType="com.ruoyi.interfaces.domain.MdDataSet">
        insert into md_data_set
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dsCode != null">DS_CODE,</if>
            <if test="cateId != null">CATE_ID,</if>
            <if test="dsName != null">DS_NAME,</if>
            <if test="dsType != null">DS_TYPE,</if>
            <if test="dsSort != null">DS_SORT,</if>
            <if test="dsIcon != null">DS_ICON,</if>
            <if test="dsNote != null">DS_NOTE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dsCode != null">#{dsCode},</if>
            <if test="cateId != null">#{cateId},</if>
            <if test="dsName != null">#{dsName},</if>
            <if test="dsType != null">#{dsType},</if>
            <if test="dsSort != null">#{dsSort},</if>
            <if test="dsIcon != null">#{dsIcon},</if>
            <if test="dsNote != null">#{dsNote},</if>
        </trim>
    </insert>

    <update id="updateMdDataSet" parameterType="com.ruoyi.interfaces.domain.MdDataSet">
        update md_data_set
        <trim prefix="SET" suffixOverrides=",">
            <if test="cateId != null">CATE_ID = #{cateId},</if>
            <if test="dsName != null">DS_NAME = #{dsName},</if>
            <if test="dsType != null">DS_TYPE = #{dsType},</if>
            <if test="dsSort != null">DS_SORT = #{dsSort},</if>
            <if test="dsIcon != null">DS_ICON = #{dsIcon},</if>
            <if test="dsNote != null">DS_NOTE = #{dsNote},</if>
        </trim>
        where DS_CODE = #{dsCode}
    </update>

    <delete id="deleteMdDataSetByDsCode" parameterType="String">
        delete from md_data_set where DS_CODE = #{dsCode}
    </delete>

    <delete id="deleteMdDataSetByDsCodes" parameterType="String">
        delete from md_data_set where DS_CODE in
        <foreach item="dsCode" collection="array" open="(" separator="," close=")">
            #{dsCode}
        </foreach>
    </delete>
</mapper>