ExamMapper.xml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.exam.mapper.ExamMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.ydl.exam.modules.exam.entity.Exam">
  6. <id column="id" property="id" />
  7. <result column="title" property="title" />
  8. <result column="content" property="content" />
  9. <result column="open_type" property="openType" />
  10. <result column="join_type" property="joinType" />
  11. <result column="level" property="level" />
  12. <result column="state" property="state" />
  13. <result column="time_limit" property="timeLimit" />
  14. <result column="start_time" property="startTime" />
  15. <result column="end_time" property="endTime" />
  16. <result column="create_time" property="createTime" />
  17. <result column="update_time" property="updateTime" />
  18. <result column="total_score" property="totalScore" />
  19. <result column="total_time" property="totalTime" />
  20. <result column="qualify_score" property="qualifyScore" />
  21. </resultMap>
  22. <!-- 通用查询结果列 -->
  23. <sql id="Base_Column_List">
  24. `id`,`title`,`content`,`open_type`,`join_type`,`level`,`state`,`time_limit`,`start_time`,`end_time`,`create_time`,`update_time`,`total_score`,`total_time`,`qualify_score`
  25. </sql>
  26. <resultMap id="ReviewResultMap"
  27. type="com.ydl.exam.modules.exam.dto.response.ExamReviewRespDTO"
  28. extends="BaseResultMap">
  29. <result column="examUser" property="examUser" />
  30. <result column="unreadPaper" property="unreadPaper" />
  31. </resultMap>
  32. <resultMap id="ListResultMap"
  33. type="com.ydl.exam.modules.exam.dto.ExamDTO"
  34. extends="BaseResultMap">
  35. </resultMap>
  36. <select id="paging" resultMap="ListResultMap">
  37. SELECT * FROM el_exam
  38. <where>
  39. <if test="query!=null">
  40. <if test="query.title!=null and query.title!=''">
  41. AND title LIKE '%${query.title}%'
  42. </if>
  43. <if test="query.openType!=null">
  44. AND open_type = #{query.openType}
  45. </if>
  46. <if test="query.startTime!=null">
  47. AND start_time >= #{query.startTime}
  48. </if>
  49. <if test="query.endTime!=null">
  50. AND end_time &lt;= #{query.endTime}
  51. </if>
  52. </if>
  53. </where>
  54. </select>
  55. <select id="reviewPaging" resultMap="ReviewResultMap">
  56. SELECT ex.*,
  57. (SELECT COUNT(DISTINCT user_id) FROM el_paper WHERE exam_id=ex.id) as examUser,
  58. (SELECT COUNT(0) FROM el_paper WHERE exam_id=ex.id AND state=1) as unreadPaper
  59. FROM el_exam ex
  60. WHERE ex.has_saq=1
  61. </select>
  62. <resultMap id="OnlineResultMap"
  63. type="com.ydl.exam.modules.exam.dto.response.ExamOnlineRespDTO"
  64. extends="BaseResultMap">
  65. </resultMap>
  66. <select id="online" resultMap="OnlineResultMap">
  67. SELECT ex.*
  68. FROM el_exam ex
  69. LEFT JOIN el_exam_depart dept ON ex.id=dept.exam_id AND ex.open_type=2
  70. LEFT JOIN sys_user uc ON uc.depart_id=dept.depart_id
  71. WHERE (ex.open_type=1 OR ex.open_type=3 OR uc.id='{{userId}}')
  72. <if test="query!=null">
  73. <if test="query.title!=null and query.title!=''">
  74. AND ex.title LIKE '%${query.title}%'
  75. </if>
  76. <if test="query.openType!=null">
  77. AND ex.open_type=#{query.openType}
  78. </if>
  79. </if>
  80. </select>
  81. </mapper>