CourseSectionMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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.CourseSectionMapper">
  6. <resultMap type="com.zhongzheng.modules.course.domain.CourseSection" id="CourseSectionResult">
  7. <result property="sectionId" column="section_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="prefixName" column="prefix_name"/>
  13. <result property="status" column="status"/>
  14. <result property="sectionType" column="section_type"/>
  15. <result property="publishStatus" column="publish_status"/>
  16. <result property="liveUrl" column="live_url"/>
  17. <result property="liveStartTime" column="live_start_time"/>
  18. <result property="liveEndTime" column="live_end_time"/>
  19. <result property="recordingUrl" column="recording_url"/>
  20. <result property="durationTime" column="duration_time"/>
  21. <result property="coverUrl" column="cover_url"/>
  22. <result property="code" column="code"/>
  23. <result property="importBy" column="import_by"/>
  24. <result property="importNo" column="import_no"/>
  25. <result property="sessionId" column="session_id"/>
  26. <result property="realLiveStartTime" column="real_live_start_time"/>
  27. <result property="realLiveEndTime" column="real_live_end_time"/>
  28. <result property="realDuration" column="real_duration"/>
  29. <result property="teacherId" column="teacher_id"/>
  30. </resultMap>
  31. <resultMap type="com.zhongzheng.modules.course.vo.CourseSectionVo" id="CourseSectionResultVo">
  32. <result property="sectionId" column="section_id"/>
  33. <result property="name" column="name"/>
  34. <result property="sort" column="sort"/>
  35. <result property="prefixName" column="prefix_name"/>
  36. <result property="status" column="status"/>
  37. <result property="sectionType" column="section_type"/>
  38. <result property="publishStatus" column="publish_status"/>
  39. <result property="liveUrl" column="live_url"/>
  40. <result property="liveStartTime" column="live_start_time"/>
  41. <result property="liveEndTime" column="live_end_time"/>
  42. <result property="recordingUrl" column="recording_url"/>
  43. <result property="durationTime" column="duration_time"/>
  44. <result property="coverUrl" column="cover_url"/>
  45. <result property="code" column="code"/>
  46. <result property="createTime" column="create_time"/>
  47. <result property="updateTime" column="update_time"/>
  48. <result property="sessionId" column="session_id"/>
  49. <result property="realLiveStartTime" column="real_live_start_time"/>
  50. <result property="realLiveEndTime" column="real_live_end_time"/>
  51. <result property="realDuration" column="real_duration"/>
  52. <result property="teacherId" column="teacher_id"/>
  53. <collection property="businessList" column="section_id" select="findBusinessList"/>
  54. <collection property="chapterList" column="section_id" select="findChapterList"/>
  55. <!-- <collection property="moduleList" javaType="java.util.List" resultMap="CourseModuleChapterListResult"/>
  56. <collection property="courseList" javaType="java.util.List" resultMap="CourseSectionListResult"/> -->
  57. </resultMap>
  58. <select id="findChapterList" resultMap="CourseChapterSectionListResult">
  59. SELECT
  60. ccs.chapter_id,
  61. cc.NAME AS chapter_name
  62. FROM
  63. course_chapter_section ccs
  64. LEFT JOIN course_chapter cc ON ccs.chapter_id = cc.chapter_id
  65. WHERE
  66. ccs.section_id =#{section_id}
  67. and cc.status =1
  68. </select>
  69. <select id="findBusinessList" resultMap="CourseSectionBusiness">
  70. SELECT
  71. csb.education_type_id,
  72. csb.id,
  73. csb.business_id,
  74. csb.subject_id,
  75. csb.project_id,
  76. cet.education_name,
  77. cpt.project_name,
  78. cb.business_name,
  79. cs.subject_name
  80. FROM
  81. course_section_business csb
  82. LEFT JOIN course_education_type cet ON csb.education_type_id = cet.id AND cet.status =1
  83. LEFT JOIN course_project_type cpt ON csb.project_id = cpt.id AND cpt.status =1
  84. LEFT JOIN course_business cb ON csb.business_id = cb.id AND cb.status =1
  85. LEFT JOIN course_subject cs ON csb.subject_id = cs.id AND cs.status =1
  86. WHERE
  87. csb.section_id=#{section_id}
  88. </select>
  89. <resultMap type="com.zhongzheng.modules.course.domain.CourseSectionBusiness" id="CourseSectionBusiness">
  90. <result property="id" column="id"/>
  91. <result property="subjectId" column="subject_id"/>
  92. <result property="educationTypeId" column="education_type_id"/>
  93. <result property="businessId" column="business_id"/>
  94. <result property="projectId" column="project_id"/>
  95. <result property="educationName" column="education_name"/>
  96. <result property="projectName" column="project_name"/>
  97. <result property="businessName" column="business_name"/>
  98. <result property="subjectName" column="subject_name"/>
  99. </resultMap>
  100. <resultMap type="com.zhongzheng.modules.course.vo.CourseChapterSectionListVo" id="CourseChapterSectionListResult">
  101. <result property="chapterName" column="chapter_name"/>
  102. <result property="chapterId" column="chapter_id"/>
  103. </resultMap>
  104. <resultMap type="com.zhongzheng.modules.course.vo.CourseModuleChapterListVo" id="CourseModuleChapterListResult">
  105. <result property="moduleId" column="module_id"/>
  106. <result property="moduleName" column="module_name"/>
  107. </resultMap>
  108. <resultMap type="com.zhongzheng.modules.course.vo.CourseSectionListVo" id="CourseSectionListResult">
  109. <result property="courseId" column="course_id"/>
  110. <result property="courseName" column="course_name"/>
  111. </resultMap>
  112. <select id="selectSectionList" parameterType="com.zhongzheng.modules.course.bo.CourseSectionQueryBo" resultMap="CourseSectionResultVo">
  113. SELECT
  114. c.*
  115. FROM
  116. course_section c
  117. LEFT JOIN course_section_business csb ON csb.section_id = c.section_id
  118. WHERE
  119. 1 = 1 AND c.status !=-1
  120. <if test="name != null and name != ''">
  121. AND c.name like concat('%', #{name}, '%')
  122. </if>
  123. <if test="publishStatus != null ">
  124. AND c.publish_status = #{publishStatus}
  125. </if>
  126. <if test="educationTypeId != null and educationTypeId != ''">
  127. AND csb.education_type_id = #{educationTypeId}
  128. </if>
  129. <if test="subjectId != null and subjectId != ''">
  130. AND csb.subject_id = #{subjectId}
  131. </if>
  132. <if test="businessId != null and businessId != ''">
  133. AND csb.business_id = #{businessId}
  134. </if>
  135. <if test="sectionType != null and sectionType != ''">
  136. AND c.section_type = #{sectionType}
  137. </if>
  138. <if test="prefixName != null and prefixName != ''">
  139. AND c.prefix_name like concat('%', #{prefixName}, '%')
  140. </if>
  141. <if test="key != null and key != ''">
  142. AND (c.name like concat('%', #{key}, '%') or c.prefix_name like concat('%', #{key}, '%') or c.code = #{key})
  143. </if>
  144. <if test="status != null and status.size()!=0 ">
  145. AND c.status in
  146. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  147. #{item}
  148. </foreach>
  149. </if>
  150. <if test="sectionIds != null and sectionIds.size()!=0 ">
  151. AND c.section_id in
  152. <foreach collection="sectionIds" item="item" index="index" open="(" close=")" separator=",">
  153. #{item}
  154. </foreach>
  155. </if>
  156. <if test="importNo != null and importNo != ''">
  157. AND c.import_no = #{importNo}
  158. </if>
  159. GROUP BY
  160. c.section_id
  161. ORDER BY c.section_id DESC
  162. </select>
  163. <select id="selectSectionList_COUNT" resultType="Long">
  164. SELECT
  165. count(distinct c.section_id )
  166. FROM
  167. course_section c
  168. LEFT JOIN course_section_business csb ON c.section_id = csb.section_id
  169. WHERE
  170. 1 = 1
  171. <if test="name != null and name != ''">
  172. AND c.name like concat('%', #{name}, '%')
  173. </if>
  174. <if test="publishStatus != null ">
  175. AND c.publish_status = #{publishStatus}
  176. </if>
  177. <if test="educationTypeId != null and educationTypeId != ''">
  178. AND csb.education_type_id = #{educationTypeId}
  179. </if>
  180. <if test="subjectId != null and subjectId != ''">
  181. AND csb.subject_id = #{subjectId}
  182. </if>
  183. <if test="businessId != null and businessId != ''">
  184. AND csb.business_id = #{businessId}
  185. </if>
  186. <if test="sectionType != null and sectionType != ''">
  187. AND c.section_type = #{sectionType}
  188. </if>
  189. <if test="prefixName != null and prefixName != ''">
  190. AND c.prefix_name like concat('%', #{prefixName}, '%')
  191. </if>
  192. <if test="key != null and key != ''">
  193. AND (c.name like concat('%', #{key}, '%') or c.prefix_name like concat('%', #{key}, '%') or c.code = #{key})
  194. </if>
  195. <if test="status != null and status.size()!=0 ">
  196. AND c.status in
  197. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  198. #{item}
  199. </foreach>
  200. </if>
  201. <if test="importNo != null and importNo != ''">
  202. AND c.import_no = #{importNo}
  203. </if>
  204. </select>
  205. <select id="overSectionList" parameterType="map" resultMap="CourseSectionResultVo">
  206. SELECT * from course_section cs where cs.section_type = 2 and cs.live_end_time >= #{startTime} and #{endTime} >= cs.live_end_time
  207. </select>
  208. <select id="livingSectionList" parameterType="map" resultMap="CourseSectionResultVo">
  209. SELECT * from course_section cs where cs.section_type = 2 and cs.live_end_time >= #{nowTime} and #{nowTime} >= cs.live_start_time
  210. </select>
  211. <select id="checkUserHaveLiveGoods" parameterType="map" resultType="long">
  212. SELECT
  213. og.order_goods_id
  214. FROM
  215. `order` o
  216. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  217. WHERE
  218. o.user_id = #{userId}
  219. AND og.goods_id = #{goodsId}
  220. and og.`status` = 1
  221. and og.refund_status in (0,1,3)
  222. and og.pay_status in (2,3,4)
  223. limit 1
  224. </select>
  225. <select id="checkCrossLiveTime" parameterType="map" resultType="long">
  226. SELECT count(*) from course_section cs where ((#{startTime} >= cs.live_start_time and cs.live_end_time >= #{startTime})
  227. or (cs.live_end_time >= #{endTime} and #{endTime} >= cs.live_start_time) or (cs.live_start_time >= #{startTime} and
  228. #{endTime} >= cs.live_end_time))
  229. <if test="sectionId != null and sectionId != ''">
  230. AND cs.section_id != #{sectionId}
  231. </if>
  232. AND cs.live_url = #{liveUrl}
  233. AND cs.`status` != -1
  234. </select>
  235. <select id="getSectionByTenant" parameterType="map" resultType="com.zhongzheng.modules.course.domain.CourseSection">
  236. SELECT * from course_section where code = #{code} and tenant_id = #{newTenantId}
  237. </select>
  238. <select id="getSectionByNotTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.course.domain.CourseSection">
  239. SELECT * from course_section where section_id = #{sid}
  240. </select>
  241. <select id="getSectionByTenantTwo" parameterType="map" resultType="com.zhongzheng.modules.course.domain.CourseSection">
  242. SELECT * from course_section where `name` = #{name} and code = #{code} and tenant_id = #{tenantId}
  243. </select>
  244. </mapper>