<?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.HotakeReferenceCheckMapper">
    
    <resultMap type="HotakeReferenceCheck" id="HotakeReferenceCheckResult">
        <result property="id"    column="id"    />
        <result property="company"    column="company"    />
        <result property="fullName"    column="full_name"    />
        <result property="position"    column="position"    />
        <result property="relationship"    column="relationship"    />
        <result property="email"    column="email"    />
        <result property="saveJobExperience"    column="save_job_experience"    />
        <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="selectHotakeReferenceCheckVo">
        select id, company, full_name, position, relationship, email, save_job_experience,
               del_flag, create_by, create_time, update_by, update_time, remark 
        from hotake_reference_check
    </sql>

    <select id="selectHotakeReferenceCheckList" parameterType="HotakeReferenceCheck" resultMap="HotakeReferenceCheckResult">
        <include refid="selectHotakeReferenceCheckVo"/>
        <where>  
            <if test="company != null and company != ''"> and company like concat('%', #{company}, '%')</if>
            <if test="fullName != null and fullName != ''"> and full_name like concat('%', #{fullName}, '%')</if>
            <if test="position != null and position != ''"> and position like concat('%', #{position}, '%')</if>
            <if test="relationship != null and relationship != ''"> and relationship = #{relationship}</if>
            <if test="email != null and email != ''"> and email like concat('%', #{email}, '%')</if>
            <if test="saveJobExperience != null"> and save_job_experience = #{saveJobExperience}</if>
            <if test="delFlag != null and delFlag != ''"> and del_flag = #{delFlag}</if>
            <if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
        </where>
    </select>
    
    <select id="selectHotakeReferenceCheckById" parameterType="Integer" resultMap="HotakeReferenceCheckResult">
        <include refid="selectHotakeReferenceCheckVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertHotakeReferenceCheck" parameterType="HotakeReferenceCheck" useGeneratedKeys="true" keyProperty="id">
        insert into hotake_reference_check
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="company != null and company != ''">company,</if>
            <if test="fullName != null and fullName != ''">full_name,</if>
            <if test="position != null">position,</if>
            <if test="relationship != null and relationship != ''">relationship,</if>
            <if test="email != null and email != ''">email,</if>
            <if test="saveJobExperience != null">save_job_experience,</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="company != null and company != ''">#{company},</if>
            <if test="fullName != null and fullName != ''">#{fullName},</if>
            <if test="position != null">#{position},</if>
            <if test="relationship != null and relationship != ''">#{relationship},</if>
            <if test="email != null and email != ''">#{email},</if>
            <if test="saveJobExperience != null">#{saveJobExperience},</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="updateHotakeReferenceCheck" parameterType="HotakeReferenceCheck">
        update hotake_reference_check
        <trim prefix="SET" suffixOverrides=",">
            <if test="company != null and company != ''">company = #{company},</if>
            <if test="fullName != null and fullName != ''">full_name = #{fullName},</if>
            <if test="position != null">position = #{position},</if>
            <if test="relationship != null and relationship != ''">relationship = #{relationship},</if>
            <if test="email != null and email != ''">email = #{email},</if>
            <if test="saveJobExperience != null">save_job_experience = #{saveJobExperience},</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="deleteHotakeReferenceCheckById" parameterType="Integer">
        delete from hotake_reference_check where id = #{id}
    </delete>

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