<?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.manage.mapper.RecordStoreCheckInfoMapper">
    
    <resultMap type="RecordStoreCheckInfo" id="RecordStoreCheckInfoResult">
        <result property="checkId"    column="check_id"    />
        <result property="epcCode"    column="epc_code"    />
        <result property="locationCode"    column="location_code"    />
        <result property="checkState"    column="check_state"    />
    </resultMap>

    <sql id="selectRecordStoreCheckInfoVo">
        select check_id, epc_code, location_code, check_state from record_store_check_info
    </sql>

    <select id="selectRecordStoreCheckInfoList" parameterType="RecordStoreCheckInfo" resultMap="RecordStoreCheckInfoResult">
        <include refid="selectRecordStoreCheckInfoVo"/>
        <where>  
            <if test="checkId != null "> and check_id = #{checkId}</if>
            <if test="epcCode != null  and epcCode != ''"> and epc_code = #{epcCode}</if>
            <if test="locationCode != null  and locationCode != ''"> and location_code = #{locationCode}</if>
            <if test="checkState != null  and checkState != ''"> and check_state = #{checkState}</if>
        </where>
    </select>
    
    <select id="selectRecordStoreCheckInfoByCheckId" parameterType="Long" resultMap="RecordStoreCheckInfoResult">
        <include refid="selectRecordStoreCheckInfoVo"/>
        where check_id = #{checkId}
    </select>
        
    <insert id="insertRecordStoreCheckInfo" parameterType="RecordStoreCheckInfo">
        insert into record_store_check_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="checkId != null">check_id,</if>
            <if test="epcCode != null">epc_code,</if>
            <if test="locationCode != null">location_code,</if>
            <if test="checkState != null">check_state,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="checkId != null">#{checkId},</if>
            <if test="epcCode != null">#{epcCode},</if>
            <if test="locationCode != null">#{locationCode},</if>
            <if test="checkState != null">#{checkState},</if>
         </trim>
    </insert>

    <update id="updateRecordStoreCheckInfo" parameterType="RecordStoreCheckInfo">
        update record_store_check_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="epcCode != null">epc_code = #{epcCode},</if>
            <if test="locationCode != null">location_code = #{locationCode},</if>
            <if test="checkState != null">check_state = #{checkState},</if>
        </trim>
        where check_id = #{checkId}
    </update>

    <delete id="deleteRecordStoreCheckInfoByCheckId" parameterType="Long">
        delete from record_store_check_info where check_id = #{checkId}
    </delete>

    <delete id="deleteRecordStoreCheckInfoByCheckIds" parameterType="String">
        delete from record_store_check_info where check_id in 
        <foreach item="checkId" collection="array" open="(" separator="," close=")">
            #{checkId}
        </foreach>
    </delete>

</mapper>