FastGptChatSessionMapper.xml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.fastGpt.mapper.FastGptChatSessionMapper">
  6. <resultMap type="FastGptChatSession" id="FastGptChatSessionResult">
  7. <result property="sessionId" column="session_id" />
  8. <result property="chatId" column="chat_id" />
  9. <result property="userId" column="user_id" />
  10. <result property="kfId" column="kf_id" />
  11. <result property="createTime" column="create_time" />
  12. <result property="updateTime" column="update_time" />
  13. <result property="status" column="status" />
  14. <result property="companyId" column="company_id" />
  15. <result property="isLook" column="is_look" />
  16. <result property="userType" column="user_type" />
  17. <result property="nickName" column="nick_name" />
  18. <result property="avatar" column="avatar" />
  19. <result property="isArtificial" column="is_artificial" />
  20. <result property="remindTime" column="remind_time" />
  21. <result property="remindStatus" column="remind_status" />
  22. <result property="remindCount" column="remind_count" />
  23. <result property="qwExtId" column="qw_ext_id" />
  24. <result property="qwUserId" column="qw_user_id" />
  25. <result property="lastTime" column="last_time" />
  26. <result property="isReply" column="is_reply" />
  27. <result property="userInfo" column="user_info" />
  28. </resultMap>
  29. <sql id="selectFastGptChatSessionVo">
  30. select session_id,remind_time,is_reply,last_time,remind_status,remind_count,qw_ext_id,qw_user_id,chat_id,is_artificial, user_id, kf_id, create_time, update_time, status, company_id, is_look, user_type, nick_name, avatar from fastgpt_chat_session
  31. </sql>
  32. <sql id="Base_Column_List">
  33. session_id,
  34. chat_id,
  35. user_id,
  36. qw_ext_id,
  37. qw_user_id,
  38. kf_id,
  39. status,
  40. company_id,
  41. is_look,
  42. user_type,
  43. nick_name,
  44. avatar,
  45. is_artificial,
  46. create_time,
  47. update_time,
  48. remind_time,
  49. remind_status,
  50. remind_count,
  51. last_time,
  52. is_reply,
  53. user_info
  54. </sql>
  55. <select id="selectFastGptChatSessionList" parameterType="FastGptChatSession" resultMap="FastGptChatSessionResult">
  56. <include refid="selectFastGptChatSessionVo"/>
  57. <where>
  58. <if test="chatId != null and chatId != ''"> and chat_id = #{chatId}</if>
  59. <if test="userId != null and userId != ''"> and user_id = #{userId}</if>
  60. <if test="kfId != null and kfId != ''"> and kf_id = #{kfId}</if>
  61. <if test="status != null "> and status = #{status}</if>
  62. <if test="companyId != null "> and company_id = #{companyId}</if>
  63. <if test="isLook != null "> and is_look = #{isLook}</if>
  64. <if test="userType != null "> and user_type = #{userType}</if>
  65. <if test="nickName != null and nickName != ''"> and nick_name like concat( #{nickName}, '%')</if>
  66. <if test="avatar != null and avatar != ''"> and avatar = #{avatar}</if>
  67. </where>
  68. </select>
  69. <select id="selectFastGptChatSessionBySessionId" parameterType="Long" resultMap="FastGptChatSessionResult">
  70. <include refid="selectFastGptChatSessionVo"/>
  71. where session_id = #{sessionId}
  72. </select>
  73. <select id="selectSessionByTriple" resultType="com.fs.fastGpt.domain.FastGptChatSession">
  74. SELECT <include refid="Base_Column_List"/>
  75. FROM fastgpt_chat_session
  76. <where>
  77. <if test="companyId != null and companyId != ''">
  78. AND company_id = #{companyId}
  79. </if>
  80. <if test="qwExternalId != null and qwExternalId != ''">
  81. AND qw_ext_id = #{qwExternalId}
  82. </if>
  83. <if test="qwUserId != null and qwUserId != ''">
  84. AND qw_user_id = #{qwUserId}
  85. </if>
  86. </where>
  87. ORDER BY create_time DESC
  88. </select>
  89. <insert id="insertFastGptChatSession" parameterType="FastGptChatSession" useGeneratedKeys="true" keyProperty="sessionId">
  90. insert into fastgpt_chat_session
  91. <trim prefix="(" suffix=")" suffixOverrides=",">
  92. <if test="sessionId != null">session_id,</if>
  93. <if test="chatId != null">chat_id,</if>
  94. <if test="userId != null">user_id,</if>
  95. <if test="kfId != null">kf_id,</if>
  96. <if test="createTime != null">create_time,</if>
  97. <if test="updateTime != null">update_time,</if>
  98. <if test="status != null">status,</if>
  99. <if test="companyId != null">company_id,</if>
  100. <if test="isLook != null">is_look,</if>
  101. <if test="userType != null">user_type,</if>
  102. <if test="nickName != null">nick_name,</if>
  103. <if test="avatar != null">avatar,</if>
  104. <if test="isArtificial != null">is_artificial,</if>
  105. <if test="remindTime != null">remind_time,</if>
  106. <if test="remindStatus != null">remind_status,</if>
  107. <if test="remindCount != null">remind_count,</if>
  108. <if test="qwExtId != null">qw_ext_id,</if>
  109. <if test="qwUserId != null">qw_user_id,</if>
  110. <if test="lastTime != null">last_time,</if>
  111. <if test="isReply != null">is_reply,</if>
  112. <if test="userInfo != null">user_info,</if>
  113. </trim>
  114. <trim prefix="values (" suffix=")" suffixOverrides=",">
  115. <if test="sessionId != null">#{sessionId},</if>
  116. <if test="chatId != null">#{chatId},</if>
  117. <if test="userId != null">#{userId},</if>
  118. <if test="kfId != null">#{kfId},</if>
  119. <if test="createTime != null">#{createTime},</if>
  120. <if test="updateTime != null">#{updateTime},</if>
  121. <if test="status != null">#{status},</if>
  122. <if test="companyId != null">#{companyId},</if>
  123. <if test="isLook != null">#{isLook},</if>
  124. <if test="userType != null">#{userType},</if>
  125. <if test="nickName != null">#{nickName},</if>
  126. <if test="avatar != null">#{avatar},</if>
  127. <if test="isArtificial != null">#{isArtificial},</if>
  128. <if test="remindTime != null">#{remindTime},</if>
  129. <if test="remindStatus != null">#{remindStatus},</if>
  130. <if test="remindCount != null">#{remindCount},</if>
  131. <if test="qwExtId != null">#{qwExtId},</if>
  132. <if test="qwUserId != null">#{qwUserId},</if>
  133. <if test="lastTime != null">#{lastTime},</if>
  134. <if test="isReply != null">#{isReply},</if>
  135. <if test="userInfo != null">#{userInfo},</if>
  136. </trim>
  137. </insert>
  138. <update id="updateFastGptChatSession" parameterType="FastGptChatSession">
  139. update fastgpt_chat_session
  140. <trim prefix="SET" suffixOverrides=",">
  141. <if test="chatId != null">chat_id = #{chatId},</if>
  142. <if test="userId != null">user_id = #{userId},</if>
  143. <if test="kfId != null">kf_id = #{kfId},</if>
  144. <if test="createTime != null">create_time = #{createTime},</if>
  145. <if test="updateTime != null">update_time = #{updateTime},</if>
  146. <if test="status != null">status = #{status},</if>
  147. <if test="companyId != null">company_id = #{companyId},</if>
  148. <if test="isLook != null">is_look = #{isLook},</if>
  149. <if test="userType != null">user_type = #{userType},</if>
  150. <if test="nickName != null">nick_name = #{nickName},</if>
  151. <if test="avatar != null">avatar = #{avatar},</if>
  152. <if test="isArtificial != null">is_artificial = #{isArtificial},</if>
  153. <if test="remindTime != null">remind_time = #{remindTime},</if>
  154. <if test="remindStatus != null">remind_status = #{remindStatus},</if>
  155. <if test="remindCount != null">remind_count = #{remindCount},</if>
  156. <if test="qwExtId != null">qw_ext_id = #{qwExtId},</if>
  157. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  158. <if test="lastTime != null">last_time = #{lastTime},</if>
  159. <if test="isReply != null">is_reply = #{isReply},</if>
  160. <if test="userInfo != null">user_info = #{userInfo},</if>
  161. </trim>
  162. where session_id = #{sessionId}
  163. </update>
  164. <delete id="deleteFastGptChatSessionBySessionId" parameterType="Long">
  165. delete from fastgpt_chat_session where session_id = #{sessionId}
  166. </delete>
  167. <delete id="deleteFastGptChatSessionBySessionIds" parameterType="String">
  168. delete from fastgpt_chat_session where session_id in
  169. <foreach item="sessionId" collection="array" open="(" separator="," close=")">
  170. #{sessionId}
  171. </foreach>
  172. </delete>
  173. </mapper>