CourseModuleMapper.xml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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.course.mapper.CourseModuleMapper">
  6. <resultMap type="com.zhongzheng.modules.course.domain.CourseModule" id="CourseModuleResult">
  7. <result property="moduleId" column="module_id"/>
  8. <result property="prefixName" column="prefix_name"/>
  9. <result property="moduleName" column="module_name"/>
  10. <result property="coverUrl" column="cover_url"/>
  11. <result property="publishStatus" column="publish_status"/>
  12. <result property="createTime" column="create_time"/>
  13. <result property="updateTime" column="update_time"/>
  14. <result property="status" column="status"/>
  15. <result property="code" column="code"/>
  16. <result property="examType" column="exam_type"/>
  17. <result property="freeExamId" column="free_exam_id"/>
  18. </resultMap>
  19. <resultMap type="com.zhongzheng.modules.course.vo.CourseModuleVo" id="CourseModuleResultVo">
  20. <result property="moduleId" column="module_id"/>
  21. <result property="prefixName" column="prefix_name"/>
  22. <result property="moduleName" column="module_name"/>
  23. <result property="coverUrl" column="cover_url"/>
  24. <result property="publishStatus" column="publish_status"/>
  25. <result property="status" column="status"/>
  26. <result property="code" column="code"/>
  27. <result property="chapterNum" column="chapter_num"/>
  28. <result property="sectionNum" column="section_num"/>
  29. <result property="durationTime" column="duration_time"/>
  30. <result property="createTime" column="create_time"/>
  31. <result property="updateTime" column="update_time"/>
  32. <result property="examType" column="exam_type"/>
  33. <result property="freeExamId" column="free_exam_id"/>
  34. <result property="freeExamName" column="free_exam_name"/>
  35. <collection property="businessList" column="module_id" select="findBusinessList" />
  36. <collection property="courseList" column="module_id" select="findCourseList"/>
  37. </resultMap>
  38. <resultMap type="com.zhongzheng.modules.course.domain.CourseModuleBusiness" id="CourseModuleBusiness">
  39. <result property="id" column="id"/>
  40. <result property="subjectId" column="subject_id"/>
  41. <result property="educationTypeId" column="education_type_id"/>
  42. <result property="businessId" column="business_id"/>
  43. <result property="projectId" column="project_id"/>
  44. <result property="educationName" column="education_name"/>
  45. <result property="projectName" column="project_name"/>
  46. <result property="businessName" column="business_name"/>
  47. <result property="subjectName" column="subject_name"/>
  48. </resultMap>
  49. <resultMap type="com.zhongzheng.modules.course.vo.CourseSectionListVo" id="CourseSectionListResult">
  50. <result property="courseId" column="course_id"/>
  51. <result property="courseName" column="course_name"/>
  52. </resultMap>
  53. <select id="findCourseList" resultMap="CourseSectionListResult">
  54. SELECT
  55. m.course_id,
  56. co.course_name
  57. FROM
  58. ( SELECT course_id, menu_id FROM course_menu WHERE type = 1 AND STATUS = 1 ) m
  59. LEFT JOIN course co ON m.course_id = co.course_id
  60. WHERE
  61. m.menu_id=#{module_id} AND co.`status` !=-1
  62. </select>
  63. <select id="findBusinessList" resultMap="CourseModuleBusiness">
  64. SELECT
  65. cmb.education_type_id,
  66. cmb.id,
  67. cmb.business_id,
  68. cmb.subject_id,
  69. cmb.project_id,
  70. cet.education_name,
  71. cpt.project_name,
  72. cb.business_name,
  73. cs.subject_name
  74. FROM
  75. course_module_business cmb
  76. LEFT JOIN course_education_type cet ON cmb.education_type_id = cet.id AND cet.status =1
  77. LEFT JOIN course_project_type cpt ON cmb.project_id = cpt.id AND cpt.status =1
  78. LEFT JOIN course_business cb ON cmb.business_id = cb.id AND cb.status =1
  79. LEFT JOIN course_subject cs ON cmb.subject_id = cs.id AND cs.status =1
  80. WHERE
  81. cmb.module_id=#{module_id}
  82. </select>
  83. <select id="selectList" parameterType="com.zhongzheng.modules.course.bo.CourseModuleQueryBo" resultMap="CourseModuleResultVo">
  84. SELECT
  85. c.*
  86. FROM
  87. (
  88. SELECT
  89. cm.*,
  90. count( ccs.section_id ) AS section_num,
  91. count( DISTINCT cc.chapter_id ) AS chapter_num,
  92. COALESCE ( SUM( cs.duration_time ), 0 ) AS duration_time,
  93. CASE cm.exam_type
  94. WHEN 1 THEN (SELECT module_name FROM question_module WHERE module_exam_id = cm.free_exam_id)
  95. WHEN 2 THEN (SELECT `name` FROM question_chapter WHERE chapter_exam_id = cm.free_exam_id)
  96. WHEN 3 THEN (SELECT exam_name FROM exam WHERE exam_id = cm.free_exam_id)
  97. ELSE (NULL) END as free_exam_name
  98. FROM
  99. course_module cm
  100. LEFT JOIN course_module_chapter cmc ON cm.module_id = cmc.module_id
  101. LEFT JOIN course_chapter cc ON cmc.chapter_id = cc.chapter_id
  102. LEFT JOIN course_chapter_section ccs ON cc.chapter_id = ccs.chapter_id
  103. LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
  104. WHERE
  105. cm.STATUS !=- 1
  106. GROUP BY
  107. cm.module_id
  108. ) c
  109. WHERE
  110. 1 = 1 AND c.status !=-1
  111. <if test="status != null and status.size()!=0 ">
  112. AND c.status in
  113. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  114. #{item}
  115. </foreach>
  116. </if>
  117. <if test="publishStatus != null ">
  118. AND c.publish_status = #{publishStatus}
  119. </if>
  120. <if test="educationTypeId != null and educationTypeId != ''">
  121. AND (select count(cmb.education_type_id) FROM course_module_business cmb where cmb.module_id = c.module_id and cmb.education_type_id = #{educationTypeId}) >0
  122. </if>
  123. <if test="subjectId != null and subjectId != ''">
  124. AND (select count(cmb.subject_id) FROM course_module_business cmb where cmb.module_id = c.module_id and cmb.subject_id = #{subjectId})>0
  125. </if>
  126. <if test="businessId != null and businessId != ''">
  127. AND (select count(cmb.business_id) FROM course_module_business cmb where cmb.module_id = c.module_id and cmb.business_id = #{businessId})>0
  128. </if>
  129. <if test="moduleName != null and moduleName != ''">
  130. AND c.module_name like concat('%', #{moduleName}, '%')
  131. </if>
  132. <if test="prefixName != null and prefixName != ''">
  133. AND c.prefix_name like concat('%', #{prefixName}, '%')
  134. </if>
  135. <if test="key != null and key != ''">
  136. AND (c.module_name like concat('%', #{key}, '%') or c.prefix_name like concat('%', #{key}, '%') or c.code = #{key})
  137. </if>
  138. ORDER BY c.module_id DESC
  139. </select>
  140. <select id="selectList_COUNT" resultType="Long">
  141. SELECT
  142. count( DISTINCT c.module_id )
  143. FROM
  144. course_module c
  145. LEFT JOIN course_module_business cmb ON cmb.module_id = c.module_id
  146. WHERE
  147. 1 = 1
  148. <if test="status != null and status.size()!=0 ">
  149. AND c.status in
  150. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  151. #{item}
  152. </foreach>
  153. </if>
  154. <if test="publishStatus != null ">
  155. AND c.publish_status = #{publishStatus}
  156. </if>
  157. <if test="educationTypeId != null and educationTypeId != ''">
  158. AND cmb.education_type_id = #{educationTypeId}
  159. </if>
  160. <if test="subjectId != null and subjectId != ''">
  161. AND cmb.subject_id = #{subjectId}
  162. </if>
  163. <if test="businessId != null and businessId != ''">
  164. AND cmb.business_id = #{businessId}
  165. </if>
  166. <if test="moduleName != null and moduleName != ''">
  167. AND c.module_name like concat('%', #{moduleName}, '%')
  168. </if>
  169. <if test="prefixName != null and prefixName != ''">
  170. AND c.prefix_name like concat('%', #{prefixName}, '%')
  171. </if>
  172. <if test="key != null and key != ''">
  173. AND (c.module_name like concat('%', #{key}, '%') or c.prefix_name like concat('%', #{key}, '%') or c.code = #{key})
  174. </if>
  175. </select>
  176. </mapper>