PaperQuMapper.xml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.ydl.exam.modules.paper.mapper.PaperQuMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.ydl.exam.modules.paper.entity.PaperQu">
  6. <id column="id" property="id" />
  7. <result column="paper_id" property="paperId" />
  8. <result column="qu_id" property="quId" />
  9. <result column="qu_type" property="quType" />
  10. <result column="answered" property="answered" />
  11. <result column="answer" property="answer" />
  12. <result column="sort" property="sort" />
  13. <result column="score" property="score" />
  14. <result column="actual_score" property="actualScore" />
  15. <result column="is_right" property="isRight" />
  16. </resultMap>
  17. <!-- 通用查询结果列 -->
  18. <sql id="Base_Column_List">
  19. `id`,`paper_id`,`qu_id`,`qu_type`,`answered`,`answer`,`sort`,`score`,`actual_score`,`is_right`
  20. </sql>
  21. <!-- 计算总分 -->
  22. <select id="sumObjective" resultType="int">
  23. SELECT IFNULL(SUM(actual_score),0) as total
  24. FROM el_paper_qu
  25. WHERE paper_id=#{paperId}
  26. AND is_right=true
  27. AND qu_type &lt; 4
  28. </select>
  29. <select id="sumSubjective" resultType="int">
  30. SELECT IFNULL(SUM(actual_score),0) as total
  31. FROM el_paper_qu
  32. WHERE paper_id=#{paperId}
  33. AND qu_type=4
  34. </select>
  35. <resultMap id="ListResultMap" extends="BaseResultMap" type="com.ydl.exam.modules.paper.dto.ext.PaperQuDetailDTO">
  36. <result column="image" property="image" />
  37. <result column="content" property="content" />
  38. <collection property="answerList" column="{paperId=paper_id,quId=qu_id}"
  39. select="com.ydl.exam.modules.paper.mapper.PaperQuAnswerMapper.listForShow"></collection>
  40. </resultMap>
  41. <select id="listByPaper" resultMap="ListResultMap">
  42. SELECT pq.*,eq.content,eq.image
  43. FROM el_paper_qu pq
  44. LEFT JOIN el_qu eq ON pq.qu_id = eq.id
  45. WHERE pq.paper_id=#{paperId}
  46. ORDER BY pq.sort ASC
  47. </select>
  48. </mapper>