<?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.tourism.webadmin.back.dao.JobProjectMapper">
    <resultMap id="BaseResultMap" type="com.tourism.webadmin.back.model.JobProject">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="job_title" jdbcType="VARCHAR" property="jobTitle"/>
        <result column="job_label" jdbcType="VARCHAR" property="jobLabel"/>
        <result column="belong_tab" jdbcType="BIGINT" property="belongTab"/>
        <result column="job_area" jdbcType="VARCHAR" property="jobArea"/>
        <result column="job_people" jdbcType="INTEGER" property="jobPeople"/>
        <result column="job_pay" jdbcType="VARCHAR" property="jobPay"/>
        <result column="job_education" jdbcType="VARCHAR" property="jobEducation"/>
        <result column="job_language" jdbcType="VARCHAR" property="jobLanguage"/>
        <result column="job_contract" jdbcType="VARCHAR" property="jobContract"/>
        <result column="job_deadline" jdbcType="VARCHAR" property="jobDeadline"/>
        <result column="job_require" jdbcType="VARCHAR" property="jobRequire"/>
        <result column="job_welfare" jdbcType="VARCHAR" property="jobWelfare"/>
        <result column="job_time" jdbcType="VARCHAR" property="jobTime"/>
        <result column="job_post" jdbcType="VARCHAR" property="jobPost"/>
        <result column="job_advantage" jdbcType="VARCHAR" property="jobAdvantage"/>
        <result column="job_url" jdbcType="VARCHAR" property="jobUrl"/>
        <result column="is_hotspot" jdbcType="TINYINT" property="isHotspot"/>
        <result column="show_order" jdbcType="TINYINT" property="showOrder"/>
        <result column="enable" jdbcType="TINYINT" property="enable"/>
        <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
        <result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="data_state" jdbcType="TINYINT" property="dataState"/>
    </resultMap>

    <insert id="insertList">
        INSERT INTO tour_job_project
            (id,
            job_title,
            job_label,
            belong_tab,
            job_area,
            job_people,
            job_pay,
            job_education,
            job_language,
            job_contract,
            job_deadline,
            job_require,
            job_welfare,
            job_time,
            job_post,
            job_advantage,
            job_url,
            is_hotspot,
            show_order,
            enable,
            remarks,
            create_user_id,
            create_time,
            update_user_id,
            update_time,
            data_state)
        VALUES
        <foreach collection="list" index="index" item="item" separator="," >
            (#{item.id},
            #{item.jobTitle},
            #{item.jobLabel},
            #{item.belongTab},
            #{item.jobArea},
            #{item.jobPeople},
            #{item.jobPay},
            #{item.jobEducation},
            #{item.jobLanguage},
            #{item.jobContract},
            #{item.jobDeadline},
            #{item.jobRequire},
            #{item.jobWelfare},
            #{item.jobTime},
            #{item.jobPost},
            #{item.jobAdvantage},
            #{item.jobUrl},
            #{item.isHotspot},
            #{item.showOrder},
            #{item.enable},
            #{item.remarks},
            #{item.createUserId},
            #{item.createTime},
            #{item.updateUserId},
            #{item.updateTime},
            #{item.dataState})
        </foreach>
    </insert>

    <!-- 如果有逻辑删除字段过滤，请写到这里 -->
    <sql id="filterRef">
        <!-- 这里必须加上全包名，否则当filterRef被其他Mapper.xml包含引用的时候，就会调用Mapper.xml中的该SQL片段 -->
        <include refid="com.tourism.webadmin.back.dao.JobProjectMapper.inputFilterRef"/>
        AND tour_job_project.data_state = ${@com.tourism.common.core.constant.GlobalDeletedFlag@NORMAL}
    </sql>

    <!-- 这里仅包含调用接口输入的主表过滤条件 -->
    <sql id="inputFilterRef">
        <if test="jobProjectFilter != null">
            <if test="jobProjectFilter.belongTab != null and jobProjectFilter.belongTab != ''">
                AND belong_tab = #{jobProjectFilter.belongTab}
            </if>
            <if test="jobProjectFilter.isHotspot != null and jobProjectFilter.isHotspot != ''">
                AND is_hotspot = #{jobProjectFilter.isHotspot}
            </if>
            <if test="jobProjectFilter.jobTitle != null and jobProjectFilter.jobTitle != ''">
                <bind name = "safeJobProjectJobTitle" value = "'%' + jobProjectFilter.jobTitle + '%'" />
                AND tour_job_project.job_title LIKE #{safeJobProjectJobTitle}
            </if>
            <if test="jobProjectFilter.searchString != null and jobProjectFilter.searchString != ''">
                <bind name = "safeJobProjectSearchString" value = "'%' + jobProjectFilter.searchString + '%'" />
                AND IFNULL(tour_job_project.job_title,'') LIKE #{safeJobProjectSearchString}
            </if>
        </if>
    </sql>

    <select id="getJobProjectList" resultMap="BaseResultMap" parameterType="com.tourism.webadmin.back.model.JobProject">
        SELECT * FROM tour_job_project
        <where>
            <include refid="filterRef"/>
        </where>
        <if test="orderBy != null and orderBy != ''">
            ORDER BY ${orderBy}
        </if>
    </select>
</mapper>
