TakaiDialogMapper.xml 4.5 KB

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