<?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.RecordStoreCheckMapper">
    
    <resultMap type="RecordStoreCheck" id="RecordStoreCheckResult">
        <result property="checkId"    column="check_id"    />
        <result property="checkTime"    column="check_time"    />
        <result property="checkUser"    column="check_user"    />
        <result property="checkNumber"    column="check_number"    />
        <result property="checkRemack"    column="check_remack"    />
    </resultMap>

    <sql id="selectRecordStoreCheckVo">
        select check_id, check_time, check_user, check_number, check_remack from record_store_check
    </sql>

    <select id="selectRecordStoreCheckList" parameterType="RecordStoreCheck" resultMap="RecordStoreCheckResult">
        <include refid="selectRecordStoreCheckVo"/>
        <where>
            <if test="params.beginCheckTime != null and params.beginCheckTime != '' and params.endCheckTime != null and params.endCheckTime != ''"> and check_time between #{params.beginCheckTime} and #{params.endCheckTime}</if>

            <if test="checkUser != null  and checkUser != ''"> and check_user = #{checkUser}</if>
        </where>
    </select>
    
    <select id="selectRecordStoreCheckByCheckId" parameterType="Long" resultMap="RecordStoreCheckResult">
        <include refid="selectRecordStoreCheckVo"/>
        where check_id = #{checkId}
    </select>
        
    <insert id="insertRecordStoreCheck" parameterType="RecordStoreCheck" useGeneratedKeys="true" keyProperty="checkId">
        insert into record_store_check
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="checkTime != null">check_time,</if>
            <if test="checkUser != null">check_user,</if>
            <if test="checkNumber != null">check_number,</if>
            <if test="checkRemack != null">check_remack,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="checkTime != null">#{checkTime},</if>
            <if test="checkUser != null">#{checkUser},</if>
            <if test="checkNumber != null">#{checkNumber},</if>
            <if test="checkRemack != null">#{checkRemack},</if>
         </trim>
    </insert>

    <update id="updateRecordStoreCheck" parameterType="RecordStoreCheck">
        update record_store_check
        <trim prefix="SET" suffixOverrides=",">
            <if test="checkTime != null">check_time = #{checkTime},</if>
            <if test="checkUser != null">check_user = #{checkUser},</if>
            <if test="checkNumber != null">check_number = #{checkNumber},</if>
            <if test="checkRemack != null">check_remack = #{checkRemack},</if>
        </trim>
        where check_id = #{checkId}
    </update>

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

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

</mapper>