blob: d9aac6ff20a7f31127aa9b03a0668c105cf3e49a [file] [log] [blame]
<?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>