<?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.TourImSensitiveWordDenyMapper">
    <resultMap id="BaseResultMap" type="com.tourism.webadmin.back.model.TourImSensitiveWordDeny">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="word" jdbcType="VARCHAR" property="word"/>
    </resultMap>

    <insert id="insertList">
        INSERT INTO tour_im_sensitive_word_deny
            (id,
            word)
        VALUES
        <foreach collection="list" index="index" item="item" separator="," >
            (#{item.id},
            #{item.word})
        </foreach>
    </insert>

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

    <!-- 这里仅包含调用接口输入的主表过滤条件 -->
    <sql id="inputFilterRef">
        <if test="tourImSensitiveWordDenyFilter != null">
            <if test="tourImSensitiveWordDenyFilter.id != null">
                AND tour_im_sensitive_word_deny.id = #{tourImSensitiveWordDenyFilter.id}
            </if>
            <if test="tourImSensitiveWordDenyFilter.word != null and tourImSensitiveWordDenyFilter.word != ''">
                <bind name = "safeTourImSensitiveWordDenyWord" value = "'%' + tourImSensitiveWordDenyFilter.word + '%'" />
                AND tour_im_sensitive_word_deny.word LIKE #{safeTourImSensitiveWordDenyWord}
            </if>
            <if test="tourImSensitiveWordDenyFilter.searchString != null and tourImSensitiveWordDenyFilter.searchString != ''">
                <bind name = "safeTourImSensitiveWordDenySearchString" value = "'%' + tourImSensitiveWordDenyFilter.searchString + '%'" />
                AND IFNULL(tour_im_sensitive_word_deny.word,'') LIKE #{safeTourImSensitiveWordDenySearchString}
            </if>
        </if>
    </sql>

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