Files
urbanLifeline/urbanLifelineServ/workcase/src/main/resources/mapper/TbChatMessageMapper.xml

155 lines
9.5 KiB
XML
Raw Normal View History

2025-12-22 11:24:30 +08:00
<?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="org.xyzh.workcase.mapper.TbChatMessageMapper">
2025-12-22 13:08:08 +08:00
<resultMap id="BaseResultMap" type="org.xyzh.api.workcase.dto.TbChatRoomMessageDTO">
2025-12-22 11:24:30 +08:00
<id column="message_id" property="messageId" jdbcType="VARCHAR"/>
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="room_id" property="roomId" jdbcType="VARCHAR"/>
<result column="sender_id" property="senderId" jdbcType="VARCHAR"/>
<result column="sender_type" property="senderType" jdbcType="VARCHAR"/>
<result column="sender_name" property="senderName" jdbcType="VARCHAR"/>
<result column="message_type" property="messageType" jdbcType="VARCHAR"/>
<result column="content" property="content" jdbcType="VARCHAR"/>
<result column="files" property="files" jdbcType="ARRAY" typeHandler="org.xyzh.common.jdbc.handler.StringArrayTypeHandler"/>
2025-12-26 18:55:54 +08:00
<result column="content_extra" property="contentExtra" jdbcType="OTHER" typeHandler="org.xyzh.common.jdbc.handler.FastJson2TypeHandler"/>
2025-12-22 11:24:30 +08:00
<result column="reply_to_msg_id" property="replyToMsgId" jdbcType="VARCHAR"/>
<result column="is_ai_message" property="isAiMessage" jdbcType="BOOLEAN"/>
<result column="ai_message_id" property="aiMessageId" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="VARCHAR"/>
<result column="read_count" property="readCount" jdbcType="INTEGER"/>
<result column="send_time" property="sendTime" jdbcType="TIMESTAMP"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
2025-12-22 13:08:08 +08:00
<resultMap id="VOResultMap" type="org.xyzh.api.workcase.vo.ChatRoomMessageVO">
2025-12-22 11:24:30 +08:00
<id column="message_id" property="messageId" jdbcType="VARCHAR"/>
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="room_id" property="roomId" jdbcType="VARCHAR"/>
<result column="sender_id" property="senderId" jdbcType="VARCHAR"/>
<result column="sender_type" property="senderType" jdbcType="VARCHAR"/>
<result column="sender_name" property="senderName" jdbcType="VARCHAR"/>
<result column="message_type" property="messageType" jdbcType="VARCHAR"/>
<result column="content" property="content" jdbcType="VARCHAR"/>
<result column="files" property="files" jdbcType="ARRAY" typeHandler="org.xyzh.common.jdbc.handler.StringArrayTypeHandler"/>
2025-12-26 18:55:54 +08:00
<result column="content_extra" property="contentExtra" jdbcType="OTHER" typeHandler="org.xyzh.common.jdbc.handler.FastJson2TypeHandler"/>
2025-12-22 11:24:30 +08:00
<result column="reply_to_msg_id" property="replyToMsgId" jdbcType="VARCHAR"/>
<result column="is_ai_message" property="isAiMessage" jdbcType="BOOLEAN"/>
<result column="ai_message_id" property="aiMessageId" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="VARCHAR"/>
<result column="read_count" property="readCount" jdbcType="INTEGER"/>
<result column="send_time" property="sendTime" jdbcType="TIMESTAMP"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
message_id, optsn, room_id, sender_id, sender_type, sender_name, message_type,
content, files, content_extra, reply_to_msg_id, is_ai_message, ai_message_id,
status, read_count, send_time, creator, create_time, update_time
</sql>
2025-12-22 13:08:08 +08:00
<insert id="insertChatMessage" parameterType="org.xyzh.api.workcase.dto.TbChatRoomMessageDTO">
INSERT INTO workcase.tb_chat_room_message (
2025-12-22 11:24:30 +08:00
optsn, message_id, room_id, sender_id, sender_type, sender_name, content, creator
<if test="messageType != null">, message_type</if>
<if test="files != null">, files</if>
<if test="contentExtra != null">, content_extra</if>
<if test="replyToMsgId != null">, reply_to_msg_id</if>
<if test="isAiMessage != null">, is_ai_message</if>
<if test="aiMessageId != null">, ai_message_id</if>
<if test="status != null">, status</if>
<if test="sendTime != null">, send_time</if>
<if test="createTime != null">, create_time</if>
2025-12-22 11:24:30 +08:00
) VALUES (
#{optsn}, #{messageId}, #{roomId}, #{senderId}, #{senderType}, #{senderName}, #{content}, #{creator}
<if test="messageType != null">, #{messageType}</if>
<if test="files != null">, #{files, typeHandler=org.xyzh.common.jdbc.handler.StringArrayTypeHandler}</if>
2025-12-26 18:55:54 +08:00
<if test="contentExtra != null">, #{contentExtra, typeHandler=org.xyzh.common.jdbc.handler.FastJson2TypeHandler}::jsonb</if>
2025-12-22 11:24:30 +08:00
<if test="replyToMsgId != null">, #{replyToMsgId}</if>
<if test="isAiMessage != null">, #{isAiMessage}</if>
<if test="aiMessageId != null">, #{aiMessageId}</if>
<if test="status != null">, #{status}</if>
<if test="sendTime != null">, send_time</if>
<if test="createTime != null">, #{createTime}</if>
2025-12-22 11:24:30 +08:00
)
</insert>
2025-12-22 13:08:08 +08:00
<update id="updateChatMessage" parameterType="org.xyzh.api.workcase.dto.TbChatRoomMessageDTO">
UPDATE workcase.tb_chat_room_message
2025-12-22 11:24:30 +08:00
<set>
<if test="content != null">content = #{content},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="readCount != null">read_count = #{readCount},</if>
update_time = now()
</set>
WHERE message_id = #{messageId}
</update>
2025-12-22 13:08:08 +08:00
<delete id="deleteChatMessage" parameterType="org.xyzh.api.workcase.dto.TbChatRoomMessageDTO">
DELETE FROM workcase.tb_chat_room_message
2025-12-22 11:24:30 +08:00
WHERE message_id = #{messageId}
</delete>
<select id="selectChatMessageById" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"/>
2025-12-22 13:08:08 +08:00
FROM workcase.tb_chat_room_message
2025-12-22 11:24:30 +08:00
WHERE message_id = #{messageId}
</select>
<select id="selectChatMessageList" resultMap="VOResultMap">
SELECT <include refid="Base_Column_List"/>
2025-12-22 13:08:08 +08:00
FROM workcase.tb_chat_room_message
2025-12-22 11:24:30 +08:00
<where>
<if test="filter.messageId != null and filter.messageId != ''">AND message_id = #{filter.messageId}</if>
<if test="filter.roomId != null and filter.roomId != ''">AND room_id = #{filter.roomId}</if>
<if test="filter.senderId != null and filter.senderId != ''">AND sender_id = #{filter.senderId}</if>
<if test="filter.senderType != null and filter.senderType != ''">AND sender_type = #{filter.senderType}</if>
<if test="filter.messageType != null and filter.messageType != ''">AND message_type = #{filter.messageType}</if>
<if test="filter.isAiMessage != null">AND is_ai_message = #{filter.isAiMessage}</if>
<if test="filter.status != null and filter.status != ''">AND status = #{filter.status}</if>
</where>
ORDER BY send_time DESC
</select>
<select id="selectChatMessagePage" resultMap="VOResultMap">
SELECT <include refid="Base_Column_List"/>
2025-12-22 13:08:08 +08:00
FROM workcase.tb_chat_room_message
2025-12-22 11:24:30 +08:00
<where>
<if test="filter.messageId != null and filter.messageId != ''">AND message_id = #{filter.messageId}</if>
<if test="filter.roomId != null and filter.roomId != ''">AND room_id = #{filter.roomId}</if>
<if test="filter.senderId != null and filter.senderId != ''">AND sender_id = #{filter.senderId}</if>
<if test="filter.senderType != null and filter.senderType != ''">AND sender_type = #{filter.senderType}</if>
<if test="filter.messageType != null and filter.messageType != ''">AND message_type = #{filter.messageType}</if>
<if test="filter.isAiMessage != null">AND is_ai_message = #{filter.isAiMessage}</if>
<if test="filter.status != null and filter.status != ''">AND status = #{filter.status}</if>
</where>
ORDER BY send_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<select id="countChatMessages" resultType="long">
SELECT COUNT(*)
2025-12-22 13:08:08 +08:00
FROM workcase.tb_chat_room_message
2025-12-22 11:24:30 +08:00
<where>
<if test="filter.messageId != null and filter.messageId != ''">AND message_id = #{filter.messageId}</if>
<if test="filter.roomId != null and filter.roomId != ''">AND room_id = #{filter.roomId}</if>
<if test="filter.senderId != null and filter.senderId != ''">AND sender_id = #{filter.senderId}</if>
<if test="filter.senderType != null and filter.senderType != ''">AND sender_type = #{filter.senderType}</if>
<if test="filter.messageType != null and filter.messageType != ''">AND message_type = #{filter.messageType}</if>
<if test="filter.isAiMessage != null">AND is_ai_message = #{filter.isAiMessage}</if>
<if test="filter.status != null and filter.status != ''">AND status = #{filter.status}</if>
</where>
</select>
2025-12-24 15:02:23 +08:00
<select id="selectChatMessageVOById" resultMap="VOResultMap">
SELECT <include refid="Base_Column_List"/>
FROM workcase.tb_chat_room_message
WHERE message_id = #{messageId}
</select>
2025-12-22 11:24:30 +08:00
</mapper>