UserNoteQuestionRelationMapper.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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.UserNoteQuestionRelationMapper">
  4. <resultMap id="IdMap" type="com.qxgmat.data.dao.entity.UserNoteQuestion">
  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(unq.`id`)
  15. </sql>
  16. <select id="listExercise" resultMap="IdMap">
  17. <if test="keyword != null">
  18. <bind name="keywordLike" value="'%' + keyword + '%'" />
  19. </if>
  20. select
  21. <include refid="Id_Column_List" />,
  22. unq.`update_time` as `update_time`
  23. from `user_note_question` unq
  24. left join `question` q on q.`id` = unq.`question_id`
  25. and (q.`question_module` = 'base' or q.`question_module` = 'sentence')
  26. <if test="questionTypes != null">
  27. and
  28. <foreach collection="questionTypes" item="item" index="index" open="(" close=")" separator=" or ">
  29. q.`question_type` = #{item}
  30. </foreach>
  31. </if>
  32. left join `question_no` qn on qn.`id` = unq.`question_no_id` and qn.`module` = 'exercise' and qn.`delete_time` is null
  33. and (q.`question_module` = 'base')
  34. <if test="structIds != null">
  35. and
  36. <foreach collection="structIds" item="item" index="index" open="(" close=")" separator=" or ">
  37. find_in_set(#{item}, qn.`module_struct`)
  38. </foreach>
  39. </if>
  40. left join `sentence_question` sq on sq.`question_id` = q.`id`
  41. and (q.`question_module` = 'sentence')
  42. left join `user_question` uq on uq.`question_id` = unq.`question_id`
  43. left join `user_report` ur on ur.`id` = uq.`report_id`
  44. left join `preview_assign` pa on ur.`paper_origin` = 'preview' and pa.`id` = ur.`origin_id` and ur.`paper_origin` = 'preview'
  45. <if test="courseModules != null">
  46. and pa.`course_module` in
  47. <foreach collection="courseModules" item="item" index="index" open="(" close=")" separator=",">
  48. #{item}
  49. </foreach>
  50. </if>
  51. <!-- left join `preview_paper` pp on pa.`paper_id` = pp.`id`-->
  52. <!-- <if test="questionTypes != null">-->
  53. <!-- and-->
  54. <!-- <foreach collection="questionTypes" item="item" index="index" open="(" close=")" separator=" or ">-->
  55. <!-- pp.`question_type` = #{item}-->
  56. <!-- </foreach>-->
  57. <!-- </if>-->
  58. where
  59. q.`id` > 0 and unq.`user_id` = #{userId,jdbcType=VARCHAR}
  60. <if test="keyword != null">
  61. and (q.`stem` like #{keywordLike,jdbcType=VARCHAR}
  62. or qn.`title` like #{keywordLike,jdbcType=VARCHAR}
  63. or sq.`title` like #{keywordLike,jdbcType=VARCHAR}
  64. or unq.`question_content` like #{keywordLike,jdbcType=VARCHAR})
  65. </if>
  66. <if test="structIds != null">
  67. and qn.`id` > 0
  68. </if>
  69. <if test="courseModules != null">
  70. and (pa.`id` > 0)
  71. </if>
  72. <if test="structIds == null">
  73. and (qn.`id` > 0 or sq.`id` > 0)
  74. </if>
  75. <if test="startTime != null">
  76. and unq.`update_time` &gt; #{startTime,jdbcType=TIMESTAMP}
  77. </if>
  78. <if test="endTime != null">
  79. and unq.`update_time` &lt; #{endTime,jdbcType=TIMESTAMP}
  80. </if>
  81. <if test="order != null">
  82. order by ${order}
  83. </if>
  84. </select>
  85. <select id="listExamination" resultMap="IdMap">
  86. <if test="keyword != null">
  87. <bind name="keywordLike" value="'%' + keyword + '%'" />
  88. </if>
  89. select
  90. <include refid="Id_Column_List" />,
  91. unq.`update_time`
  92. from `user_note_question` unq
  93. left join `question` q on q.`id` = unq.`question_id`
  94. and (q.`question_module` = 'base' or q.`question_module` = 'textbook')
  95. <if test="questionTypes != null">
  96. and
  97. <foreach collection="questionTypes" item="item" index="index" open="(" close=")" separator=" or ">
  98. q.`question_type` = #{item}
  99. </foreach>
  100. </if>
  101. left join `question_no` qn on qn.`id` = unq.`question_no_id` and qn.`module` = 'examination'
  102. and (q.`question_module` = 'base')
  103. <if test="structIds != null">
  104. and
  105. <foreach collection="structIds" item="item" index="index" open="(" close=")" separator=" or ">
  106. find_in_set(#{item}, qn.`module_struct`)
  107. </foreach>
  108. </if>
  109. left join `textbook_question` tq on tq.`question_id` = q.`id`
  110. and (q.`question_module` = 'textbook')
  111. <if test="libraryId != null and libraryId > 0">
  112. and tq.`library_id` = #{libraryId,jdbcType=VARCHAR}
  113. </if>
  114. <if test="year != null">
  115. and tq.`year` = #{year,jdbcType=VARCHAR}
  116. </if>
  117. where
  118. q.`id` > 0 and unq.`user_id` = #{userId,jdbcType=VARCHAR}
  119. <if test="keyword != null">
  120. and (q.`stem` like #{keywordLike,jdbcType=VARCHAR}
  121. or qn.`title` like #{keywordLike,jdbcType=VARCHAR}
  122. or tq.`title` like #{keywordLike,jdbcType=VARCHAR}
  123. or unq.`question_content` like #{keywordLike,jdbcType=VARCHAR})
  124. </if>
  125. <if test="structIds != null">
  126. and qn.`id` > 0
  127. </if>
  128. <if test="structIds == null">
  129. and (qn.`id` > 0 or tq.`id` > 0)
  130. </if>
  131. <if test="libraryId != null">
  132. and (tq.`id` > 0)
  133. </if>
  134. <if test="year != null">
  135. and (tq.`id` > 0)
  136. </if>
  137. <if test="startTime != null">
  138. and unq.`update_time` &gt; #{startTime,jdbcType=TIMESTAMP}
  139. </if>
  140. <if test="endTime != null">
  141. and unq.`update_time` &lt; #{endTime,jdbcType=TIMESTAMP}
  142. </if>
  143. <if test="order != null">
  144. order by ${order}
  145. </if>
  146. </select>
  147. </mapper>