<?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.huijy.management.mapper.TSensitiveWordsMapper">
    
    <resultMap type="TSensitiveWords" id="TSensitiveWordsResult">
        <result property="sensitiveWordsId"    column="sensitive_words_id"    />
        <result property="keyword"    column="keyword"    />
        <result property="useState"    column="use_state"    />
        <result property="createTime"    column="create_time"    />
        <result property="createAt"    column="create_at"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <sql id="selectTSensitiveWordsVo">
        select sensitive_words_id, keyword, use_state, create_time, create_at, remarks from t_sensitive_words
    </sql>

    <select id="selectTSensitiveWordsList" parameterType="TSensitiveWords" resultMap="TSensitiveWordsResult">
        <include refid="selectTSensitiveWordsVo"/>
        <where>  
            <if test="keyword != null  and keyword != ''"> and keyword = #{keyword}</if>
            <if test="useState != null  and useState != ''"> and use_state = #{useState}</if>
        </where>
    </select>
    
    <select id="selectTSensitiveWordsBySensitiveWordsId" parameterType="Long" resultMap="TSensitiveWordsResult">
        <include refid="selectTSensitiveWordsVo"/>
        where sensitive_words_id = #{sensitiveWordsId}
    </select>
        
    <insert id="insertTSensitiveWords" parameterType="TSensitiveWords" useGeneratedKeys="true" keyProperty="sensitiveWordsId">
        insert into t_sensitive_words
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="keyword != null and keyword != ''">keyword,</if>
            <if test="useState != null">use_state,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createAt != null">create_at,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="keyword != null and keyword != ''">#{keyword},</if>
            <if test="useState != null">#{useState},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createAt != null">#{createAt},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTSensitiveWords" parameterType="TSensitiveWords">
        update t_sensitive_words
        <trim prefix="SET" suffixOverrides=",">
            <if test="keyword != null and keyword != ''">keyword = #{keyword},</if>
            <if test="useState != null">use_state = #{useState},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createAt != null">create_at = #{createAt},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where sensitive_words_id = #{sensitiveWordsId}
    </update>

    <delete id="deleteTSensitiveWordsBySensitiveWordsId" parameterType="Long">
        delete from t_sensitive_words where sensitive_words_id = #{sensitiveWordsId}
    </delete>

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