<?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.HotakeSettingsJobMapper">
    
    <resultMap type="HotakeSettingsJob" id="HotakeSettingsJobResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="location"    column="location"    />
        <result property="latitude" column="latitude" />
        <result property="longitude" column="longitude" />
        <result property="salary" column="salary" />
        <result property="tagsJson" column="tags_json" />
        <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="selectHotakeSettingsJobVo">
        select id, name, location, latitude, longitude, salary, tags_json,
               del_flag, create_by, create_time, update_by, update_time, remark from hotake_settings_job
    </sql>

    <select id="selectHotakeSettingsJobList" parameterType="HotakeSettingsJob" resultMap="HotakeSettingsJobResult">
        <include refid="selectHotakeSettingsJobVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="location != null  and location != ''"> and location like concat('%', #{location}, '%')</if>
            <if test="latitude != null"> and latitude = #{latitude}</if>
            <if test="longitude != null"> and longitude = #{longitude}</if>
            <if test="salary != null  and salary != ''"> and salary = #{salary}</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="selectHotakeSettingsJobById" parameterType="Long" resultMap="HotakeSettingsJobResult">
        <include refid="selectHotakeSettingsJobVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertHotakeSettingsJob" parameterType="HotakeSettingsJob" useGeneratedKeys="true" keyProperty="id">
        insert into hotake_settings_job
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="location != null">location,</if>
            <if test="latitude != null">latitude,</if>
            <if test="longitude != null">longitude,</if>
            <if test="salary != null">salary,</if>
            <if test="tagsJson != null">tags_json,</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="name != null">#{name},</if>
            <if test="location != null">#{location},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="salary != null">#{salary},</if>
            <if test="tagsJson != null">#{tagsJson},</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="updateHotakeSettingsJob" parameterType="HotakeSettingsJob">
        update hotake_settings_job
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="location != null">location = #{location},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="salary != null">salary = #{salary},</if>
            <if test="tagsJson != null">tags_json = #{tagsJson},</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="deleteHotakeSettingsJobById" parameterType="Long">
        delete from hotake_settings_job where id = #{id}
    </delete>

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