You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
2.0 KiB
50 lines
2.0 KiB
<?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.learning.newdemo.mapper.WxConversationMapper">
|
|
|
|
<!-- 基础结果映射 -->
|
|
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.WxConversation">
|
|
<id column="id" property="id" jdbcType="BIGINT"/>
|
|
<result column="user_id" property="userId" jdbcType="BIGINT"/>
|
|
<result column="type" property="type" jdbcType="VARCHAR"/>
|
|
<result column="title" property="title" jdbcType="VARCHAR"/>
|
|
<result column="preview" property="preview" jdbcType="VARCHAR"/>
|
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
|
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
|
</resultMap>
|
|
|
|
<!-- 可复用的列名列表 -->
|
|
<sql id="Base_Column_List">
|
|
id, user_id, type, title, preview, create_time, update_time
|
|
</sql>
|
|
|
|
<!-- 按用户ID和类型查询对话活动 (用于接口4.1) -->
|
|
<select id="selectByUserId" resultMap="BaseResultMap">
|
|
SELECT <include refid="Base_Column_List"/>
|
|
FROM wx_conversation
|
|
WHERE user_id = #{userId}
|
|
ORDER BY update_time DESC
|
|
</select>
|
|
|
|
<!-- 插入新对话活动 (用于接口3.1/3.2/3.3) -->
|
|
<insert id="insert" parameterType="com.learning.newdemo.entity.WxConversation"
|
|
useGeneratedKeys="true" keyProperty="id">
|
|
INSERT INTO wx_conversation (
|
|
user_id, type, title, preview, create_time, update_time
|
|
)
|
|
VALUES (
|
|
#{userId}, #{type}, #{title}, #{preview}, #{createTime}, #{updateTime}
|
|
)
|
|
</insert>
|
|
|
|
<!-- 更新对话预览信息 (用于更新最后一次AI回复的预览) -->
|
|
<update id="updatePreview">
|
|
UPDATE wx_conversation
|
|
SET
|
|
preview = #{preview},
|
|
update_time = NOW()
|
|
WHERE id = #{conversationId}
|
|
</update>
|
|
|
|
</mapper>
|