对话相关上传

Change-Id: I4eb3223e650cd40905f51691e1d5d3204d981693
diff --git a/src/main/resources/mapper/ChatInformationMapper.xml b/src/main/resources/mapper/ChatInformationMapper.xml
new file mode 100644
index 0000000..d9aac6f
--- /dev/null
+++ b/src/main/resources/mapper/ChatInformationMapper.xml
@@ -0,0 +1,34 @@
+<?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.pt5.pthouduan.mapper.ChatInformationMapper">
+
+    <!-- 插入聊天记录 -->
+    <insert id="insertChat" parameterType="com.pt5.pthouduan.entity.ChatInformation" useGeneratedKeys="true" keyProperty="informationid">
+        INSERT INTO chat_information (sender_id, receiver_id, content)
+        VALUES (#{senderId}, #{receiverId}, #{content})
+    </insert>
+
+    <!-- 删除聊天记录 -->
+    <delete id="deleteChatById" parameterType="int">
+        DELETE FROM chat_information WHERE informationid = #{value}
+    </delete>
+
+    <!-- 查询某用户参与的所有聊天记录 -->
+    <select id="selectChatsByUser" parameterType="long" resultType="com.pt5.pthouduan.entity.ChatInformation">
+        SELECT * FROM chat_information
+        WHERE sender_id = #{userId} OR receiver_id = #{userId}
+        ORDER BY talk_time ASC
+    </select>
+
+    <!-- 查询两个用户之间的聊天记录 -->
+    <select id="selectChatsBetweenUsers" parameterType="map" resultType="com.pt5.pthouduan.entity.ChatInformation">
+        SELECT * FROM chat_information
+        WHERE (sender_id = #{user1} AND receiver_id = #{user2})
+           OR (sender_id = #{user2} AND receiver_id = #{user1})
+        ORDER BY talk_time ASC
+    </select>
+
+</mapper>