CourseChapterMapper.xml 8.5 KB

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