CourseMenuMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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.CourseMenuMapper">
  6. <resultMap type="com.zhongzheng.modules.course.domain.CourseMenu" id="CourseMenuResult">
  7. <result property="id" column="id"/>
  8. <result property="courseId" column="course_id"/>
  9. <result property="menuId" column="menu_id"/>
  10. <result property="type" column="type"/>
  11. <result property="parentId" column="parent_id"/>
  12. <result property="createTime" column="create_time"/>
  13. <result property="updateTime" column="update_time"/>
  14. <result property="status" column="status"/>
  15. <result property="sort" column="sort"/>
  16. </resultMap>
  17. <resultMap type="com.zhongzheng.modules.course.vo.CourseMenuVo" id="CourseMenuResultVo">
  18. <result property="id" column="id"/>
  19. <result property="courseId" column="course_id"/>
  20. <result property="menuId" column="menu_id"/>
  21. <result property="type" column="type"/>
  22. <result property="parentId" column="parent_id"/>
  23. <result property="status" column="status"/>
  24. <result property="menuName" column="menu_name"/>
  25. <result property="durationTime" column="duration_time"/>
  26. <result property="sort" column="sort"/>
  27. <result property="sectionType" column="section_type"/>
  28. <result property="liveStartTime" column="live_start_time"/>
  29. <result property="liveEndTime" column="live_end_time"/>
  30. <result property="recordingUrl" column="recording_url"/>
  31. <result property="liveUrl" column="live_url"/>
  32. <result property="examType" column="exam_type"/>
  33. <result property="freeExamId" column="free_exam_id"/>
  34. <result property="freeExamName" column="free_exam_name"/>
  35. <result property="code" column="code"/>
  36. <result property="publishStatus" column="publish_status"/>
  37. </resultMap>
  38. <resultMap type="com.zhongzheng.modules.course.vo.CourseUserMenuVo" id="CourseUserMenuVo">
  39. <result property="id" column="id"/>
  40. <result property="courseId" column="course_id"/>
  41. <result property="gradeId" column="grade_id"/>
  42. <result property="menuId" column="menu_id"/>
  43. <result property="type" column="type"/>
  44. <result property="parentId" column="parent_id"/>
  45. <result property="status" column="status"/>
  46. <result property="menuName" column="menu_name"/>
  47. <result property="durationTime" column="duration_time"/>
  48. <result property="sort" column="sort"/>
  49. <result property="sectionType" column="section_type"/>
  50. <result property="liveStartTime" column="live_start_time"/>
  51. <result property="liveEndTime" column="live_end_time"/>
  52. <result property="recordingUrl" column="recording_url"/>
  53. <result property="liveUrl" column="live_url"/>
  54. <result property="teacherName" column="teacher_name"/>
  55. <result property="goodsId" column="goods_id"/>
  56. </resultMap>
  57. <select id="getList" parameterType="com.zhongzheng.modules.course.bo.CourseMenuQueryBo" resultMap="CourseMenuResultVo">
  58. SELECT * from (SELECT
  59. m.*,
  60. cm.module_name AS menu_name,
  61. cm.publish_status AS publish_status,
  62. cm.code AS code,
  63. 0 AS duration_time,
  64. NULL AS section_type,
  65. NULL AS live_start_time,
  66. NULL AS live_end_time,
  67. NULL AS live_url,
  68. NULL AS recording_url,
  69. cm.exam_type AS exam_type,
  70. cm.free_exam_id AS free_exam_id,
  71. (
  72. CASE
  73. cm.exam_type
  74. WHEN 1 THEN
  75. ( SELECT module_name FROM question_module WHERE module_exam_id = cm.free_exam_id )
  76. WHEN 2 THEN
  77. ( SELECT `name` FROM question_chapter WHERE chapter_exam_id = cm.free_exam_id )
  78. WHEN 3 THEN
  79. ( SELECT exam_name FROM exam WHERE exam_id = cm.free_exam_id ) ELSE ( NULL )
  80. END
  81. ) free_exam_name
  82. FROM
  83. course_menu m
  84. LEFT JOIN course_module cm ON m.menu_id = cm.module_id
  85. WHERE
  86. m.course_id = #{courseId}
  87. AND m.type = 1 and cm.`status`!=-1
  88. UNION
  89. SELECT
  90. m.*,
  91. cc.`name` AS menu_name,
  92. cc.publish_status AS publish_status,
  93. cc.code AS code,
  94. 0 AS duration_time,
  95. NULL AS section_type,
  96. NULL AS live_start_time,
  97. NULL AS live_end_time,
  98. NULL AS live_url,
  99. NULL AS recording_url,
  100. NULL AS exam_type,
  101. NULL AS free_exam_id,
  102. NULL as free_exam_name
  103. FROM
  104. course_menu m
  105. LEFT JOIN course_chapter cc ON m.menu_id = cc.chapter_id
  106. WHERE
  107. m.course_id = #{courseId}
  108. AND m.type = 2 and cc.`status`!=-1
  109. UNION
  110. SELECT
  111. m.*,
  112. cs.`name` AS menu_name,
  113. cs.publish_status AS publish_status,
  114. cs.code AS code,
  115. cs.duration_time AS duration_time,
  116. cs.section_type AS section_type,
  117. cs.live_start_time AS live_start_time,
  118. cs.live_end_time AS live_end_time,
  119. cs.live_url AS live_url,
  120. cs.recording_url AS recording_url,
  121. NULL AS exam_type,
  122. NULL AS free_exam_id,
  123. NULL as free_exam_name
  124. FROM
  125. course_menu m
  126. LEFT JOIN course_section cs ON m.menu_id = cs.section_id
  127. WHERE
  128. m.course_id = #{courseId}
  129. AND m.type = 3 and cs.`status`!=-1 )un
  130. WHERE 1=1
  131. <if test="type != null and type != ''">
  132. AND un.type = #{type}
  133. </if>
  134. ORDER BY un.sort asc
  135. </select>
  136. <select id="menuList" parameterType="com.zhongzheng.modules.course.bo.CourseMenuQueryBo" resultMap="CourseUserMenuVo">
  137. SELECT
  138. m.*,
  139. #{gradeId} as grade_id,
  140. CASE
  141. WHEN m.type = 1 THEN
  142. cm.module_name
  143. WHEN m.type = 2 THEN
  144. cc.`name`
  145. WHEN m.type = 3 THEN
  146. cs.`name`
  147. END menu_name,
  148. CASE
  149. WHEN m.type = 1 THEN
  150. 0
  151. WHEN m.type = 2 THEN
  152. 0
  153. WHEN m.type = 3 THEN
  154. cs.duration_time
  155. END duration_time,
  156. cs.section_type,
  157. cs.live_start_time,
  158. cs.live_end_time,
  159. cs.live_url,
  160. CASE
  161. WHEN m.type = 1 THEN
  162. ''
  163. WHEN m.type = 2 THEN
  164. ''
  165. WHEN m.type = 3 THEN
  166. cs.recording_url
  167. END recording_url,
  168. CASE
  169. WHEN m.type = 1 THEN
  170. ''
  171. WHEN m.type = 2 THEN
  172. ''
  173. WHEN m.type = 3 THEN
  174. (SELECT teacher_name from teacher where teacher_id = cs.teacher_id)
  175. END teacher_name
  176. FROM
  177. course_menu m
  178. LEFT JOIN course_module cm ON m.menu_id = cm.module_id
  179. AND m.type = 1 and cm.status=1
  180. LEFT JOIN course_chapter cc ON m.menu_id = cc.chapter_id
  181. AND m.type = 2 and cc.status=1
  182. LEFT JOIN course_section cs ON m.menu_id = cs.section_id
  183. AND m.type = 3 and cs.status=1
  184. WHERE
  185. m.course_id = #{courseId}
  186. ORDER BY m.sort
  187. </select>
  188. <select id="getGoodsMenuList" parameterType="com.zhongzheng.modules.course.bo.CourseMenuQueryBo" resultMap="CourseUserMenuVo">
  189. SELECT
  190. gc.goods_id,
  191. m.*,
  192. #{gradeId} as grade_id,
  193. CASE
  194. WHEN m.type = 1 THEN
  195. cm.module_name
  196. WHEN m.type = 2 THEN
  197. cc.`name`
  198. WHEN m.type = 3 THEN
  199. cs.`name`
  200. END menu_name,
  201. CASE
  202. WHEN m.type = 1 THEN
  203. 0
  204. WHEN m.type = 2 THEN
  205. 0
  206. WHEN m.type = 3 THEN
  207. cs.duration_time
  208. END duration_time,
  209. cs.section_type,
  210. cs.live_start_time,
  211. cs.live_end_time,
  212. cs.live_url,
  213. CASE
  214. WHEN m.type = 1 THEN
  215. ''
  216. WHEN m.type = 2 THEN
  217. ''
  218. WHEN m.type = 3 THEN
  219. cs.recording_url
  220. END recording_url,
  221. CASE
  222. WHEN m.type = 1 THEN
  223. ''
  224. WHEN m.type = 2 THEN
  225. ''
  226. WHEN m.type = 3 THEN
  227. (SELECT teacher_name from teacher where teacher_id = cs.teacher_id)
  228. END teacher_name
  229. FROM
  230. goods_course gc
  231. INNER JOIN course_menu m ON gc.course_id = m.course_id
  232. LEFT JOIN course_module cm ON m.menu_id = cm.module_id
  233. AND m.type = 1 and cm.status=1
  234. LEFT JOIN course_chapter cc ON m.menu_id = cc.chapter_id
  235. AND m.type = 2 and cc.status=1
  236. LEFT JOIN course_section cs ON m.menu_id = cs.section_id
  237. AND m.type = 3 and cs.status=1
  238. WHERE
  239. gc.goods_id = #{goodsId}
  240. ORDER BY m.sort
  241. </select>
  242. <select id="rebuildCheck" parameterType="map" resultType="Integer">
  243. SELECT
  244. COUNT(up.id)
  245. FROM
  246. user_period up
  247. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  248. WHERE
  249. up.grade_id =#{gradeId}
  250. AND up.user_id = #{userId}
  251. AND up.module_id= 0
  252. and up.chapter_id=0
  253. and up.course_id=#{courseId}
  254. and up.section_id=#{sectionId}
  255. AND ups.period_status =1
  256. and (ups.`status` = 0 or ups.`status` = 3)
  257. </select>
  258. <delete id="deleteByIdTenant" parameterType="map">
  259. delete from course_menu where course_id = #{newCourseId} and tenant_id = #{newTenantId}
  260. </delete>
  261. <select id="rebuildSectionCheck" parameterType="map" resultType="Integer">
  262. SELECT
  263. COUNT(up.id)
  264. FROM
  265. user_period up
  266. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  267. WHERE
  268. up.grade_id =#{gradeId}
  269. AND up.user_id = #{userId}
  270. AND up.module_id= #{moduleId}
  271. and up.chapter_id= #{chapterId}
  272. and up.course_id=#{courseId}
  273. and up.section_id=#{sectionId}
  274. AND ups.period_status =1
  275. and (ups.`status` = 0 or ups.`status` = 3)
  276. </select>
  277. <select id="auditCheck" parameterType="map" resultType="Integer">
  278. SELECT
  279. COUNT(up.id)
  280. FROM
  281. user_period up
  282. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  283. WHERE
  284. up.grade_id =#{gradeId}
  285. AND up.user_id = #{userId}
  286. AND up.module_id= 0
  287. and up.chapter_id=0
  288. and up.course_id=#{courseId}
  289. and up.section_id=#{sectionId}
  290. AND ups.period_status =1
  291. and ups.`status` = 1
  292. </select>
  293. <select id="rebuildChapterCheck" parameterType="map" resultType="Integer">
  294. SELECT
  295. COUNT(up.id)
  296. FROM
  297. user_period up
  298. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  299. WHERE
  300. up.grade_id =#{gradeId}
  301. AND up.user_id = #{userId}
  302. AND up.module_id= 0
  303. and up.course_id=#{courseId}
  304. and up.chapter_id=#{chapterId}
  305. AND ups.period_status =1
  306. and (ups.`status` = 0 or ups.`status` = 3)
  307. </select>
  308. <select id="rebuildModuleCheck" parameterType="map" resultType="Integer">
  309. SELECT
  310. COUNT(up.id)
  311. FROM
  312. user_period up
  313. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  314. WHERE
  315. up.grade_id =#{gradeId}
  316. AND up.user_id = #{userId}
  317. AND up.module_id= #{moduleId}
  318. AND up.course_id=#{courseId}
  319. AND ups.period_status =1
  320. and (ups.`status` = 0 or ups.`status` = 3)
  321. </select>
  322. <select id="learningCheck" parameterType="map" resultType="Integer">
  323. SELECT
  324. COUNT(up.id)
  325. FROM
  326. user_period up
  327. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  328. WHERE
  329. up.grade_id =#{gradeId}
  330. AND up.user_id = #{userId}
  331. AND up.module_id= 0
  332. and up.chapter_id=0
  333. and up.section_id=#{sectionId}
  334. and up.course_id=#{courseId}
  335. AND ups.period_status =1
  336. and ups.record_end_time is not null
  337. </select>
  338. <select id="getStudyDuration" parameterType="map" resultType="long">
  339. SELECT
  340. IFNULL(MAX(usr.video_current_time),0) as study_duration
  341. FROM
  342. user_study_record usr
  343. WHERE
  344. usr.grade_id =#{gradeId}
  345. AND usr.user_id = #{userId}
  346. AND usr.module_id= 0
  347. and usr.chapter_id=0
  348. and usr.section_id=#{sectionId}
  349. and usr.course_id=#{courseId}
  350. AND usr.current_status =1
  351. </select>
  352. </mapper>