<?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.srs.stureg.mapper.ArrivalInformationMapper">
    
    <resultMap type="ArrivalInformation" id="ArrivalInformationResult">
        <result property="arriveId"    column="arrive_id"    />
        <result property="studentId"    column="student_id"    />
        <result property="lot"    column="lot"    />
        <result property="receivingSite"    column="receiving_site"    />
        <result property="userType"    column="user_type"    />
        <result property="timeInterval"    column="time_interval"    />
        <result property="statisticalTime"    column="statistical_time"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectArrivalInformationVo">
        select arrive_id, student_id, lot, receiving_site, user_type, time_interval, statistical_time, status, create_by, create_time, update_by, update_time from srs_arrival_information
    </sql>

    <select id="selectArrivalInformationList" parameterType="ArrivalInformation" resultMap="ArrivalInformationResult">
        <include refid="selectArrivalInformationVo"/>
        <where>  
            <if test="studentId != null "> and student_id = #{studentId}</if>
            <if test="receivingSite != null  and receivingSite != ''"> and receiving_site = #{receivingSite}</if>
            <if test="userType != null  and userType != ''"> and user_type = #{userType}</if>
            <if test="timeInterval != null "> and time_interval = #{timeInterval}</if>
            <if test="statisticalTime != null "> and statistical_time = #{statisticalTime}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectArrivalInformationByArriveId" parameterType="Long" resultMap="ArrivalInformationResult">
        <include refid="selectArrivalInformationVo"/>
        where arrive_id = #{arriveId}
    </select>
        
    <insert id="insertArrivalInformation" parameterType="ArrivalInformation">
        insert into srs_arrival_information
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="arriveId != null">arrive_id,</if>
            <if test="studentId != null">student_id,</if>
            <if test="lot != null">lot,</if>
            <if test="receivingSite != null">receiving_site,</if>
            <if test="userType != null">user_type,</if>
            <if test="timeInterval != null">time_interval,</if>
            <if test="statisticalTime != null">statistical_time,</if>
            <if test="status != null">status,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="arriveId != null">#{arriveId},</if>
            <if test="studentId != null">#{studentId},</if>
            <if test="lot != null">#{lot},</if>
            <if test="receivingSite != null">#{receivingSite},</if>
            <if test="userType != null">#{userType},</if>
            <if test="timeInterval != null">#{timeInterval},</if>
            <if test="statisticalTime != null">#{statisticalTime},</if>
            <if test="status != null">#{status},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateArrivalInformation" parameterType="ArrivalInformation">
        update srs_arrival_information
        <trim prefix="SET" suffixOverrides=",">
            <if test="studentId != null">student_id = #{studentId},</if>
            <if test="lot != null">lot = #{lot},</if>
            <if test="receivingSite != null">receiving_site = #{receivingSite},</if>
            <if test="userType != null">user_type = #{userType},</if>
            <if test="timeInterval != null">time_interval = #{timeInterval},</if>
            <if test="statisticalTime != null">statistical_time = #{statisticalTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where arrive_id = #{arriveId}
    </update>

    <delete id="deleteArrivalInformationByArriveId" parameterType="Long">
        delete from srs_arrival_information where arrive_id = #{arriveId}
    </delete>

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