项目初始化
This commit is contained in:
117
ruoyi-admin/src/main/resources/mapper/ai/ChatMessageMapper.xml
Normal file
117
ruoyi-admin/src/main/resources/mapper/ai/ChatMessageMapper.xml
Normal file
@@ -0,0 +1,117 @@
|
||||
<?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.ruoyi.ai.message.mapper.ChatMessageMapper">
|
||||
|
||||
<resultMap type="ChatMessage" id="ChatMessageResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sessionId" column="session_id" />
|
||||
<result property="conversationId" column="conversation_id" />
|
||||
<result property="content" column="content" />
|
||||
<result property="role" column="role" />
|
||||
<result property="deductCost" column="deduct_cost" />
|
||||
<result property="totalTokens" column="total_tokens" />
|
||||
<result property="modelName" column="model_name" />
|
||||
<result property="createDept" column="create_dept" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectChatMessageVo">
|
||||
select id, session_id, conversation_id, content, role, deduct_cost, total_tokens, model_name, create_dept, create_by, create_time, update_by, update_time, remark from chat_message
|
||||
</sql>
|
||||
|
||||
<select id="selectChatMessageList" parameterType="ChatMessage" resultMap="ChatMessageResult">
|
||||
<include refid="selectChatMessageVo"/>
|
||||
<where>
|
||||
<if test="sessionId != null "> and session_id = #{sessionId}</if>
|
||||
<if test="conversationId != null "> and conversation_id = #{conversationId}</if>
|
||||
<if test="content != null and content != ''"> and content = #{content}</if>
|
||||
<if test="role != null and role != ''"> and role = #{role}</if>
|
||||
<if test="deductCost != null "> and deduct_cost = #{deductCost}</if>
|
||||
<if test="totalTokens != null "> and total_tokens = #{totalTokens}</if>
|
||||
<if test="modelName != null and modelName != ''"> and model_name like concat('%', #{modelName}, '%')</if>
|
||||
<if test="createDept != null "> and create_dept = #{createDept}</if>
|
||||
</where>
|
||||
order by create_time asc
|
||||
</select>
|
||||
|
||||
<select id="selectChatMessageById" parameterType="Long" resultMap="ChatMessageResult">
|
||||
<include refid="selectChatMessageVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertChatMessage" parameterType="ChatMessage">
|
||||
insert into chat_message
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="sessionId != null">session_id,</if>
|
||||
<if test="conversationId != null">conversation_id,</if>
|
||||
<if test="content != null">content,</if>
|
||||
<if test="role != null">role,</if>
|
||||
<if test="deductCost != null">deduct_cost,</if>
|
||||
<if test="totalTokens != null">total_tokens,</if>
|
||||
<if test="modelName != null">model_name,</if>
|
||||
<if test="createDept != null">create_dept,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="sessionId != null">#{sessionId},</if>
|
||||
<if test="conversationId != null">#{conversationId},</if>
|
||||
<if test="content != null">#{content},</if>
|
||||
<if test="role != null">#{role},</if>
|
||||
<if test="deductCost != null">#{deductCost},</if>
|
||||
<if test="totalTokens != null">#{totalTokens},</if>
|
||||
<if test="modelName != null">#{modelName},</if>
|
||||
<if test="createDept != null">#{createDept},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateChatMessage" parameterType="ChatMessage">
|
||||
update chat_message
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sessionId != null">session_id = #{sessionId},</if>
|
||||
<if test="conversationId != null">conversation_id = #{conversationId},</if>
|
||||
<if test="content != null">content = #{content},</if>
|
||||
<if test="role != null">role = #{role},</if>
|
||||
<if test="deductCost != null">deduct_cost = #{deductCost},</if>
|
||||
<if test="totalTokens != null">total_tokens = #{totalTokens},</if>
|
||||
<if test="modelName != null">model_name = #{modelName},</if>
|
||||
<if test="createDept != null">create_dept = #{createDept},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteChatMessageById" parameterType="Long">
|
||||
delete from chat_message where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteChatMessageByIds" parameterType="String">
|
||||
delete from chat_message where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<delete id="deleteChatMessageByConversationId">
|
||||
delete from chat_message where conversation_id = #{conversationId}
|
||||
</delete>
|
||||
</mapper>
|
||||
107
ruoyi-admin/src/main/resources/mapper/ai/ConversationsMapper.xml
Normal file
107
ruoyi-admin/src/main/resources/mapper/ai/ConversationsMapper.xml
Normal file
@@ -0,0 +1,107 @@
|
||||
<?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.ruoyi.ai.conversation.mapper.ConversationsMapper">
|
||||
|
||||
<resultMap type="Conversations" id="ConversationsResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sessionId" column="session_id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="title" column="title" />
|
||||
<result property="status" column="status" />
|
||||
<result property="metadata" column="metadata" />
|
||||
<result property="firstQuery" column="first_query" />
|
||||
<result property="messageCount" column="message_count" />
|
||||
<result property="tokenUsage" column="token_usage" />
|
||||
<result property="createdAt" column="created_at" />
|
||||
<result property="updatedAt" column="updated_at" />
|
||||
<result property="lastInteractionAt" column="last_interaction_at" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectConversationsVo">
|
||||
select id, session_id, user_id, title, status, metadata, first_query, message_count, token_usage, created_at, updated_at, last_interaction_at from conversations
|
||||
</sql>
|
||||
|
||||
<select id="selectConversationsList" parameterType="Conversations" resultMap="ConversationsResult">
|
||||
<include refid="selectConversationsVo"/>
|
||||
<where>
|
||||
<if test="sessionId != null and sessionId != ''"> and session_id = #{sessionId}</if>
|
||||
<if test="userId != null and userId != ''"> and user_id = #{userId}</if>
|
||||
<if test="title != null and title != ''"> and title = #{title}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="metadata != null and metadata != ''"> and metadata = #{metadata}</if>
|
||||
<if test="firstQuery != null and firstQuery != ''"> and first_query = #{firstQuery}</if>
|
||||
<if test="messageCount != null "> and message_count = #{messageCount}</if>
|
||||
<if test="tokenUsage != null "> and token_usage = #{tokenUsage}</if>
|
||||
<if test="createdAt != null "> and created_at = #{createdAt}</if>
|
||||
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
|
||||
<if test="lastInteractionAt != null "> and last_interaction_at = #{lastInteractionAt}</if>
|
||||
order by id desc
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectConversationsById" parameterType="Long" resultMap="ConversationsResult">
|
||||
<include refid="selectConversationsVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertConversations" parameterType="Conversations" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into conversations
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sessionId != null and sessionId != ''">session_id,</if>
|
||||
<if test="userId != null and userId != ''">user_id,</if>
|
||||
<if test="title != null">title,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="metadata != null">metadata,</if>
|
||||
<if test="firstQuery != null">first_query,</if>
|
||||
<if test="messageCount != null">message_count,</if>
|
||||
<if test="tokenUsage != null">token_usage,</if>
|
||||
<if test="createdAt != null">created_at,</if>
|
||||
<if test="updatedAt != null">updated_at,</if>
|
||||
<if test="lastInteractionAt != null">last_interaction_at,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sessionId != null and sessionId != ''">#{sessionId},</if>
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
<if test="title != null">#{title},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="metadata != null">#{metadata},</if>
|
||||
<if test="firstQuery != null">#{firstQuery},</if>
|
||||
<if test="messageCount != null">#{messageCount},</if>
|
||||
<if test="tokenUsage != null">#{tokenUsage},</if>
|
||||
<if test="createdAt != null">#{createdAt},</if>
|
||||
<if test="updatedAt != null">#{updatedAt},</if>
|
||||
<if test="lastInteractionAt != null">#{lastInteractionAt},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateConversations" parameterType="Conversations">
|
||||
update conversations
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sessionId != null and sessionId != ''">session_id = #{sessionId},</if>
|
||||
<if test="userId != null and userId != ''">user_id = #{userId},</if>
|
||||
<if test="title != null">title = #{title},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="metadata != null">metadata = #{metadata},</if>
|
||||
<if test="firstQuery != null">first_query = #{firstQuery},</if>
|
||||
<if test="messageCount != null">message_count = #{messageCount},</if>
|
||||
<if test="tokenUsage != null">token_usage = #{tokenUsage},</if>
|
||||
<if test="createdAt != null">created_at = #{createdAt},</if>
|
||||
<if test="updatedAt != null">updated_at = #{updatedAt},</if>
|
||||
<if test="lastInteractionAt != null">last_interaction_at = #{lastInteractionAt},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteConversationsById" parameterType="Long">
|
||||
delete from conversations where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteConversationsByIds" parameterType="String">
|
||||
delete from conversations where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user