<?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.HotakeInterviewDetailMapper">
    
    <resultMap type="HotakeInterviewDetail" id="HotakeInterviewDetailResult">
        <result property="id"    column="id"    />
        <result property="interviewId"    column="interview_id"    />
        <result property="interviewerName"    column="interviewer_name"    />
        <result property="content"    column="content"    />
        <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="selectHotakeInterviewDetailVo">
        select id, interview_id, interviewer_name, content, del_flag, create_by, create_time, update_by, update_time, remark from hotake_interview_detail
    </sql>

    <select id="selectHotakeInterviewDetailList" parameterType="HotakeInterviewDetail" resultMap="HotakeInterviewDetailResult">
        <include refid="selectHotakeInterviewDetailVo"/>
        <where>  
            <if test="interviewId != null "> and interview_id = #{interviewId}</if>
            <if test="interviewerName != null  and interviewerName != ''"> and interviewer_name like concat('%', #{interviewerName}, '%')</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
        </where>
    </select>
    
    <select id="selectHotakeInterviewDetailById" parameterType="Long" resultMap="HotakeInterviewDetailResult">
        <include refid="selectHotakeInterviewDetailVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertHotakeInterviewDetail" parameterType="HotakeInterviewDetail" useGeneratedKeys="true" keyProperty="id">
        insert into hotake_interview_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="interviewId != null">interview_id,</if>
            <if test="interviewerName != null">interviewer_name,</if>
            <if test="content != null">content,</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="interviewId != null">#{interviewId},</if>
            <if test="interviewerName != null">#{interviewerName},</if>
            <if test="content != null">#{content},</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="updateHotakeInterviewDetail" parameterType="HotakeInterviewDetail">
        update hotake_interview_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="interviewId != null">interview_id = #{interviewId},</if>
            <if test="interviewerName != null">interviewer_name = #{interviewerName},</if>
            <if test="content != null">content = #{content},</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="deleteHotakeInterviewDetailById" parameterType="Long">
        delete from hotake_interview_detail where id = #{id}
    </delete>

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

    <insert id="batchInsertHotakeInterviewDetail">
        insert into hotake_interview_detail( id, interview_id, interviewer_name, content, del_flag, create_by, create_time, update_by, update_time, remark) values
        <foreach item="item" index="index" collection="list" separator=",">
            ( #{item.id}, #{item.interviewId}, #{item.interviewerName}, #{item.content}, #{item.delFlag}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark})
        </foreach>
    </insert>
</mapper>