LearnQuestionsMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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.ruoyi.learn.mapper.LearnQuestionsMapper">
  6. <resultMap type="LearnQuestions" id="LearnQuestionsResult">
  7. <result property="id" column="id" />
  8. <result property="title" column="title" />
  9. <result property="optionA" column="option_a" />
  10. <result property="optionB" column="option_b" />
  11. <result property="optionC" column="option_c" />
  12. <result property="optionD" column="option_d" />
  13. <result property="optionE" column="option_e" />
  14. <result property="optionF" column="option_f" />
  15. <result property="optionG" column="option_g" />
  16. <result property="answer1" column="answer1" />
  17. <result property="answer2" column="answer2" />
  18. <result property="qtpye" column="qtpye" />
  19. <result property="subjectId" column="subjectId" />
  20. <result property="paperId" column="paperId" />
  21. <result property="knowledgeId" column="knowledgeId" />
  22. <result property="diff" column="diff" />
  23. <result property="similarity" column="similarity" />
  24. <result property="parse" column="parse" />
  25. <result property="knowId" column="knowId" />
  26. <result property="gradeId" column="gradeId" />
  27. <result property="knowledges" column="knowledges" />
  28. <result property="area" column="area" />
  29. <result property="year" column="year" />
  30. <result property="paperTpye" column="paperTpye" />
  31. <result property="source" column="source" />
  32. <result property="fromSite" column="fromSite" />
  33. <result property="isSub" column="isSub" />
  34. <result property="isNormal" column="isNormal" />
  35. <result property="isKonw" column="isKonw" />
  36. <result property="tiid" column="tiid" />
  37. <result property="md5" column="md5" />
  38. <result property="isunique" column="isunique" />
  39. <result property="md52" column="md52" />
  40. <result property="createTime" column="create_time" />
  41. <result property="score" column="score" />
  42. <result property="options" column="options" />
  43. <result property="number" column="number" />
  44. <result property="paperTypeTitle" column="paperTypeTitle" />
  45. <result property="options0" column="options0" />
  46. <result property="title0" column="title0" />
  47. <result property="title1" column="title1" />
  48. <result property="parse0" column="parse0" />
  49. <result property="answer0" column="answer0" />
  50. <result property="isUpdate" column="isUpdate" />
  51. <result property="isSubType" column="isSubType" />
  52. </resultMap>
  53. <sql id="selectLearnQuestionsVo">
  54. select id, title, option_a, option_b, option_c, option_d, option_e, option_f, option_g, answer1, answer2, qtpye, subjectId, paperId, knowledgeId, diff, similarity, parse, knowId, gradeId, knowledges, area, year, paperTpye, source, fromSite, isSub, isNormal, isKonw, tiid, md5, isunique, md52, create_time, score, options, number, paperTypeTitle, options0, title0, title1, parse0, answer0, isUpdate, isSubType from learn_questions
  55. </sql>
  56. <select id="selectLearnQuestionsList" parameterType="LearnQuestions" resultMap="LearnQuestionsResult">
  57. <include refid="selectLearnQuestionsVo"/>
  58. <where>
  59. <if test="title != null and title != ''"> and title = #{title}</if>
  60. <if test="optionA != null and optionA != ''"> and option_a = #{optionA}</if>
  61. <if test="optionB != null and optionB != ''"> and option_b = #{optionB}</if>
  62. <if test="optionC != null and optionC != ''"> and option_c = #{optionC}</if>
  63. <if test="optionD != null and optionD != ''"> and option_d = #{optionD}</if>
  64. <if test="optionE != null and optionE != ''"> and option_e = #{optionE}</if>
  65. <if test="optionF != null and optionF != ''"> and option_f = #{optionF}</if>
  66. <if test="optionG != null and optionG != ''"> and option_g = #{optionG}</if>
  67. <if test="answer1 != null and answer1 != ''"> and answer1 = #{answer1}</if>
  68. <if test="answer2 != null and answer2 != ''"> and answer2 = #{answer2}</if>
  69. <if test="qtpye != null and qtpye != ''"> and qtpye = #{qtpye}</if>
  70. <if test="subjectId != null "> and subjectId = #{subjectId}</if>
  71. <if test="paperId != null "> and paperId = #{paperId}</if>
  72. <if test="knowledgeId != null "> and knowledgeId = #{knowledgeId}</if>
  73. <if test="diff != null "> and diff = #{diff}</if>
  74. <if test="similarity != null "> and similarity = #{similarity}</if>
  75. <if test="parse != null and parse != ''"> and parse = #{parse}</if>
  76. <if test="knowId != null "> and knowId = #{knowId}</if>
  77. <if test="gradeId != null "> and gradeId = #{gradeId}</if>
  78. <if test="knowledges != null and knowledges != ''"> and knowledges = #{knowledges}</if>
  79. <if test="area != null and area != ''"> and area = #{area}</if>
  80. <if test="year != null "> and year = #{year}</if>
  81. <if test="paperTpye != null and paperTpye != ''"> and paperTpye = #{paperTpye}</if>
  82. <if test="source != null and source != ''"> and source = #{source}</if>
  83. <if test="fromSite != null and fromSite != ''"> and fromSite = #{fromSite}</if>
  84. <if test="isSub != null "> and isSub = #{isSub}</if>
  85. <if test="isNormal != null "> and isNormal = #{isNormal}</if>
  86. <if test="isKonw != null "> and isKonw = #{isKonw}</if>
  87. <if test="tiid != null and tiid != ''"> and tiid = #{tiid}</if>
  88. <if test="md5 != null and md5 != ''"> and md5 = #{md5}</if>
  89. <if test="isunique != null "> and isunique = #{isunique}</if>
  90. <if test="md52 != null and md52 != ''"> and md52 = #{md52}</if>
  91. <if test="score != null "> and score = #{score}</if>
  92. <if test="options != null and options != ''"> and options = #{options}</if>
  93. <if test="number != null "> and number = #{number}</if>
  94. <if test="paperTypeTitle != null and paperTypeTitle != ''"> and paperTypeTitle = #{paperTypeTitle}</if>
  95. <if test="options0 != null and options0 != ''"> and options0 = #{options0}</if>
  96. <if test="title0 != null and title0 != ''"> and title0 = #{title0}</if>
  97. <if test="title1 != null and title1 != ''"> and title1 = #{title1}</if>
  98. <if test="parse0 != null and parse0 != ''"> and parse0 = #{parse0}</if>
  99. <if test="answer0 != null and answer0 != ''"> and answer0 = #{answer0}</if>
  100. <if test="isUpdate != null "> and isUpdate = #{isUpdate}</if>
  101. <if test="isSubType != null and isSubType != ''"> and isSubType = #{isSubType}</if>
  102. </where>
  103. </select>
  104. <select id="selectLearnQuestionsById" parameterType="Long" resultMap="LearnQuestionsResult">
  105. <include refid="selectLearnQuestionsVo"/>
  106. where id = #{id}
  107. </select>
  108. <insert id="insertLearnQuestions" parameterType="LearnQuestions" useGeneratedKeys="true" keyProperty="id">
  109. insert into learn_questions
  110. <trim prefix="(" suffix=")" suffixOverrides=",">
  111. <if test="title != null">title,</if>
  112. <if test="optionA != null">option_a,</if>
  113. <if test="optionB != null">option_b,</if>
  114. <if test="optionC != null">option_c,</if>
  115. <if test="optionD != null">option_d,</if>
  116. <if test="optionE != null">option_e,</if>
  117. <if test="optionF != null">option_f,</if>
  118. <if test="optionG != null">option_g,</if>
  119. <if test="answer1 != null">answer1,</if>
  120. <if test="answer2 != null">answer2,</if>
  121. <if test="qtpye != null">qtpye,</if>
  122. <if test="subjectId != null">subjectId,</if>
  123. <if test="paperId != null">paperId,</if>
  124. <if test="knowledgeId != null">knowledgeId,</if>
  125. <if test="diff != null">diff,</if>
  126. <if test="similarity != null">similarity,</if>
  127. <if test="parse != null">parse,</if>
  128. <if test="knowId != null">knowId,</if>
  129. <if test="gradeId != null">gradeId,</if>
  130. <if test="knowledges != null">knowledges,</if>
  131. <if test="area != null">area,</if>
  132. <if test="year != null">year,</if>
  133. <if test="paperTpye != null">paperTpye,</if>
  134. <if test="source != null">source,</if>
  135. <if test="fromSite != null">fromSite,</if>
  136. <if test="isSub != null">isSub,</if>
  137. <if test="isNormal != null">isNormal,</if>
  138. <if test="isKonw != null">isKonw,</if>
  139. <if test="tiid != null">tiid,</if>
  140. <if test="md5 != null">md5,</if>
  141. <if test="isunique != null">isunique,</if>
  142. <if test="md52 != null">md52,</if>
  143. <if test="createTime != null">create_time,</if>
  144. <if test="score != null">score,</if>
  145. <if test="options != null">options,</if>
  146. <if test="number != null">number,</if>
  147. <if test="paperTypeTitle != null">paperTypeTitle,</if>
  148. <if test="options0 != null">options0,</if>
  149. <if test="title0 != null">title0,</if>
  150. <if test="title1 != null">title1,</if>
  151. <if test="parse0 != null">parse0,</if>
  152. <if test="answer0 != null">answer0,</if>
  153. <if test="isUpdate != null">isUpdate,</if>
  154. <if test="isSubType != null">isSubType,</if>
  155. </trim>
  156. <trim prefix="values (" suffix=")" suffixOverrides=",">
  157. <if test="title != null">#{title},</if>
  158. <if test="optionA != null">#{optionA},</if>
  159. <if test="optionB != null">#{optionB},</if>
  160. <if test="optionC != null">#{optionC},</if>
  161. <if test="optionD != null">#{optionD},</if>
  162. <if test="optionE != null">#{optionE},</if>
  163. <if test="optionF != null">#{optionF},</if>
  164. <if test="optionG != null">#{optionG},</if>
  165. <if test="answer1 != null">#{answer1},</if>
  166. <if test="answer2 != null">#{answer2},</if>
  167. <if test="qtpye != null">#{qtpye},</if>
  168. <if test="subjectId != null">#{subjectId},</if>
  169. <if test="paperId != null">#{paperId},</if>
  170. <if test="knowledgeId != null">#{knowledgeId},</if>
  171. <if test="diff != null">#{diff},</if>
  172. <if test="similarity != null">#{similarity},</if>
  173. <if test="parse != null">#{parse},</if>
  174. <if test="knowId != null">#{knowId},</if>
  175. <if test="gradeId != null">#{gradeId},</if>
  176. <if test="knowledges != null">#{knowledges},</if>
  177. <if test="area != null">#{area},</if>
  178. <if test="year != null">#{year},</if>
  179. <if test="paperTpye != null">#{paperTpye},</if>
  180. <if test="source != null">#{source},</if>
  181. <if test="fromSite != null">#{fromSite},</if>
  182. <if test="isSub != null">#{isSub},</if>
  183. <if test="isNormal != null">#{isNormal},</if>
  184. <if test="isKonw != null">#{isKonw},</if>
  185. <if test="tiid != null">#{tiid},</if>
  186. <if test="md5 != null">#{md5},</if>
  187. <if test="isunique != null">#{isunique},</if>
  188. <if test="md52 != null">#{md52},</if>
  189. <if test="createTime != null">#{createTime},</if>
  190. <if test="score != null">#{score},</if>
  191. <if test="options != null">#{options},</if>
  192. <if test="number != null">#{number},</if>
  193. <if test="paperTypeTitle != null">#{paperTypeTitle},</if>
  194. <if test="options0 != null">#{options0},</if>
  195. <if test="title0 != null">#{title0},</if>
  196. <if test="title1 != null">#{title1},</if>
  197. <if test="parse0 != null">#{parse0},</if>
  198. <if test="answer0 != null">#{answer0},</if>
  199. <if test="isUpdate != null">#{isUpdate},</if>
  200. <if test="isSubType != null">#{isSubType},</if>
  201. </trim>
  202. </insert>
  203. <update id="updateLearnQuestions" parameterType="LearnQuestions">
  204. update learn_questions
  205. <trim prefix="SET" suffixOverrides=",">
  206. <if test="title != null">title = #{title},</if>
  207. <if test="optionA != null">option_a = #{optionA},</if>
  208. <if test="optionB != null">option_b = #{optionB},</if>
  209. <if test="optionC != null">option_c = #{optionC},</if>
  210. <if test="optionD != null">option_d = #{optionD},</if>
  211. <if test="optionE != null">option_e = #{optionE},</if>
  212. <if test="optionF != null">option_f = #{optionF},</if>
  213. <if test="optionG != null">option_g = #{optionG},</if>
  214. <if test="answer1 != null">answer1 = #{answer1},</if>
  215. <if test="answer2 != null">answer2 = #{answer2},</if>
  216. <if test="qtpye != null">qtpye = #{qtpye},</if>
  217. <if test="subjectId != null">subjectId = #{subjectId},</if>
  218. <if test="paperId != null">paperId = #{paperId},</if>
  219. <if test="knowledgeId != null">knowledgeId = #{knowledgeId},</if>
  220. <if test="diff != null">diff = #{diff},</if>
  221. <if test="similarity != null">similarity = #{similarity},</if>
  222. <if test="parse != null">parse = #{parse},</if>
  223. <if test="knowId != null">knowId = #{knowId},</if>
  224. <if test="gradeId != null">gradeId = #{gradeId},</if>
  225. <if test="knowledges != null">knowledges = #{knowledges},</if>
  226. <if test="area != null">area = #{area},</if>
  227. <if test="year != null">year = #{year},</if>
  228. <if test="paperTpye != null">paperTpye = #{paperTpye},</if>
  229. <if test="source != null">source = #{source},</if>
  230. <if test="fromSite != null">fromSite = #{fromSite},</if>
  231. <if test="isSub != null">isSub = #{isSub},</if>
  232. <if test="isNormal != null">isNormal = #{isNormal},</if>
  233. <if test="isKonw != null">isKonw = #{isKonw},</if>
  234. <if test="tiid != null">tiid = #{tiid},</if>
  235. <if test="md5 != null">md5 = #{md5},</if>
  236. <if test="isunique != null">isunique = #{isunique},</if>
  237. <if test="md52 != null">md52 = #{md52},</if>
  238. <if test="createTime != null">create_time = #{createTime},</if>
  239. <if test="score != null">score = #{score},</if>
  240. <if test="options != null">options = #{options},</if>
  241. <if test="number != null">number = #{number},</if>
  242. <if test="paperTypeTitle != null">paperTypeTitle = #{paperTypeTitle},</if>
  243. <if test="options0 != null">options0 = #{options0},</if>
  244. <if test="title0 != null">title0 = #{title0},</if>
  245. <if test="title1 != null">title1 = #{title1},</if>
  246. <if test="parse0 != null">parse0 = #{parse0},</if>
  247. <if test="answer0 != null">answer0 = #{answer0},</if>
  248. <if test="isUpdate != null">isUpdate = #{isUpdate},</if>
  249. <if test="isSubType != null">isSubType = #{isSubType},</if>
  250. </trim>
  251. where id = #{id}
  252. </update>
  253. <delete id="deleteLearnQuestionsById" parameterType="Long">
  254. delete from learn_questions where id = #{id}
  255. </delete>
  256. <delete id="deleteLearnQuestionsByIds" parameterType="String">
  257. delete from learn_questions where id in
  258. <foreach item="id" collection="array" open="(" separator="," close=")">
  259. #{id}
  260. </foreach>
  261. </delete>
  262. <select id="selectQuestionByPaperId" parameterType="Long" resultMap="LearnQuestionsResult">
  263. select q.`id`, pq.`seq`, pq.`score`, title, option_a, option_b, option_c, option_d, option_e, option_f, option_g, qtpye, diff, similarity, isSub, paperTypeTitle, title0
  264. from learn_paper_question pq join `learn_questions` q on q.`id` = pq.`question_id`
  265. where pq.`paper_id` = #{paperId}
  266. order by pq.`seq`, q.`id`
  267. </select>
  268. <select id="statByKnowledgeType" parameterType="map" resultMap="LearnQuestionsResult">
  269. SELECT q.`knowledgeId`, q.`qtpye`, COUNT(*) number
  270. FROM `learn_knowledge_question` kq
  271. <if test="studentId != null">
  272. LEFT JOIN `learn_answer` a ON kq.`question_id` = a.`question_id` AND a.`student_id` = #{studentId}
  273. </if>
  274. JOIN `learn_questions` q ON q.`id` = kq.`question_id`
  275. <where>
  276. <if test="knowIds != null"> and kq.`knowledge_id` in <foreach item="id" collection="knowIds" open="(" separator="," close=")">#{id}</foreach></if>
  277. <if test="types != null"> and q.`qtpye` in <foreach item="id" collection="types" open="(" separator="," close=")">#{id}</foreach></if>
  278. <if test="studentId != null"> AND a.`student_id` IS NULL</if>
  279. </where>
  280. GROUP BY q.`knowledgeId`, q.`qtpye`
  281. </select>
  282. <select id="selectQuestionsForPaper" parameterType="LearnQuestions" resultMap="LearnQuestionsResult">
  283. SELECT q.`id`, q.`knowledgeId`
  284. FROM `learn_knowledge_question` kq
  285. <if test="id != null">
  286. LEFT JOIN `learn_answer` a ON kq.`question_id` = a.`question_id` AND a.`student_id` = #{id}
  287. </if>
  288. JOIN `learn_questions` q ON q.`id` = kq.`question_id`
  289. <where>
  290. <if test="qtpye != null and qtpye != ''"> and qtpye = #{qtpye}</if>
  291. <if test="id != null "> AND a.`student_id` IS NULL</if>
  292. <if test="knowledgeId != null "> and knowledgeId = #{knowledgeId}</if>
  293. </where>
  294. limit #{number}, 500
  295. </select>
  296. </mapper>