Skip to content

Commit

Permalink
add pg
Browse files Browse the repository at this point in the history
  • Loading branch information
lhpqaq committed Sep 15, 2024
1 parent e581a3c commit f014c56
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
SELECT *
FROM llm_chat_message
WHERE thread_id = #{threadId}
AND is_deleted = false
</select>

<delete id="deleteByThreadId">
DELETE FROM llm_chat_message
<update id="deleteByThreadId" parameterType="java.lang.Long">
UPDATE llm_chat_message
SET is_deleted = true
WHERE thread_id = #{threadId}
</delete>
</update>

</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,39 @@
SELECT *
FROM llm_chat_thread
WHERE user_id = #{userId}
AND is_deleted = false
</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}
WHERE platform_id = #{platformId} AND user_id = #{userId} AND is_deleted = false
</select>

<select id="findByThreadId" resultMap="ChatThreadResultMap">
SELECT * FROM llm_chat_thread WHERE id = #{id}
SELECT * FROM llm_chat_thread WHERE id = #{id} AND is_deleted = false
</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)
platform_id = VALUES(platform_id),
user_id = VALUES(user_id),
model = VALUES(model),
thread_info = VALUES(thread_info)
</insert>

<update id="deleteByPlatformId" parameterType="java.lang.Long">
UPDATE llm_chat_thread
SET is_deleted = true
WHERE platform_id = #{platformId}
</update>

<update id="deleteByThreadId" parameterType="java.lang.Long">
UPDATE llm_chat_thread
SET is_deleted = true
WHERE id = #{id}
</update>

</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
</resultMap>

<select id="findByPlatformId" resultMap="PlatformAuthorizedResultMap">
SELECT * FROM llm_platform_authorized WHERE id = #{id}
SELECT * FROM llm_platform_authorized WHERE id = #{id} AND is_deleted = false
</select>

<select id="findAllPlatform" resultMap="PlatformAuthorizedResultMap">
SELECT * FROM llm_platform_authorized WHERE is_deleted = false
</select>

<insert id="saveWithCredentials" parameterType="org.apache.bigtop.manager.dao.po.PlatformAuthorizedPO" useGeneratedKeys="true" keyProperty="id">
Expand All @@ -42,4 +46,10 @@
credentials = VALUES(credentials)
</insert>

<update id="deleteByPlatformId" parameterType="java.lang.Long">
UPDATE llm_platform_authorized
SET is_deleted =true
WHERE id = #{id}
</update>

</mapper>

0 comments on commit f014c56

Please sign in to comment.