UserNoteQuestionRelationMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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'
  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_paper` up on up.`id` = uq.`paper_id`
  44. left join `preview_assign` pa on up.`paper_origin` = 'preview' and pa.`id` = up.`origin_id`
  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. </if>
  65. <if test="structIds != null">
  66. and qn.`id` > 0
  67. </if>
  68. <if test="courseModules != null">
  69. and (pa.`id` > 0)
  70. </if>
  71. <if test="structIds == null">
  72. and (qn.`id` > 0 or sq.`id` > 0)
  73. </if>
  74. <if test="startTime != null">
  75. and unq.`create_time` &gt; #{startTime,jdbcType=TIMESTAMP}
  76. </if>
  77. <if test="endTime != null">
  78. and unq.`create_time` &lt; #{endTime,jdbcType=TIMESTAMP}
  79. </if>
  80. <if test="order != null">
  81. order by ${order}
  82. </if>
  83. </select>
  84. <select id="listExamination" resultMap="IdMap">
  85. <if test="keyword != null">
  86. <bind name="keywordLike" value="'%' + keyword + '%'" />
  87. </if>
  88. select
  89. <include refid="Id_Column_List" />,
  90. unq.`update_time`
  91. from `user_note_question` unq
  92. left join `question` q on q.`id` = unq.`question_id`
  93. and (q.`question_module` = 'base' or q.`question_module` = 'textbook')
  94. <if test="questionTypes != null">
  95. and
  96. <foreach collection="questionTypes" item="item" index="index" open="(" close=")" separator=" or ">
  97. q.`question_type` = #{item}
  98. </foreach>
  99. </if>
  100. left join `question_no` qn on qn.`id` = unq.`question_no_id` and qn.`module` = 'examination'
  101. and (q.`question_module` = 'base')
  102. <if test="structIds != null">
  103. and
  104. <foreach collection="structIds" item="item" index="index" open="(" close=")" separator=" or ">
  105. find_in_set(#{item}, qn.`module_struct`)
  106. </foreach>
  107. </if>
  108. left join `textbook_question` tq on tq.`question_id` = q.`id`
  109. and (q.`question_module` = 'textbook')
  110. <if test="libraryId != null and libraryId > 0">
  111. and tq.`library_id` = #{libraryId,jdbcType=VARCHAR}
  112. </if>
  113. <if test="year != null">
  114. and tq.`year` = #{year,jdbcType=VARCHAR}
  115. </if>
  116. where
  117. q.`id` > 0 and unq.`user_id` = #{userId,jdbcType=VARCHAR}
  118. <if test="keyword != null">
  119. and (q.`stem` like #{keywordLike,jdbcType=VARCHAR}
  120. or qn.`title` like #{keywordLike,jdbcType=VARCHAR}
  121. or tq.`title` like #{keywordLike,jdbcType=VARCHAR})
  122. </if>
  123. <if test="structIds != null">
  124. and qn.`id` > 0
  125. </if>
  126. <if test="structIds == null">
  127. and (qn.`id` > 0 or tq.`id` > 0)
  128. </if>
  129. <if test="libraryId != null">
  130. and (tq.`id` > 0)
  131. </if>
  132. <if test="year != null">
  133. and (tq.`id` > 0)
  134. </if>
  135. <if test="startTime != null">
  136. and unq.`create_time` &gt; #{startTime,jdbcType=TIMESTAMP}
  137. </if>
  138. <if test="endTime != null">
  139. and unq.`create_time` &lt; #{endTime,jdbcType=TIMESTAMP}
  140. </if>
  141. <if test="order != null">
  142. order by ${order}
  143. </if>
  144. </select>
  145. </mapper>