blob: d9aac6ff20a7f31127aa9b03a0668c105cf3e49a [file] [log] [blame]
ym9230fd7c292025-06-06 17:40:03 +08001<?xml version="1.0" encoding="UTF-8" ?>
2<!DOCTYPE mapper
3 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
6<mapper namespace="com.pt5.pthouduan.mapper.ChatInformationMapper">
7
8 <!-- 插入聊天记录 -->
9 <insert id="insertChat" parameterType="com.pt5.pthouduan.entity.ChatInformation" useGeneratedKeys="true" keyProperty="informationid">
10 INSERT INTO chat_information (sender_id, receiver_id, content)
11 VALUES (#{senderId}, #{receiverId}, #{content})
12 </insert>
13
14 <!-- 删除聊天记录 -->
15 <delete id="deleteChatById" parameterType="int">
16 DELETE FROM chat_information WHERE informationid = #{value}
17 </delete>
18
19 <!-- 查询某用户参与的所有聊天记录 -->
20 <select id="selectChatsByUser" parameterType="long" resultType="com.pt5.pthouduan.entity.ChatInformation">
21 SELECT * FROM chat_information
22 WHERE sender_id = #{userId} OR receiver_id = #{userId}
23 ORDER BY talk_time ASC
24 </select>
25
26 <!-- 查询两个用户之间的聊天记录 -->
27 <select id="selectChatsBetweenUsers" parameterType="map" resultType="com.pt5.pthouduan.entity.ChatInformation">
28 SELECT * FROM chat_information
29 WHERE (sender_id = #{user1} AND receiver_id = #{user2})
30 OR (sender_id = #{user2} AND receiver_id = #{user1})
31 ORDER BY talk_time ASC
32 </select>
33
34</mapper>