<?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.OfflineCheckInMapper">
    
    <resultMap type="OfflineCheckIn" id="OfflineCheckInResult">
        <result property="id"    column="id"    />
        <result property="studentId"    column="student_id"    />
        <result property="candidatesId"    column="candidates_id"    />
        <result property="name"    column="name"    />
        <result property="sex"    column="sex"    />
        <result property="phoneNumber"    column="phoneNumber"    />
        <result property="email"    column="email"    />
        <result property="idCard"    column="idCard"    />
        <result property="departments"    column="departments"    />
        <result property="handlingStatus"    column="handling_status"    />
        <result property="status"    column="status"    />
        <result property="delFlag"    column="del_flag"    />
        <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="selectOfflineCheckInVo">
        select id, student_id, candidates_id, name, sex, phoneNumber, email, idCard, departments, handling_status, status, del_flag, create_by, create_time, update_by, update_time from srs_handle_information
    </sql>

    <select id="selectOfflineCheckInList" parameterType="OfflineCheckIn" resultMap="OfflineCheckInResult">
        <include refid="selectOfflineCheckInVo"/>
        <where>  
            <if test="studentId != null "> and student_id = #{studentId}</if>
            <if test="candidatesId != null  and candidatesId != ''"> and candidates_id = #{candidatesId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="sex != null "> and sex = #{sex}</if>
            <if test="phoneNumber != null "> and phoneNumber = #{phoneNumber}</if>
            <if test="email != null  and email != ''"> and email = #{email}</if>
            <if test="idCard != null  and idCard != ''"> and idCard = #{idCard}</if>
            <if test="departments != null  and departments != ''"> and departments = #{departments}</if>
            <if test="handlingStatus != null  and handlingStatus != ''"> and handling_status = #{handlingStatus}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectOfflineCheckInById" parameterType="Long" resultMap="OfflineCheckInResult">
        <include refid="selectOfflineCheckInVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertOfflineCheckIn" parameterType="OfflineCheckIn" useGeneratedKeys="true" keyProperty="id">
        insert into srs_handle_information
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="studentId != null">student_id,</if>
            <if test="candidatesId != null">candidates_id,</if>
            <if test="name != null">name,</if>
            <if test="sex != null">sex,</if>
            <if test="phoneNumber != null">phoneNumber,</if>
            <if test="email != null">email,</if>
            <if test="idCard != null">idCard,</if>
            <if test="departments != null">departments,</if>
            <if test="handlingStatus != null">handling_status,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null">del_flag,</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="studentId != null">#{studentId},</if>
            <if test="candidatesId != null">#{candidatesId},</if>
            <if test="name != null">#{name},</if>
            <if test="sex != null">#{sex},</if>
            <if test="phoneNumber != null">#{phoneNumber},</if>
            <if test="email != null">#{email},</if>
            <if test="idCard != null">#{idCard},</if>
            <if test="departments != null">#{departments},</if>
            <if test="handlingStatus != null">#{handlingStatus},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</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="updateOfflineCheckIn" parameterType="OfflineCheckIn">
        update srs_handle_information
        <trim prefix="SET" suffixOverrides=",">
            <if test="studentId != null">student_id = #{studentId},</if>
            <if test="candidatesId != null">candidates_id = #{candidatesId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="sex != null">sex = #{sex},</if>
            <if test="phoneNumber != null">phoneNumber = #{phoneNumber},</if>
            <if test="email != null">email = #{email},</if>
            <if test="idCard != null">idCard = #{idCard},</if>
            <if test="departments != null">departments = #{departments},</if>
            <if test="handlingStatus != null">handling_status = #{handlingStatus},</if>
            <if test="status != null">status = #{status},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</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 id = #{id}
    </update>

    <delete id="deleteOfflineCheckInById" parameterType="Long">
        delete from srs_handle_information where id = #{id}
    </delete>

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



</mapper>