| <?xml version="1.0" encoding="UTF-8" ?> | 
 | <!-- | 
 |   ~ Licensed to the Apache Software Foundation (ASF) under one | 
 |   ~ or more contributor license agreements.  See the NOTICE file | 
 |   ~ distributed with this work for additional information | 
 |   ~ regarding copyright ownership.  The ASF licenses this file | 
 |   ~ to you under the Apache License, Version 2.0 (the | 
 |   ~ "License"); you may not use this file except in compliance | 
 |   ~ with the License.  You may obtain a copy of the License at | 
 |   ~ | 
 |   ~   http://www.apache.org/licenses/LICENSE-2.0 | 
 |   ~ | 
 |   ~ Unless required by applicable law or agreed to in writing, | 
 |   ~ software distributed under the License is distributed on an | 
 |   ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | 
 |   ~ KIND, either express or implied.  See the License for the | 
 |   ~ specific language governing permissions and limitations | 
 |   ~ under the License. | 
 | --> | 
 | <!DOCTYPE mapper | 
 |         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | 
 |         "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
 | <mapper namespace="org.apache.bigtop.manager.dao.repository.ChatThreadDao"> | 
 |     <sql id="baseColumns"> | 
 |         id, user_id, platform_id, model | 
 |     </sql> | 
 |  | 
 |     <resultMap id="ChatThreadResultMap" type="org.apache.bigtop.manager.dao.po.ChatThreadPO"> | 
 |         <result property="threadInfo" column="thread_info" typeHandler="org.apache.bigtop.manager.dao.handler.JsonTypeHandler"/> | 
 |     </resultMap> | 
 |  | 
 |     <select id="findAllByUserId" resultType="org.apache.bigtop.manager.dao.po.ChatThreadPO"> | 
 |         SELECT * | 
 |         FROM llm_chat_thread | 
 |         WHERE user_id = #{userId} | 
 |         AND is_deleted = 0 | 
 |     </select> | 
 |  | 
 |     <select id="findAllByPlatformAuthorizedIdAndUserId" resultType="org.apache.bigtop.manager.dao.po.ChatThreadPO"> | 
 |         SELECT * | 
 |         FROM llm_chat_thread | 
 |         WHERE platform_id = #{platformId} AND user_id = #{userId} AND is_deleted = 0 | 
 |     </select> | 
 |  | 
 |     <select id="findByThreadId" resultMap="ChatThreadResultMap"> | 
 |         SELECT * FROM llm_chat_thread WHERE id = #{id} AND is_deleted = 0 | 
 |     </select> | 
 |  | 
 |     <insert id="saveWithThreadInfo" parameterType="org.apache.bigtop.manager.dao.po.ChatThreadPO" useGeneratedKeys="true" keyProperty="id"> | 
 |         INSERT INTO llm_chat_thread (platform_id, user_id, model, thread_info) | 
 |         VALUES (#{platformId}, #{userId}, #{model}, #{threadInfo, typeHandler=org.apache.bigtop.manager.dao.handler.JsonTypeHandler}) | 
 |             ON DUPLICATE KEY UPDATE | 
 |             platform_id = VALUES(platform_id), | 
 |             user_id = VALUES(user_id), | 
 |             model = VALUES(model), | 
 |             thread_info = VALUES(thread_info) | 
 |     </insert> | 
 |  | 
 |     <select id="findAllByPlatformId" resultType="org.apache.bigtop.manager.dao.po.ChatThreadPO"> | 
 |         SELECT * | 
 |         FROM llm_chat_thread | 
 |         WHERE platform_id = #{platformId} AND is_deleted = 0 | 
 |     </select> | 
 |  | 
 | </mapper> |