<?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.fs.qw.mapper.QwForbiddenWordsMapper">

    <resultMap type="QwForbiddenWords" id="QwForbiddenWordsResult">
        <result property="id"    column="id"    />
        <result property="word"    column="word"    />
        <result property="severity"    column="severity"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="operator"    column="operator"    />
    </resultMap>

    <sql id="selectQwForbiddenWordsVo">
        select id, word, severity, create_time, update_time, operator from qw_forbidden_words
    </sql>

    <select id="selectQwForbiddenWordsList" parameterType="QwForbiddenWords" resultMap="QwForbiddenWordsResult">
        <include refid="selectQwForbiddenWordsVo"/>
        <where>
            <if test="word != null  and word != ''"> and word = #{word}</if>
            <if test="severity != null "> and severity = #{severity}</if>
            <if test="operator != null  and operator != ''"> and operator = #{operator}</if>
        </where>
    </select>

    <select id="selectQwForbiddenWordsById" parameterType="Long" resultMap="QwForbiddenWordsResult">
        <include refid="selectQwForbiddenWordsVo"/>
        where id = #{id}
    </select>

    <insert id="insertQwForbiddenWords" parameterType="QwForbiddenWords" useGeneratedKeys="true" keyProperty="id">
        insert into qw_forbidden_words
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="word != null">word,</if>
            <if test="severity != null">severity,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="operator != null">operator,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="word != null">#{word},</if>
            <if test="severity != null">#{severity},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="operator != null">#{operator},</if>
        </trim>
    </insert>

    <update id="updateQwForbiddenWords" parameterType="QwForbiddenWords">
        update qw_forbidden_words
        <trim prefix="SET" suffixOverrides=",">
            <if test="word != null">word = #{word},</if>
            <if test="severity != null">severity = #{severity},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="operator != null">operator = #{operator},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQwForbiddenWordsById" parameterType="Long">
        delete from qw_forbidden_words where id = #{id}
    </delete>

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