TakaiDialogMapper.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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.takai.ai.mapper.TakaiDialogMapper">
  6. <resultMap type="com.takai.ai.domain.dto.TakaiDialogRespDTO" id="TakaiDialogResult">
  7. <id property="id" column="id" />
  8. <result property="dialog_name" column="dialog_name" />
  9. <result property="dialog_id" column="dialog_id" />
  10. <result property="did" column="did" />
  11. <result property="content" column="content" />
  12. <result property="type" column="type" />
  13. <result property="create_time" column="create_time" />
  14. <result property="slice_info" column="slice_info" />
  15. <result property="downloadUrl" column="downloadUrl" />
  16. </resultMap>
  17. <select id="selectDialogById" parameterType="String" resultMap="TakaiDialogResult">
  18. select id
  19. from dialog
  20. <where>
  21. <if test="dialogId != null and dialogId != ''">
  22. AND id = #{dialogId}
  23. </if>
  24. </where>
  25. </select>
  26. <select id="selectDialogDetailById" parameterType="String" resultMap="TakaiDialogResult">
  27. select id
  28. from dialog_detail
  29. <where>
  30. <if test="detailId != null and detailId != ''">
  31. AND id = #{detailId}
  32. </if>
  33. </where>
  34. </select>
  35. <select id="selectDialogList" resultMap="TakaiDialogResult">
  36. select
  37. d.id as id,
  38. d.app_id as appId,
  39. d.dialog_name as dialog_name,
  40. date_format(d.create_time, '%Y-%m-%d') as create_time
  41. from dialog d
  42. <where>
  43. <if test="appId != null">
  44. and d.app_id = #{appId}
  45. </if>
  46. <if test="userId != null">
  47. and d.user_id = #{userId}
  48. </if>
  49. </where>
  50. GROUP BY d.id,d.app_id,d.dialog_name,d.create_time
  51. ORDER BY d.create_time desc
  52. </select>
  53. <insert id="insertDialog" parameterType="DialogReqDTO">
  54. insert into dialog(
  55. id,
  56. <if test="appId != null">app_id,</if>
  57. <if test="knowledgeId != null">knowledge_id,</if>
  58. <if test="userId != null">user_id,</if>
  59. <if test="dialogName != null">dialog_name,</if>
  60. create_time
  61. )values(
  62. #{id},
  63. <if test="appId != null">#{appId},</if>
  64. <if test="knowledgeId != null">#{knowledgeId},</if>
  65. <if test="userId != null">#{userId},</if>
  66. <if test="dialogName != null">#{dialogName},</if>
  67. sysdate()
  68. )
  69. </insert>
  70. <insert id="insertDialogDetail" parameterType="DialogDetailReqDTO">
  71. insert into dialog_detail(
  72. id,
  73. <if test="dialogId != null">dialog_id,</if>
  74. <if test="role != null">type,</if>
  75. <if test="content != null">content,</if>
  76. <if test="role != null">create_by,</if>
  77. <if test="sliceJson != null and sliceJson != ''">slice_info,</if>
  78. <if test="downloadUrl != null and downloadUrl != ''">download_url,</if>
  79. create_time
  80. )values(
  81. #{id},
  82. <if test="dialogId != null">#{dialogId},</if>
  83. <if test="role != null">#{role},</if>
  84. <if test="content != null">#{content},</if>
  85. <if test="role != null">#{role},</if>
  86. <if test="sliceJson != null and sliceJson != ''">#{sliceJson},</if>
  87. <if test="downloadUrl != null and downloadUrl != ''">#{downloadUrl},</if>
  88. sysdate()
  89. )
  90. </insert>
  91. <select id="selectDialogDetail" resultMap="TakaiDialogResult">
  92. select
  93. d.id,
  94. d.app_id as appId,
  95. d.knowledge_id as knowledgeId,
  96. d.user_id as userId,
  97. d.dialog_name,
  98. d.create_time,
  99. dd.id as did,
  100. dd.type,
  101. dd.content,
  102. dd.dialog_id,
  103. dd.slice_info as sliceJson,
  104. dd.download_url as downloadUrl
  105. from dialog d
  106. left join dialog_detail dd on d.id = dd.dialog_id
  107. where dd.dialog_id = #{dialogId}
  108. ORDER BY dd.create_time asc, dd.type desc
  109. </select>
  110. <delete id="delDialog" parameterType="String">
  111. delete from dialog where id = #{id}
  112. </delete>
  113. <delete id="delDialogDetail" parameterType="String">
  114. delete from dialog_detail where dialog_id = #{dialogId}
  115. </delete>
  116. <update id="updateDialog" parameterType="DialogDetailReqDTO">
  117. update dialog set dialog_name = #{dialogName} where id = #{id}
  118. </update>
  119. <select id="selectDialogExport" resultMap="TakaiDialogResult">
  120. select
  121. d.id,
  122. d.app_id as appId,
  123. d.knowledge_id as knowledgeId,
  124. d.user_id as userId,
  125. d.dialog_name,
  126. d.create_time,
  127. dd.id as did,
  128. dd.type,
  129. dd.content,
  130. dd.dialog_id
  131. from dialog d
  132. left join dialog_detail dd on d.id = dd.dialog_id
  133. where dd.dialog_id = #{id}
  134. ORDER BY dd.create_time asc, dd.type desc
  135. </select>
  136. <select id="selectDialogListByAppId" resultMap="TakaiDialogResult">
  137. select
  138. d.id,
  139. d.app_id as appId,
  140. d.knowledge_id as knowledgeId,
  141. d.user_id as userId,
  142. d.dialog_name,
  143. d.create_time,
  144. dd.id as did,
  145. dd.type,
  146. dd.content,
  147. dd.dialog_id
  148. from dialog d
  149. left join dialog_detail dd on d.id = dd.dialog_id
  150. <where>
  151. <if test="appId != null">
  152. d.app_id = #{appId}
  153. </if>
  154. </where>
  155. ORDER BY dd.create_time asc, dd.type desc
  156. </select>
  157. <select id="selectDialog" resultMap="TakaiDialogResult">
  158. select
  159. d.id,
  160. d.app_id as appId,
  161. d.knowledge_id as knowledgeId,
  162. d.user_id as userId,
  163. d.dialog_name,
  164. d.create_time
  165. from dialog d
  166. <where>
  167. <if test="appId != null and appId != null">
  168. d.app_id = #{appId}
  169. </if>
  170. <if test="userId != null and userId != null">
  171. d.user_id = #{userId}
  172. </if>
  173. </where>
  174. ORDER BY d.create_time asc
  175. </select>
  176. </mapper>