TestPaperInfoMapper.xml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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.education.business.mapper.education.TestPaperInfoMapper">
  4. <select id="selectPageList" resultType="testPaperInfoDto">
  5. select paper.*, subject.name subject_name, grade.name gradeInfoName from test_paper_info paper
  6. left join grade_info grade on paper.grade_info_id = grade.id
  7. left join subject_info subject on paper.subject_id = subject.id
  8. <where>
  9. <if test="testPaperInfo.gradeInfoId != null">
  10. and paper.grade_info_id = #{testPaperInfo.gradeInfoId}
  11. </if>
  12. <if test="testPaperInfo.name != null and testPaperInfo.name != ''">
  13. <bind name="name" value="'%' + testPaperInfo.name+ '%'"/>
  14. and paper.name like #{name}
  15. </if>
  16. <if test="testPaperInfo.subjectId != null">
  17. and paper.subject_id = #{testPaperInfo.subjectId}
  18. </if>
  19. <if test="testPaperInfo.publishFlag != null and testPaperInfo.publishFlag">
  20. and paper.publish_flag = 1
  21. </if>
  22. </where>
  23. order by paper.id desc
  24. </select>
  25. <!-- 试卷试题列表 -->
  26. <select id="selectPaperQuestionList" resultType="testPaperQuestionDto">
  27. select
  28. b.id, a.id question_info_id, a.content, b.sort, b.mark,
  29. <if test="testPaperQuestionRequest.showAnswer">
  30. a.answer,
  31. </if>
  32. b.test_paper_info_id, a.question_type, a.options
  33. from question_info a inner join test_paper_question_info b
  34. on a.id = b.question_info_id inner join test_paper_info c
  35. on b.test_paper_info_id = c.id where c.id = #{testPaperQuestionRequest.testPaperInfoId}
  36. <if test="testPaperQuestionRequest.questionType != null">
  37. and a.question_type = #{testPaperQuestionRequest.questionType}
  38. </if>
  39. <if test="testPaperQuestionRequest.content != null and testPaperQuestionRequest.content != ''">
  40. <bind name="content" value="'%' + testPaperQuestionRequest.content + '%'"/>
  41. and a.content like #{content}
  42. </if>
  43. order by b.sort asc
  44. </select>
  45. </mapper>