DialogMapper.xml 4.6 KB

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