123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?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.doc.chat.mapper.ChatMsgMapper">
- <resultMap type="ChatMsg" id="ChatMsgResult">
- <result property="msgId" column="MSG_ID"/>
- <result property="fromId" column="FROM_ID"/>
- <result property="toId" column="TO_ID"/>
- <result property="isRead" column="IS_READ"/>
- <result property="msgType" column="MSG_TYPE"/>
- <result property="content" column="CONTENT"/>
- <result property="idIndex" column="ID_INDEX"/>
- <result property="createTime" column="CREATE_TIME"/>
- </resultMap>
- <sql id="selectChatMsgVo">
- select MSG_ID,
- FROM_ID,
- TO_ID,
- MSG_TYPE,
- CONTENT,
- IS_READ,
- ID_INDEX,
- CREATE_TIME
- from chat_msg
- </sql>
- <select id="selectChatMsgList" parameterType="ChatMsg" resultMap="ChatMsgResult">
- <include refid="selectChatMsgVo"/>
- <where>
- <if test="fromId != null ">and FROM_ID = #{fromId}</if>
- <if test="toId != null ">and TO_ID = #{toId}</if>
- <if test="isRead != null ">and IS_READ = #{isRead}</if>
- <if test="msgType != null and msgType != ''">and MSG_TYPE = #{msgType}</if>
- <if test="content != null and content != ''">and CONTENT = #{content}</if>
- <if test="idIndex != null and idIndex != ''">and ID_INDEX = #{idIndex}</if>
- <if test="createTime != null ">and CREATE_TIME = #{createTime}</if>
- </where>
- </select>
- <select id="selectChatMsgByMsgId" parameterType="Long" resultMap="ChatMsgResult">
- <include refid="selectChatMsgVo"/>
- where MSG_ID = #{msgId}
- </select>
- <select id="selectFriendList" resultType="com.doc.chat.domain.ChatMsg">
- <include refid="selectChatMsgVo"/>
- where msg_id in (SELECT MAX(msg_id) msg_id
- FROM chat_msg
- WHERE from_id = #{userId} OR to_id = #{userId}
- GROUP BY id_index)
- ORDER BY create_time desc,msg_id desc
- </select>
- <select id="selectRecordList" resultType="com.doc.chat.domain.ChatMsg">
- <include refid="selectChatMsgVo"/>
- where id_index=#{idIndex}
- order by CREATE_TIME desc
- </select>
- <insert id="insertChatMsg" parameterType="ChatMsg" useGeneratedKeys="true" keyProperty="msgId">
- insert into chat_msg
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="fromId != null">FROM_ID,</if>
- <if test="toId != null">TO_ID,</if>
- <if test="isRead != null">IS_READ,</if>
- <if test="msgType != null">MSG_TYPE,</if>
- <if test="content != null">CONTENT,</if>
- <if test="idIndex != null">ID_INDEX,</if>
- <if test="createTime != null">CREATE_TIME,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="fromId != null">#{fromId},</if>
- <if test="toId != null">#{toId},</if>
- <if test="isRead != null">#{isRead},</if>
- <if test="msgType != null">#{msgType},</if>
- <if test="content != null">#{content},</if>
- <if test="idIndex != null">#{idIndex},</if>
- <if test="createTime != null">#{createTime},</if>
- </trim>
- </insert>
- <update id="updateChatMsg" parameterType="ChatMsg">
- update chat_msg
- <trim prefix="SET" suffixOverrides=",">
- <if test="fromId != null">FROM_ID = #{fromId},</if>
- <if test="toId != null">TO_ID = #{toId},</if>
- <if test="isRead != null">IS_READ=#{isRead},</if>
- <if test="msgType != null">MSG_TYPE = #{msgType},</if>
- <if test="content != null">CONTENT = #{content},</if>
- <if test="idIndex != null">ID_INDEX = #{idIndex},</if>
- <if test="createTime != null">CREATE_TIME = #{createTime},</if>
- </trim>
- where MSG_ID = #{msgId}
- </update>
- <delete id="deleteChatMsgByMsgId" parameterType="Long">
- delete
- from chat_msg
- where MSG_ID = #{msgId}
- </delete>
- <delete id="deleteChatMsgByMsgIds" parameterType="String">
- delete from chat_msg where MSG_ID in
- <foreach item="msgId" collection="array" open="(" separator="," close=")">
- #{msgId}
- </foreach>
- </delete>
- </mapper>
|