<?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.vetti.hotake.mapper.HotakeInitialScreeningQuestionsInfoMapper">
    
    <resultMap type="HotakeInitialScreeningQuestionsInfo" id="HotakeInitialScreeningQuestionsInfoResult">
        <result property="id"    column="id"    />
        <result property="roleId"    column="role_id"    />
        <result property="recruiterId"    column="recruiter_id"    />
        <result property="questionTitle"    column="question_title"    />
        <result property="questionType"    column="question_type"    />
        <result property="answerOptions"    column="answer_options"    />
        <result property="requiredField"    column="required_field"    />
        <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"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectHotakeInitialScreeningQuestionsInfoVo">
        select id, role_id, recruiter_id, question_title, question_type, answer_options, required_field, del_flag, create_by, create_time, update_by, update_time, remark from hotake_initial_screening_questions_info
    </sql>

    <select id="selectHotakeInitialScreeningQuestionsInfoList" parameterType="HotakeInitialScreeningQuestionsInfo" resultMap="HotakeInitialScreeningQuestionsInfoResult">
        <include refid="selectHotakeInitialScreeningQuestionsInfoVo"/>
        <where>  
            <if test="roleId != null "> and role_id = #{roleId}</if>
            <if test="recruiterId != null "> and recruiter_id = #{recruiterId}</if>
            <if test="questionTitle != null  and questionTitle != ''"> and question_title = #{questionTitle}</if>
            <if test="questionType != null  and questionType != ''"> and question_type = #{questionType}</if>
            <if test="answerOptions != null  and answerOptions != ''"> and answer_options = #{answerOptions}</if>
            <if test="requiredField != null  and requiredField != ''"> and required_field = #{requiredField}</if>
        </where>
    </select>
    
    <select id="selectHotakeInitialScreeningQuestionsInfoById" parameterType="Long" resultMap="HotakeInitialScreeningQuestionsInfoResult">
        <include refid="selectHotakeInitialScreeningQuestionsInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertHotakeInitialScreeningQuestionsInfo" parameterType="HotakeInitialScreeningQuestionsInfo" useGeneratedKeys="true" keyProperty="id">
        insert into hotake_initial_screening_questions_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="roleId != null">role_id,</if>
            <if test="recruiterId != null">recruiter_id,</if>
            <if test="questionTitle != null">question_title,</if>
            <if test="questionType != null">question_type,</if>
            <if test="answerOptions != null">answer_options,</if>
            <if test="requiredField != null">required_field,</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>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="roleId != null">#{roleId},</if>
            <if test="recruiterId != null">#{recruiterId},</if>
            <if test="questionTitle != null">#{questionTitle},</if>
            <if test="questionType != null">#{questionType},</if>
            <if test="answerOptions != null">#{answerOptions},</if>
            <if test="requiredField != null">#{requiredField},</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>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateHotakeInitialScreeningQuestionsInfo" parameterType="HotakeInitialScreeningQuestionsInfo">
        update hotake_initial_screening_questions_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="roleId != null">role_id = #{roleId},</if>
            <if test="recruiterId != null">recruiter_id = #{recruiterId},</if>
            <if test="questionTitle != null">question_title = #{questionTitle},</if>
            <if test="questionType != null">question_type = #{questionType},</if>
            <if test="answerOptions != null">answer_options = #{answerOptions},</if>
            <if test="requiredField != null">required_field = #{requiredField},</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>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteHotakeInitialScreeningQuestionsInfoById" parameterType="Long">
        delete from hotake_initial_screening_questions_info where id = #{id}
    </delete>

    <delete id="deleteHotakeInitialScreeningQuestionsInfoByRoleId" parameterType="Long">
        delete from hotake_initial_screening_questions_info where role_id = #{roleId}
    </delete>

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

    <insert id="batchInsertHotakeInitialScreeningQuestionsInfo">
        insert into hotake_initial_screening_questions_info( id, role_id, recruiter_id, question_title, question_type, answer_options, required_field, del_flag, create_by, create_time, update_by, update_time, remark) values
        <foreach item="item" index="index" collection="list" separator=",">
            ( #{item.id}, #{item.roleId}, #{item.recruiterId}, #{item.questionTitle}, #{item.questionType}, #{item.answerOptions}, #{item.requiredField}, #{item.delFlag}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark})
        </foreach>
    </insert>
</mapper>