UserAskQuestionRelationMapper.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.qxgmat.data.relation.UserAskQuestionRelationMapper">
  4. <resultMap id="IdMap" type="com.qxgmat.data.dao.entity.UserAskQuestion">
  5. <!--
  6. WARNING - @mbg.generated
  7. -->
  8. <id column="id" jdbcType="INTEGER" property="id" />
  9. </resultMap>
  10. <sql id="Id_Column_List">
  11. <!--
  12. WARNING - @mbg.generated
  13. -->
  14. DISTINCT(uaq.`id`)
  15. </sql>
  16. <!--修改问答排序-->
  17. <update id="adjust">
  18. UPDATE `user_ask_question`
  19. <trim prefix="set" suffixOverrides=",">
  20. `order`#{flag}1
  21. </trim>
  22. WHERE `question_id` = #{questionId,jdbcType=VARCHAR} and `order` #{direction} #{order,jdbcType=INTEGER}
  23. </update>
  24. <select id="listExercise" resultMap="IdMap">
  25. <if test="keyword != null">
  26. <bind name="keywordLike" value="'%' + keyword + '%'" />
  27. </if>
  28. select
  29. <include refid="Id_Column_List" />,
  30. uaq.`ask_time`,
  31. uaq.`create_time`
  32. from `user_ask_question` uaq
  33. left join `question` q on q.`id` = uaq.`question_id`
  34. and (q.`question_module` = 'base' or q.`question_module` = 'sentence')
  35. <if test="questionTypes != null">
  36. and
  37. <foreach collection="questionTypes" item="item" index="index" open="(" close=")" separator=" or ">
  38. q.`question_type` = #{item}
  39. </foreach>
  40. </if>
  41. left join `question_no` qn on qn.`id` = uaq.`question_no_id` and qn.`module` = 'exercise' and qn.`delete_time` is null
  42. and (q.`question_module` = 'base')
  43. <if test="structIds != null">
  44. and
  45. <foreach collection="structIds" item="item" index="index" open="(" close=")" separator=" or ">
  46. find_in_set(#{item}, qn.`module_struct`)
  47. </foreach>
  48. </if>
  49. left join `sentence_question` sq on sq.`question_id` = q.`id`
  50. and (q.`question_module` = 'sentence')
  51. where
  52. q.`id` > 0 and uaq.`user_id` = #{userId,jdbcType=VARCHAR}
  53. <if test="keyword != null">
  54. and (q.`stem` like #{keywordLike,jdbcType=VARCHAR}
  55. or qn.`title` like #{keywordLike,jdbcType=VARCHAR}
  56. or sq.`title` like #{keywordLike,jdbcType=VARCHAR})
  57. </if>
  58. <if test="structIds != null">
  59. and qn.`id` > 0
  60. </if>
  61. <if test="structIds == null">
  62. and (qn.`id` > 0 or sq.`id` > 0)
  63. </if>
  64. <if test="answerStatus != null">
  65. and uaq.`answer_status` = #{answerStatus,jdbcType=INTEGER}
  66. </if>
  67. <if test="startTime != null">
  68. and uaq.`create_time` &gt; #{startTime,jdbcType=TIMESTAMP}
  69. </if>
  70. <if test="endTime != null">
  71. and uaq.`create_time` &lt; #{endTime,jdbcType=TIMESTAMP}
  72. </if>
  73. <if test="order != null">
  74. order by ${order}
  75. </if>
  76. </select>
  77. <select id="listExamination" resultMap="IdMap">
  78. <if test="keyword != null">
  79. <bind name="keywordLike" value="'%' + keyword + '%'" />
  80. </if>
  81. select
  82. <include refid="Id_Column_List" />,
  83. uaq.`ask_time`,
  84. uaq.`create_time`
  85. from `user_ask_question` uaq
  86. left join `question` q on q.`id` = uaq.`question_id`
  87. and (q.`question_module` = 'base' or q.`question_module` = 'textbook')
  88. <if test="questionTypes != null">
  89. and
  90. <foreach collection="questionTypes" item="item" index="index" open="(" close=")" separator=" or ">
  91. q.`question_type` = #{item}
  92. </foreach>
  93. </if>
  94. left join `question_no` qn on qn.`id` = uaq.`question_no_id` and qn.`module` = 'examination' and qn.`delete_time` is null
  95. and (q.`question_module` = 'base')
  96. <if test="structIds != null">
  97. and
  98. <foreach collection="structIds" item="item" index="index" open="(" close=")" separator=" or ">
  99. find_in_set(#{item}, qn.`module_struct`)
  100. </foreach>
  101. </if>
  102. left join `textbook_question` tq on tq.`question_id` = q.`id`
  103. and (q.`question_module` = 'textbook')
  104. <if test="libraryId != null and libraryId > 0">
  105. and tq.`library_id` = #{libraryId,jdbcType=VARCHAR}
  106. </if>
  107. <if test="year != null">
  108. and tq.`year` = #{year,jdbcType=VARCHAR}
  109. </if>
  110. where
  111. q.`id` > 0 and uaq.`user_id` = #{userId,jdbcType=VARCHAR}
  112. <if test="keyword != null">
  113. and (q.`stem` like #{keywordLike,jdbcType=VARCHAR}
  114. or qn.`title` like #{keywordLike,jdbcType=VARCHAR}
  115. or tq.`title` like #{keywordLike,jdbcType=VARCHAR})
  116. </if>
  117. <if test="structIds != null">
  118. and qn.`id` > 0
  119. </if>
  120. <if test="structIds == null">
  121. and (qn.`id` > 0 or tq.`id` > 0)
  122. </if>
  123. <if test="libraryId != null">
  124. and (tq.`id` > 0)
  125. </if>
  126. <if test="year != null">
  127. and (tq.`id` > 0)
  128. </if>
  129. <if test="answerStatus != null">
  130. and uaq.`answer_status` = #{answerStatus,jdbcType=INTEGER}
  131. </if>
  132. <if test="startTime != null">
  133. and uaq.`create_time` &gt; #{startTime,jdbcType=TIMESTAMP}
  134. </if>
  135. <if test="endTime != null">
  136. and uaq.`create_time` &lt; #{endTime,jdbcType=TIMESTAMP}
  137. </if>
  138. <if test="order != null">
  139. order by ${order}
  140. </if>
  141. </select>
  142. <!--后台提问列表-->
  143. <select id="listAdmin" resultMap="IdMap">
  144. select
  145. <include refid="Id_Column_List" />
  146. from `user_ask_question` uaq
  147. left join `user` u on u.`id` = uaq.`user_id`
  148. <if test="userId != null">
  149. and uaq.`user_id` = #{userId,jdbcType=VARCHAR}
  150. </if>
  151. <if test="max != null">
  152. and u.`total_money` &lt; ${max}
  153. </if>
  154. <if test="min != null">
  155. and u.`total_money` &gt; ${min}
  156. </if>
  157. left join `question` q on q.`id` = uaq.`question_id`
  158. where
  159. u.`id` &gt; 0
  160. <if test="questionNoId != null">
  161. and uaq.`question_no_id` = #{questionNoId,jdbcType=VARCHAR}
  162. </if>
  163. <if test="target != null">
  164. and uaq.`target` = #{target,jdbcType=VARCHAR}
  165. </if>
  166. <if test="answerStatus != null">
  167. and uaq.`answer_status` = #{answerStatus,jdbcType=INTEGER}
  168. </if>
  169. <if test="showStatus != null">
  170. and uaq.`show_status` = #{showStatus,jdbcType=INTEGER}
  171. </if>
  172. <if test="askModule != null">
  173. and uaq.`ask_module` =#{askModule,jdbcType=VARCHAR}
  174. </if>
  175. <if test="questionModule != null">
  176. and uaq.`question_module` =#{questionModule,jdbcType=VARCHAR}
  177. </if>
  178. <if test="questionType != null">
  179. and q.`question_type` =#{questionType,jdbcType=VARCHAR}
  180. </if>
  181. <if test="startTime != null">
  182. and uaq.`create_time` &gt; #{startTime,jdbcType=TIMESTAMP}
  183. </if>
  184. <if test="endTime != null">
  185. and uaq.`create_time` &lt; #{endTime,jdbcType=TIMESTAMP}
  186. </if>
  187. <if test="hasRecord != null">
  188. <if test="hasRecord">
  189. and uaq.`record_id` &gt; 0
  190. </if>
  191. <if test="!hasRecord">
  192. and uaq.`record_id` = 0
  193. </if>
  194. </if>
  195. order by ${order} ${direction}
  196. </select>
  197. </mapper>