<?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.TourTourismProjectTravelNotesMapper">
    <resultMap id="BaseResultMap" type="com.tourism.webadmin.back.model.TourTourismProjectTravelNotes">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="project_title" jdbcType="VARCHAR" property="projectTitle"/>
        <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
        <result column="is_hotspot" jdbcType="TINYINT" property="isHotspot"/>
        <result column="project_label" jdbcType="VARCHAR" property="projectLabel"/>
        <result column="show_order" jdbcType="TINYINT" property="showOrder"/>
        <result column="enable" jdbcType="TINYINT" property="enable"/>
        <result column="belong_tab" jdbcType="BIGINT" property="belongTab"/>
        <result column="start_place" jdbcType="VARCHAR" property="startPlace"/>
        <result column="end_place" jdbcType="VARCHAR" property="endPlace"/>
        <result column="count_times" jdbcType="VARCHAR" property="countTimes"/>
        <result column="price" jdbcType="DECIMAL" property="price"/>
        <result column="tourism_url" jdbcType="VARCHAR" property="tourismUrl"/>
        <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"/>
        <result column="price_unit" jdbcType="VARCHAR" property="priceUnit"/>
        <result column="service_ensure" jdbcType="VARCHAR" property="serviceEnsure"/>
        <result column="contact_number" jdbcType="VARCHAR" property="contactNumber"/>
        <result column="selling_point" jdbcType="VARCHAR" property="sellingPoint"/>
        <result column="short_title" jdbcType="VARCHAR" property="shortTitle"/>
        <result column="short_description" jdbcType="VARCHAR" property="shortDescription"/>
        <result column="home_hot_picture" jdbcType="VARCHAR" property="homeHotPicture"/>
        <result column="contact_description" jdbcType="VARCHAR" property="contactDescription"/>
        <result column="travel_notes_banner" jdbcType="VARCHAR" property="travelNotesBanner"/>
        <result column="like_count" jdbcType="INTEGER" property="likeCount"/>
        <result column="page_view_count" jdbcType="INTEGER" property="pageViewCount"/>
        <result column="role" jdbcType="VARCHAR" property="role"/>
        <result column="departure_time" jdbcType="TIMESTAMP" property="departureTime"/>
        <result column="average_cost" jdbcType="VARCHAR" property="averageCost"/>
        <result column="recommendation_rate" jdbcType="TINYINT" property="recommendationRate"/>
        <result column="hot_value" jdbcType="INTEGER" property="hotValue"/>
        <result column="is_original" jdbcType="INTEGER" property="isOriginal"/>
    </resultMap>

    <insert id="insertList">
        INSERT INTO tour_tourism_project_travel_notes
            (id,
            project_title,
            remarks,
            is_hotspot,
            project_label,
            show_order,
            enable,
            belong_tab,
            start_place,
            end_place,
            count_times,
            price,
            tourism_url,
            create_user_id,
            create_time,
            update_user_id,
            update_time,
            data_state,
            price_unit,
            service_ensure,
            contact_number,
            selling_point,
            short_title,
            short_description,
            home_hot_picture,
            contact_description,
            travel_notes_banner,
            like_count,
            page_view_count,
            role,
            departure_time,
            average_cost,
            recommendation_rate,
            hot_value,
            is_original)
        VALUES
        <foreach collection="list" index="index" item="item" separator="," >
            (#{item.id},
            #{item.projectTitle},
            #{item.remarks},
            #{item.isHotspot},
            #{item.projectLabel},
            #{item.showOrder},
            #{item.enable},
            #{item.belongTab},
            #{item.startPlace},
            #{item.endPlace},
            #{item.countTimes},
            #{item.price},
            #{item.tourismUrl},
            #{item.createUserId},
            #{item.createTime},
            #{item.updateUserId},
            #{item.updateTime},
            #{item.dataState},
            #{item.priceUnit},
            #{item.serviceEnsure},
            #{item.contactNumber},
            #{item.sellingPoint},
            #{item.shortTitle},
            #{item.shortDescription},
            #{item.homeHotPicture},
            #{item.contactDescription},
            #{item.travelNotesBanner},
            #{item.likeCount},
            #{item.pageViewCount},
            #{item.role},
            #{item.departureTime},
            #{item.averageCost},
            #{item.recommendationRate},
            #{item.hotValue},
            #{item.isOriginal})
        </foreach>
    </insert>

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

    <!-- 这里仅包含调用接口输入的主表过滤条件 -->
    <sql id="inputFilterRef">
        <if test="tourTourismProjectTravelNotesFilter != null">
            <if test="tourTourismProjectTravelNotesFilter.projectTitle != null and tourTourismProjectTravelNotesFilter.projectTitle != ''">
                <bind name = "safeTourTourismProjectTravelNotesProjectTitle" value = "'%' + tourTourismProjectTravelNotesFilter.projectTitle + '%'" />
                AND tour_tourism_project_travel_notes.project_title LIKE #{safeTourTourismProjectTravelNotesProjectTitle}
            </if>
            <if test="tourTourismProjectTravelNotesFilter.remarks != null and tourTourismProjectTravelNotesFilter.remarks != ''">
                <bind name = "safeTourTourismProjectTravelNotesRemarks" value = "'%' + tourTourismProjectTravelNotesFilter.remarks + '%'" />
                AND tour_tourism_project_travel_notes.remarks LIKE #{safeTourTourismProjectTravelNotesRemarks}
            </if>
            <if test="tourTourismProjectTravelNotesFilter.id != null">
                AND tour_tourism_project_travel_notes.id = #{tourTourismProjectTravelNotesFilter.id}
            </if>
            <if test="tourTourismProjectTravelNotesFilter.isHotspot != null">
                AND tour_tourism_project_travel_notes.is_hotspot = #{tourTourismProjectTravelNotesFilter.isHotspot}
            </if>
            <if test="tourTourismProjectTravelNotesFilter.projectLabel != null and tourTourismProjectTravelNotesFilter.projectLabel != ''">
                AND tour_tourism_project_travel_notes.project_label = #{tourTourismProjectTravelNotesFilter.projectLabel}
            </if>
            <if test="tourTourismProjectTravelNotesFilter.enable != null">
                AND tour_tourism_project_travel_notes.enable = #{tourTourismProjectTravelNotesFilter.enable}
            </if>
            <if test="tourTourismProjectTravelNotesFilter.belongTab != null">
                AND tour_tourism_project_travel_notes.belong_tab = #{tourTourismProjectTravelNotesFilter.belongTab}
            </if>
            <if test="tourTourismProjectTravelNotesFilter.startPlace != null and tourTourismProjectTravelNotesFilter.startPlace != ''">
                <bind name = "safeTourTourismProjectTravelNotesStartPlace" value = "'%' + tourTourismProjectTravelNotesFilter.startPlace + '%'" />
                AND tour_tourism_project_travel_notes.start_place LIKE #{safeTourTourismProjectTravelNotesStartPlace}
            </if>
            <if test="tourTourismProjectTravelNotesFilter.endPlace != null and tourTourismProjectTravelNotesFilter.endPlace != ''">
                <bind name = "safeTourTourismProjectTravelNotesEndPlace" value = "'%' + tourTourismProjectTravelNotesFilter.endPlace + '%'" />
                AND tour_tourism_project_travel_notes.end_place LIKE #{safeTourTourismProjectTravelNotesEndPlace}
            </if>
            <if test="tourTourismProjectTravelNotesFilter.shortTitle != null and tourTourismProjectTravelNotesFilter.shortTitle != ''">
                <bind name = "safeTourTourismProjectTravelNotesShortTitle" value = "'%' + tourTourismProjectTravelNotesFilter.shortTitle + '%'" />
                AND tour_tourism_project_travel_notes.short_title LIKE #{safeTourTourismProjectTravelNotesShortTitle}
            </if>
            <if test="tourTourismProjectTravelNotesFilter.shortDescription != null and tourTourismProjectTravelNotesFilter.shortDescription != ''">
                <bind name = "safeTourTourismProjectTravelNotesShortDescription" value = "'%' + tourTourismProjectTravelNotesFilter.shortDescription + '%'" />
                AND tour_tourism_project_travel_notes.short_description LIKE #{safeTourTourismProjectTravelNotesShortDescription}
            </if>
            <if test="tourTourismProjectTravelNotesFilter.contactDescription != null and tourTourismProjectTravelNotesFilter.contactDescription != ''">
                <bind name = "safeTourTourismProjectTravelNotesContactDescription" value = "'%' + tourTourismProjectTravelNotesFilter.contactDescription + '%'" />
                AND tour_tourism_project_travel_notes.contact_description LIKE #{safeTourTourismProjectTravelNotesContactDescription}
            </if>
            <if test="tourTourismProjectTravelNotesFilter.searchString != null and tourTourismProjectTravelNotesFilter.searchString != ''">
                <bind name = "safeTourTourismProjectTravelNotesSearchString" value = "'%' + tourTourismProjectTravelNotesFilter.searchString + '%'" />
                AND CONCAT(IFNULL(tour_tourism_project_travel_notes.remarks,''), IFNULL(tour_tourism_project_travel_notes.project_label,''), IFNULL(tour_tourism_project_travel_notes.start_place,''), IFNULL(tour_tourism_project_travel_notes.end_place,''), IFNULL(tour_tourism_project_travel_notes.short_title,''), IFNULL(tour_tourism_project_travel_notes.short_description,''), IFNULL(tour_tourism_project_travel_notes.contact_description,'')) LIKE #{safeTourTourismProjectTravelNotesSearchString}
            </if>
            <if test="tourTourismProjectTravelNotesFilter.directoryInfoIds != null and tourTourismProjectTravelNotesFilter.directoryInfoIds.size() > 0">
                AND tour_tourism_project_travel_notes.belong_tab IN
                <foreach item="id" index="index" collection="tourTourismProjectTravelNotesFilter.directoryInfoIds" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            <if test="tourTourismProjectTravelNotesFilter.createUserId != null">
                AND tour_tourism_project_travel_notes.create_user_id = #{tourTourismProjectTravelNotesFilter.createUserId}
            </if>
        </if>
    </sql>

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