<?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.QwForbiddenMessageMapper">

    <resultMap type="QwForbiddenMessage" id="QwForbiddenMessageResult">
        <result property="id"    column="id"    />
        <result property="messageId"    column="message_id"    />
        <result property="conversationId"    column="conversation_id"    />
        <result property="content"    column="content"    />
        <result property="companyUserId"    column="company_user_id"    />
        <result property="companyId"    column="company_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="account"    column="account"    />
        <result property="sendTime"    column="send_time"    />
        <result property="wordId"    column="word_id"    />
    </resultMap>

    <sql id="selectQwForbiddenMessageVo">
        select id,send_time,account, message_id, conversation_id, content, company_user_id, company_id, create_time from qw_forbidden_message
    </sql>

    <select id="selectQwForbiddenMessageList" parameterType="QwForbiddenMessage" resultMap="QwForbiddenMessageResult">
        <include refid="selectQwForbiddenMessageVo"/>
        <where>
            <if test="account != null  and account != ''"> and account = #{account}</if>
            <if test="sendTime != null "> and send_time = #{sendTime}</if>
            <if test="messageId != null "> and message_id = #{messageId}</if>
            <if test="conversationId != null  and conversationId != ''"> and conversation_id = #{conversationId}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
        </where>
    </select>

    <select id="selectQwForbiddenMessageById" parameterType="Long" resultMap="QwForbiddenMessageResult">
        <include refid="selectQwForbiddenMessageVo"/>
        where id = #{id}
    </select>

    <insert id="insertQwForbiddenMessage" parameterType="QwForbiddenMessage" useGeneratedKeys="true" keyProperty="id">
        insert into qw_forbidden_message
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="messageId != null">message_id,</if>
            <if test="conversationId != null">conversation_id,</if>
            <if test="content != null">content,</if>
            <if test="sendTime != null">send_time,</if>
            <if test="companyUserId != null">company_user_id,</if>
            <if test="companyId != null">company_id,</if>
            <if test="wordId != null">word_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="account != null">account,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="messageId != null">#{messageId},</if>
            <if test="conversationId != null">#{conversationId},</if>
            <if test="content != null">#{content},</if>
            <if test="sendTime != null">#{sendTime},</if>
            <if test="companyUserId != null">#{companyUserId},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="wordId != null">#{wordId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="account != null">#{account},</if>
        </trim>
    </insert>

    <update id="updateQwForbiddenMessage" parameterType="QwForbiddenMessage">
        update qw_forbidden_message
        <trim prefix="SET" suffixOverrides=",">
            <if test="messageId != null">message_id = #{messageId},</if>
            <if test="conversationId != null">conversation_id = #{conversationId},</if>
            <if test="content != null">content = #{content},</if>
            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="wordId != null">word_id = #{wordId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="account != null">account = #{account},</if>
            <if test="sendTime != null">send_time = #{sendTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQwForbiddenMessageById" parameterType="Long">
        delete from qw_forbidden_message where id = #{id}
    </delete>

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