FastGptChatMsgMapper.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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.FastGptChatMsgMapper">
  6. <resultMap type="FastGptChatMsg" id="FastGptChatMsgResult">
  7. <result property="msgId" column="msg_id" />
  8. <result property="sessionId" column="session_id" />
  9. <result property="extId" column="ext_id" />
  10. <result property="userId" column="user_id" />
  11. <result property="content" column="content" />
  12. <result property="msgType" column="msg_type" />
  13. <result property="sendType" column="send_type" />
  14. <result property="companyId" column="company_id" />
  15. <result property="roleId" column="role_id" />
  16. <result property="companyUserId" column="company_user_id" />
  17. <result property="createTime" column="create_time" />
  18. <result property="msgJson" column="msg_json" />
  19. <result property="status" column="status" />
  20. <result property="nickName" column="nick_name" />
  21. <result property="avatar" column="avatar" />
  22. <result property="userType" column="user_type" />
  23. <result property="promptTokens" column="prompt_tokens" />
  24. <result property="completionTokens" column="completion_tokens" />
  25. <result property="totalTokens" column="total_tokens" />
  26. </resultMap>
  27. <sql id="selectFastGptChatMsgVo">
  28. select msg_id, session_id,prompt_tokens,completion_tokens,total_tokens, ext_id, user_id, content, msg_type, send_type, company_id, role_id, company_user_id, create_time, msg_json, status, nick_name, avatar, user_type from fastgpt_chat_msg
  29. </sql>
  30. <select id="selectFastGptChatMsgList" parameterType="FastGptChatMsg" resultMap="FastGptChatMsgResult">
  31. <include refid="selectFastGptChatMsgVo"/>
  32. <where>
  33. <if test="sessionId != null "> and session_id = #{sessionId}</if>
  34. <if test="extId != null and extId != ''"> and ext_id = #{extId}</if>
  35. <if test="userId != null and userId != ''"> and user_id = #{userId}</if>
  36. <if test="content != null and content != ''"> and content = #{content}</if>
  37. <if test="msgType != null "> and msg_type = #{msgType}</if>
  38. <if test="sendType != null "> and send_type = #{sendType}</if>
  39. <if test="companyId != null "> and company_id = #{companyId}</if>
  40. <if test="roleId != null "> and role_id = #{roleId}</if>
  41. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  42. <if test="msgJson != null and msgJson != ''"> and msg_json = #{msgJson}</if>
  43. <if test="status != null "> and status = #{status}</if>
  44. <if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
  45. <if test="avatar != null and avatar != ''"> and avatar = #{avatar}</if>
  46. <if test="userType != null "> and user_type = #{userType}</if>
  47. </where>
  48. </select>
  49. <select id="selectFastGptChatMsgByMsgId" parameterType="Long" resultMap="FastGptChatMsgResult">
  50. <include refid="selectFastGptChatMsgVo"/>
  51. where msg_id = #{msgId}
  52. </select>
  53. <insert id="insertFastGptChatMsg" parameterType="FastGptChatMsg" useGeneratedKeys="false">
  54. insert into fastgpt_chat_msg
  55. <trim prefix="(" suffix=")" suffixOverrides=",">
  56. <if test="msgId != null">msg_id,</if>
  57. <if test="sessionId != null">session_id,</if>
  58. <if test="extId != null">ext_id,</if>
  59. <if test="userId != null">user_id,</if>
  60. <if test="content != null">content,</if>
  61. <if test="msgType != null">msg_type,</if>
  62. <if test="sendType != null">send_type,</if>
  63. <if test="companyId != null">company_id,</if>
  64. <if test="roleId != null">role_id,</if>
  65. <if test="companyUserId != null">company_user_id,</if>
  66. <if test="createTime != null">create_time,</if>
  67. <if test="msgJson != null">msg_json,</if>
  68. <if test="status != null">status,</if>
  69. <if test="nickName != null">nick_name,</if>
  70. <if test="avatar != null">avatar,</if>
  71. <if test="userType != null">user_type,</if>
  72. <if test="promptTokens != null">prompt_tokens,</if>
  73. <if test="completionTokens != null">completion_tokens,</if>
  74. <if test="totalTokens != null">total_tokens,</if>
  75. </trim>
  76. <trim prefix="values (" suffix=")" suffixOverrides=",">
  77. <if test="msgId != null">#{msgId},</if>
  78. <if test="sessionId != null">#{sessionId},</if>
  79. <if test="extId != null">#{extId},</if>
  80. <if test="userId != null">#{userId},</if>
  81. <if test="content != null">#{content},</if>
  82. <if test="msgType != null">#{msgType},</if>
  83. <if test="sendType != null">#{sendType},</if>
  84. <if test="companyId != null">#{companyId},</if>
  85. <if test="roleId != null">#{roleId},</if>
  86. <if test="companyUserId != null">#{companyUserId},</if>
  87. <if test="createTime != null">#{createTime},</if>
  88. <if test="msgJson != null">#{msgJson},</if>
  89. <if test="status != null">#{status},</if>
  90. <if test="nickName != null">#{nickName},</if>
  91. <if test="avatar != null">#{avatar},</if>
  92. <if test="userType != null">#{userType},</if>
  93. <if test="promptTokens != null">#{promptTokens},</if>
  94. <if test="completionTokens != null">#{completionTokens},</if>
  95. <if test="totalTokens != null">#{totalTokens},</if>
  96. </trim>
  97. </insert>
  98. <update id="updateFastGptChatMsg" parameterType="FastGptChatMsg">
  99. update fastgpt_chat_msg
  100. <trim prefix="SET" suffixOverrides=",">
  101. <if test="sessionId != null">session_id = #{sessionId},</if>
  102. <if test="extId != null">ext_id = #{extId},</if>
  103. <if test="userId != null">user_id = #{userId},</if>
  104. <if test="content != null">content = #{content},</if>
  105. <if test="msgType != null">msg_type = #{msgType},</if>
  106. <if test="sendType != null">send_type = #{sendType},</if>
  107. <if test="companyId != null">company_id = #{companyId},</if>
  108. <if test="roleId != null">role_id = #{roleId},</if>
  109. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  110. <if test="createTime != null">create_time = #{createTime},</if>
  111. <if test="msgJson != null">msg_json = #{msgJson},</if>
  112. <if test="status != null">status = #{status},</if>
  113. <if test="nickName != null">nick_name = #{nickName},</if>
  114. <if test="avatar != null">avatar = #{avatar},</if>
  115. <if test="userType != null">user_type = #{userType},</if>
  116. <if test="promptTokens != null">prompt_tokens = #{promptTokens},</if>
  117. <if test="completionTokens != null">completion_tokens = #{completionTokens},</if>
  118. <if test="totalTokens != null">total_tokens = #{totalTokens},</if>
  119. </trim>
  120. where msg_id = #{msgId}
  121. </update>
  122. <delete id="deleteFastGptChatMsgByMsgId" parameterType="Long">
  123. delete from fastgpt_chat_msg where msg_id = #{msgId}
  124. </delete>
  125. <delete id="deleteFastGptChatMsgByMsgIds" parameterType="String">
  126. delete from fastgpt_chat_msg where msg_id in
  127. <foreach item="msgId" collection="array" open="(" separator="," close=")">
  128. #{msgId}
  129. </foreach>
  130. </delete>
  131. </mapper>