<?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.MdDataCateMapper">

    <resultMap type="com.ruoyi.interfaces.domain.MdDataCate" id="MdDataCateResult">
        <result property="cateId"    column="CATE_ID"    />
        <result property="catePid"    column="CATE_PID"    />
        <result property="itemName"    column="ITEM_NAME"    />
        <result property="itemNo"    column="ITEM_NO"    />
        <result property="itemNotes"    column="ITEM_NOTES"    />
        <result property="createby"    column="CREATEBY"    />
        <result property="modifyby"    column="MODIFYBY"    />
    </resultMap>

    <sql id="selectMdDataCateVo">
        select CATE_ID, CATE_PID,  ITEM_NAME, ITEM_NO, ITEM_NOTES, CREATEBY, MODIFYBY from md_data_cate
    </sql>

    <select id="selectMdDataCateList" parameterType="com.ruoyi.interfaces.domain.MdDataCate" resultMap="MdDataCateResult">
        <include refid="selectMdDataCateVo"/>
        <where>
            <if test="catePid != null  and catePid != ''"> and CATE_PID = #{catePid}</if>
            <if test="itemName != null  and itemName != ''"> and ITEM_NAME like concat('%', #{itemName}, '%')</if>
            <if test="itemNo != null "> and ITEM_NO = #{itemNo}</if>
            <if test="itemNotes != null  and itemNotes != ''"> and ITEM_NOTES = #{itemNotes}</if>
            <if test="createby != null "> and CREATEBY = #{createby}</if>
            <if test="modifyby != null "> and MODIFYBY = #{modifyby}</if>
        </where>
    </select>

    <select id="selectMdDataCateByCateId" parameterType="String" resultMap="MdDataCateResult">
        <include refid="selectMdDataCateVo"/>
        where CATE_ID = #{cateId}
    </select>

    <insert id="insertMdDataCate" parameterType="com.ruoyi.interfaces.domain.MdDataCate">
        insert into md_data_cate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="cateId != null">CATE_ID,</if>
            <if test="catePid != null and catePid != ''">CATE_PID,</if>
            <if test="itemName != null">ITEM_NAME,</if>
            <if test="itemNo != null">ITEM_NO,</if>
            <if test="itemNotes != null">ITEM_NOTES,</if>
            <if test="createby != null">CREATEBY,</if>
            <if test="modifyby != null">MODIFYBY,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="cateId != null">#{cateId},</if>
            <if test="catePid != null and catePid != ''">#{catePid},</if>
            <if test="itemName != null">#{itemName},</if>
            <if test="itemNo != null">#{itemNo},</if>
            <if test="itemNotes != null">#{itemNotes},</if>
            <if test="createby != null">#{createby},</if>
            <if test="modifyby != null">#{modifyby},</if>
        </trim>
    </insert>

    <update id="updateMdDataCate" parameterType="com.ruoyi.interfaces.domain.MdDataCate">
        update md_data_cate
        <trim prefix="SET" suffixOverrides=",">
            <if test="catePid != null and catePid != ''">CATE_PID = #{catePid},</if>
            <if test="itemName != null">ITEM_NAME = #{itemName},</if>
            <if test="itemNo != null">ITEM_NO = #{itemNo},</if>
            <if test="itemNotes != null">ITEM_NOTES = #{itemNotes},</if>
            <if test="createby != null">CREATEBY = #{createby},</if>
            <if test="modifyby != null">MODIFYBY = #{modifyby},</if>
        </trim>
        where CATE_ID = #{cateId}
    </update>

    <delete id="deleteMdDataCateByCateId" parameterType="String">
        delete from md_data_cate where CATE_ID = #{cateId}
    </delete>

    <delete id="deleteMdDataCateByCateIds" parameterType="String">
        delete from md_data_cate where CATE_ID in
        <foreach item="cateId" collection="array" open="(" separator="," close=")">
            #{cateId}
        </foreach>
    </delete>
</mapper>