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

    <resultMap type="WeChatMessageGather" id="WeChatMessageGatherResult">
        <result property="id"    column="id"    />
        <result property="seq"    column="seq"    />
        <result property="msgId"    column="msg_id"    />
        <result property="action"    column="action"    />
        <result property="fromUser"    column="from_user"    />
        <result property="toList"    column="to_list"    />
        <result property="roomId"    column="room_id"    />
        <result property="msgTime"    column="msg_time"    />
        <result property="msgType"    column="msg_type"    />
        <result property="text"    column="text"    />
        <result property="strData"    column="str_data"    />
        <result property="link"    column="link"    />
    </resultMap>

    <sql id="selectWeChatMessageGatherVo">
        select id, seq, msg_id, action, from_user, to_list, room_id, msg_time, msg_type, text, str_data, link from wechat_message
    </sql>

    <select id="selectWeChatMessageGatherList" parameterType="WeChatMessageGather" resultMap="WeChatMessageGatherResult">
        <include refid="selectWeChatMessageGatherVo"/>
        <where>
            <if test="seq != null "> and seq = #{seq}</if>
            <if test="msgId != null  and msgId != ''"> and msg_id = #{msgId}</if>
            <if test="action != null  and action != ''"> and action = #{action}</if>
            <if test="fromUser != null  and fromUser != ''"> and from_user = #{fromUser}</if>
            <if test="toList != null  and toList != ''"> and to_list = #{toList}</if>
            <if test="roomId != null  and roomId != ''"> and room_id = #{roomId}</if>
            <if test="msgTime != null "> and msg_time = #{msgTime}</if>
            <if test="msgType != null  and msgType != ''"> and msg_type = #{msgType}</if>
            <if test="text != null  and text != ''"> and text = #{text}</if>
            <if test="strData != null  and strData != ''"> and str_data = #{strData}</if>
            <if test="link != null  and link != ''"> and link = #{link}</if>
        </where>
    </select>

    <select id="selectWeChatMessageGatherById" parameterType="Long" resultMap="WeChatMessageGatherResult">
        <include refid="selectWeChatMessageGatherVo"/>
        where id = #{id}
    </select>

    <insert id="insertWeChatMessageGather" parameterType="WeChatMessageGather" useGeneratedKeys="true" keyProperty="id">
        insert into wechat_message
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="seq != null">seq,</if>
            <if test="msgId != null and msgId != ''">msg_id,</if>
            <if test="action != null">action,</if>
            <if test="fromUser != null">from_user,</if>
            <if test="toList != null">to_list,</if>
            <if test="roomId != null">room_id,</if>
            <if test="msgTime != null">msg_time,</if>
            <if test="msgType != null">msg_type,</if>
            <if test="text != null">text,</if>
            <if test="strData != null">str_data,</if>
            <if test="link != null">link,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="seq != null">#{seq},</if>
            <if test="msgId != null and msgId != ''">#{msgId},</if>
            <if test="action != null">#{action},</if>
            <if test="fromUser != null">#{fromUser},</if>
            <if test="toList != null">#{toList},</if>
            <if test="roomId != null">#{roomId},</if>
            <if test="msgTime != null">#{msgTime},</if>
            <if test="msgType != null">#{msgType},</if>
            <if test="text != null">#{text},</if>
            <if test="strData != null">#{strData},</if>
            <if test="link != null">#{link},</if>
        </trim>
    </insert>

    <update id="updateWeChatMessageGather" parameterType="WeChatMessageGather">
        update wechat_message
        <trim prefix="SET" suffixOverrides=",">
            <if test="seq != null">seq = #{seq},</if>
            <if test="msgId != null and msgId != ''">msg_id = #{msgId},</if>
            <if test="action != null">action = #{action},</if>
            <if test="fromUser != null">from_user = #{fromUser},</if>
            <if test="toList != null">to_list = #{toList},</if>
            <if test="roomId != null">room_id = #{roomId},</if>
            <if test="msgTime != null">msg_time = #{msgTime},</if>
            <if test="msgType != null">msg_type = #{msgType},</if>
            <if test="text != null">text = #{text},</if>
            <if test="strData != null">str_data = #{strData},</if>
            <if test="link != null">link = #{link},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWeChatMessageGatherById" parameterType="Long">
        delete from wechat_message where id = #{id}
    </delete>

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

</mapper>
