QuestionChapterMapper.xml 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.QuestionChapterMapper">
  6. <resultMap type="com.zhongzheng.modules.bank.domain.QuestionChapter" id="QuestionChapterResult">
  7. <result property="chapterExamId" column="chapter_exam_id"/>
  8. <result property="name" column="name"/>
  9. <result property="sort" column="sort"/>
  10. <result property="createTime" column="create_time"/>
  11. <result property="updateTime" column="update_time"/>
  12. <result property="status" column="status"/>
  13. <result property="prefixName" column="prefix_name"/>
  14. <result property="publishStatus" column="publish_status"/>
  15. <result property="code" column="code"/>
  16. </resultMap>
  17. <resultMap type="com.zhongzheng.modules.bank.vo.QuestionChapterVo" id="QuestionChapterResultVo">
  18. <result property="chapterExamId" column="chapter_exam_id"/>
  19. <result property="name" column="name"/>
  20. <result property="sort" column="sort"/>
  21. <result property="status" column="status"/>
  22. <result property="prefixName" column="prefix_name"/>
  23. <result property="publishStatus" column="publish_status"/>
  24. <result property="code" column="code"/>
  25. <result property="educationName" column="education_name"/>
  26. <result property="projectName" column="project_name"/>
  27. <result property="businessName" column="business_name"/>
  28. <result property="educationTypeId" column="education_type_id"/>
  29. <result property="businessId" column="business_id"/>
  30. <result property="subjectId" column="subject_id"/>
  31. <result property="projectId" column="project_id"/>
  32. <result property="subjectName" column="subject_name"/>
  33. <result property="examNum" column="exam_num"/>
  34. <collection property="goodsList" column="chapter_exam_id" select="findGoodsList"/>
  35. </resultMap>
  36. <select id="findGoodsList" resultMap="GoodsListResult">
  37. SELECT
  38. g.goods_name,
  39. g.goods_id
  40. FROM
  41. goods_attached ga
  42. LEFT JOIN goods g ON ga.goods_id = g.goods_id
  43. WHERE
  44. ga.major_id =#{chapter_exam_id} AND ga.type = 2
  45. </select>
  46. <resultMap type="com.zhongzheng.modules.bank.vo.ExamGoodsVo" id="GoodsListResult">
  47. <result property="goodsName" column="goods_name"/>
  48. <result property="goodsId" column="goods_id"/>
  49. </resultMap>
  50. <select id="getList" parameterType="com.zhongzheng.modules.bank.bo.QuestionChapterQueryBo" resultMap="QuestionChapterResultVo">
  51. SELECT
  52. qc.*,
  53. qb.education_type_id,
  54. qb.business_id,
  55. qb.project_id,
  56. qb.subject_id,
  57. cet.education_name,
  58. cpt.project_name,
  59. cb.business_name,
  60. cs.subject_name,
  61. (SELECT COUNT(qce.exam_id) FROM question_chapter_exam qce where qce.chapter_exam_id = qc.chapter_exam_id ) as exam_num
  62. FROM
  63. question_chapter qc
  64. LEFT JOIN question_business qb ON qc.chapter_exam_id = qb.major_id
  65. AND qb.type = 3
  66. LEFT JOIN course_education_type cet ON qb.education_type_id = cet.id
  67. LEFT JOIN course_project_type cpt ON qb.project_id = cpt.id
  68. LEFT JOIN course_business cb ON qb.business_id = cb.id
  69. LEFT JOIN course_subject cs ON cs.id = qb.subject_id where 1=1
  70. <if test="educationTypeId != null and educationTypeId != ''">
  71. AND cet.id = #{educationTypeId}
  72. </if>
  73. <if test="subjectId != null and subjectId != ''">
  74. AND cs.id = #{subjectId}
  75. </if>
  76. <if test="businessId != null and businessId != ''">
  77. AND cb.id = #{businessId}
  78. </if>
  79. <if test="projectId != null and projectId != ''">
  80. AND cpt.id = #{projectId}
  81. </if>
  82. <if test="publishStatus != null and publishStatus != ''">
  83. AND qc.publish_status = #{publishStatus}
  84. </if>
  85. <if test="name != null and name != ''">
  86. AND qc.name like concat('%', #{name}, '%')
  87. </if>
  88. <if test="prefixName != null and prefixName != ''">
  89. AND qc.prefix_name like concat('%', #{prefixName}, '%')
  90. </if>
  91. ORDER BY qc.chapter_exam_id DESC
  92. </select>
  93. </mapper>