ExamMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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.zhongzheng.modules.bank.mapper.ExamMapper">
  6. <resultMap type="com.zhongzheng.modules.bank.domain.Exam" id="ExamResult">
  7. <result property="examId" column="exam_id"/>
  8. <result property="status" column="status"/>
  9. <result property="createTime" column="create_time"/>
  10. <result property="updateTime" column="update_time"/>
  11. <result property="prefixName" column="prefix_name"/>
  12. <result property="code" column="code"/>
  13. <result property="examName" column="exam_name"/>
  14. <result property="publishStatus" column="publish_status"/>
  15. <result property="year" column="year"/>
  16. <result property="cityId" column="city_id"/>
  17. <result property="provinceId" column="province_id"/>
  18. <result property="examPaperId" column="exam_paper_id"/>
  19. <result property="answerTime" column="answer_time"/>
  20. <result property="examPaperId" column="exam_paper_id"/>
  21. <result property="answerNum" column="answer_num"/>
  22. <result property="sort" column="sort"/>
  23. <result property="createBy" column="create_by"/>
  24. <result property="doType" column="do_type"/>
  25. </resultMap>
  26. <resultMap type="com.zhongzheng.modules.bank.vo.ExamVo" id="ExamVoResult">
  27. <result property="examId" column="exam_id"/>
  28. <result property="status" column="status"/>
  29. <result property="createTime" column="create_time"/>
  30. <result property="updateTime" column="update_time"/>
  31. <result property="prefixName" column="prefix_name"/>
  32. <result property="code" column="code"/>
  33. <result property="examName" column="exam_name"/>
  34. <result property="publishStatus" column="publish_status"/>
  35. <result property="year" column="year"/>
  36. <result property="cityId" column="city_id"/>
  37. <result property="provinceId" column="province_id"/>
  38. <result property="examPaperId" column="exam_paper_id"/>
  39. <result property="answerTime" column="answer_time"/>
  40. <result property="examPaperId" column="exam_paper_id"/>
  41. <result property="answerNum" column="answer_num"/>
  42. <result property="sort" column="sort"/>
  43. <result property="educationName" column="education_name"/>
  44. <result property="projectName" column="project_name"/>
  45. <result property="businessName" column="business_name"/>
  46. <result property="educationTypeId" column="education_type_id"/>
  47. <result property="businessId" column="business_id"/>
  48. <result property="subjectId" column="subject_id"/>
  49. <result property="projectId" column="project_id"/>
  50. <result property="subjectName" column="subject_name"/>
  51. <result property="doType" column="do_type"/>
  52. <result property="questionNum" column="question_num"/>
  53. <collection property="goodsList" column="exam_id" select="findGoodsList"/>
  54. </resultMap>
  55. <select id="findGoodsList" resultMap="GoodsListResult">
  56. SELECT
  57. g.goods_name,
  58. g.goods_id
  59. FROM
  60. goods_attached ga
  61. LEFT JOIN goods g ON ga.goods_id = g.goods_id
  62. WHERE
  63. ga.major_id =#{exam_id} AND ga.type = 3
  64. </select>
  65. <resultMap type="com.zhongzheng.modules.bank.vo.ExamGoodsVo" id="GoodsListResult">
  66. <result property="goodsName" column="goods_name"/>
  67. <result property="goodsId" column="goods_id"/>
  68. </resultMap>
  69. <select id="getList" parameterType="com.zhongzheng.modules.bank.bo.ExamQueryBo" resultMap="ExamVoResult">
  70. SELECT
  71. e.*,
  72. qb.education_type_id,
  73. qb.business_id,
  74. qb.project_id,
  75. qb.subject_id,
  76. cet.education_name,
  77. cpt.project_name,
  78. cb.business_name,
  79. cs.subject_name,
  80. (SELECT count(*) from exam_question where exam_id = e.exam_id ) question_num
  81. FROM
  82. exam e
  83. LEFT JOIN question_business qb ON e.exam_id = qb.major_id
  84. AND qb.type = 2
  85. LEFT JOIN course_education_type cet ON qb.education_type_id = cet.id
  86. LEFT JOIN course_project_type cpt ON qb.project_id = cpt.id
  87. LEFT JOIN course_business cb ON qb.business_id = cb.id
  88. LEFT JOIN course_subject cs ON cs.id = qb.subject_id where 1=1
  89. <if test="status != null and status.size()!=0 ">
  90. AND e.status in
  91. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  92. #{item}
  93. </foreach>
  94. </if>
  95. <if test="educationTypeId != null and educationTypeId != ''">
  96. AND cet.id = #{educationTypeId}
  97. </if>
  98. <if test="examId != null and examId != ''">
  99. AND e.exam_id = #{examId}
  100. </if>
  101. <if test="subjectId != null and subjectId != ''">
  102. AND cs.id = #{subjectId}
  103. </if>
  104. <if test="businessId != null and businessId != ''">
  105. AND cb.id = #{businessId}
  106. </if>
  107. <if test="projectId != null and projectId != ''">
  108. AND cpt.id = #{projectId}
  109. </if>
  110. <if test="examPaperId != null and examPaperId != ''">
  111. AND e.exam_paper_id = #{examPaperId}
  112. </if>
  113. <if test="publishStatus != null and publishStatus != ''">
  114. AND e.publish_status = #{publishStatus}
  115. </if>
  116. <if test="examName != null and examName != ''">
  117. AND e.exam_name like concat('%', #{examName}, '%')
  118. </if>
  119. <if test="prefixName != null and prefixName != ''">
  120. AND e.prefix_name like concat('%', #{prefixName}, '%')
  121. </if>
  122. <if test="key != null and key != ''">
  123. AND (e.exam_name like concat('%', #{key}, '%') or e.prefix_name like concat('%', #{key}, '%') or e.code = #{key})
  124. </if>
  125. ORDER BY e.exam_id DESC
  126. </select>
  127. </mapper>