48 lines
1.8 KiB
XML
48 lines
1.8 KiB
XML
<?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.ai.mapper.AiConversationMapper">
|
|
|
|
<!-- 基础结果映射 -->
|
|
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.ai.TbAiConversation">
|
|
<id column="id" property="id" jdbcType="VARCHAR"/>
|
|
<result column="user_id" property="userID" jdbcType="VARCHAR"/>
|
|
<result column="title" property="title" jdbcType="VARCHAR"/>
|
|
<result column="status" property="status" jdbcType="INTEGER"/>
|
|
<result column="message_count" property="messageCount" jdbcType="INTEGER"/>
|
|
<result column="last_message_time" property="lastMessageTime" jdbcType="TIMESTAMP"/>
|
|
<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, title, status, message_count, last_message_time,
|
|
create_time, update_time
|
|
</sql>
|
|
|
|
<!-- 通用条件 -->
|
|
<sql id="Where_Clause">
|
|
<where>
|
|
<if test="userID != null and userID != ''">
|
|
AND user_id = #{userID}
|
|
</if>
|
|
<if test="title != null and title != ''">
|
|
AND title LIKE CONCAT('%', #{title}, '%')
|
|
</if>
|
|
<if test="status != null">
|
|
AND status = #{status}
|
|
</if>
|
|
</where>
|
|
</sql>
|
|
|
|
<!-- selectAiConversations -->
|
|
<select id="selectAiConversations" resultMap="BaseResultMap">
|
|
SELECT
|
|
<include refid="Base_Column_List"/>
|
|
FROM tb_ai_conversation
|
|
<include refid="Where_Clause"/>
|
|
ORDER BY last_message_time DESC, create_time DESC
|
|
</select>
|
|
|
|
</mapper>
|