<?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.zg.project.inventory.AutoInventory.mapper.PrintRfidMapper">
    
    <resultMap type="com.zg.project.inventory.AutoInventory.domain.entity.PrintRfid" id="PrintRfidResult">
        <result property="id"    column="id"    />
        <result property="pcde"    column="pcde"    />
        <result property="rfid"    column="rfid"    />
        <result property="isprint"    column="isprint"    />
    </resultMap>

    <sql id="selectPrintRfidVo">
        select id, pcde, rfid, isprint from print_rfid
    </sql>

    <select id="selectPrintRfidList" parameterType="PrintRfid" resultMap="PrintRfidResult">
        <include refid="selectPrintRfidVo"/>
        <where>  
            <if test="pcde != null  and pcde != ''"> and pcde = #{pcde}</if>
            <if test="rfid != null  and rfid != ''"> and rfid = #{rfid}</if>
            <if test="isprint != null "> and isprint = #{isprint}</if>
        </where>
    </select>
    
    <select id="selectPrintRfidById" parameterType="Long" resultMap="PrintRfidResult">
        <include refid="selectPrintRfidVo"/>
        where id = #{id}
    </select>

    <insert id="insertPrintRfid" parameterType="PrintRfid" useGeneratedKeys="true" keyProperty="id">
        insert into print_rfid
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pcde != null">pcde,</if>
            <if test="rfid != null">rfid,</if>
            <if test="isprint != null">isprint,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="pcde != null">#{pcde},</if>
            <if test="rfid != null">#{rfid},</if>
            <if test="isprint != null">#{isprint},</if>
         </trim>
    </insert>

    <update id="updatePrintRfid" parameterType="Long">
        update print_rfid set isprint = 1 where id = #{id}
<!--        <trim prefix="SET" suffixOverrides=",">-->
<!--            <if test="pcde != null">pcde = #{pcde},</if>-->
<!--            <if test="rfid != null">rfid = #{rfid},</if>-->
<!--            <if test="isprint != null">isprint = #{isprint},</if>-->
<!--        </trim>-->

    </update>

    <delete id="deletePrintRfidById" parameterType="Long">
        delete from print_rfid where id = #{id}
    </delete>

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