CourseSectionMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. <result property="viewSign" column="view_sign"/>
  54. <collection property="businessList" column="section_id" select="findBusinessList"/>
  55. <collection property="chapterList" column="section_id" select="findChapterList"/>
  56. <!-- <collection property="moduleList" javaType="java.util.List" resultMap="CourseModuleChapterListResult"/>
  57. <collection property="courseList" javaType="java.util.List" resultMap="CourseSectionListResult"/> -->
  58. </resultMap>
  59. <select id="findChapterList" resultMap="CourseChapterSectionListResult">
  60. SELECT
  61. ccs.chapter_id,
  62. cc.NAME AS chapter_name
  63. FROM
  64. course_chapter_section ccs
  65. LEFT JOIN course_chapter cc ON ccs.chapter_id = cc.chapter_id
  66. WHERE
  67. ccs.section_id =#{section_id}
  68. and cc.status =1
  69. ORDER BY ccs.sort
  70. </select>
  71. <select id="findBusinessList" resultMap="CourseSectionBusiness">
  72. SELECT
  73. csb.education_type_id,
  74. csb.id,
  75. csb.business_id,
  76. csb.subject_id,
  77. csb.project_id,
  78. cet.education_name,
  79. cpt.project_name,
  80. cb.business_name,
  81. cs.subject_name
  82. FROM
  83. course_section_business csb
  84. LEFT JOIN course_education_type cet ON csb.education_type_id = cet.id AND cet.status =1
  85. LEFT JOIN course_project_type cpt ON csb.project_id = cpt.id AND cpt.status =1
  86. LEFT JOIN course_business cb ON csb.business_id = cb.id AND cb.status =1
  87. LEFT JOIN course_subject cs ON csb.subject_id = cs.id AND cs.status =1
  88. WHERE
  89. csb.section_id=#{section_id}
  90. </select>
  91. <resultMap type="com.zhongzheng.modules.course.domain.CourseSectionBusiness" id="CourseSectionBusiness">
  92. <result property="id" column="id"/>
  93. <result property="subjectId" column="subject_id"/>
  94. <result property="educationTypeId" column="education_type_id"/>
  95. <result property="businessId" column="business_id"/>
  96. <result property="projectId" column="project_id"/>
  97. <result property="educationName" column="education_name"/>
  98. <result property="projectName" column="project_name"/>
  99. <result property="businessName" column="business_name"/>
  100. <result property="subjectName" column="subject_name"/>
  101. </resultMap>
  102. <resultMap type="com.zhongzheng.modules.course.vo.CourseChapterSectionListVo" id="CourseChapterSectionListResult">
  103. <result property="chapterName" column="chapter_name"/>
  104. <result property="chapterId" column="chapter_id"/>
  105. </resultMap>
  106. <resultMap type="com.zhongzheng.modules.course.vo.CourseModuleChapterListVo" id="CourseModuleChapterListResult">
  107. <result property="moduleId" column="module_id"/>
  108. <result property="moduleName" column="module_name"/>
  109. </resultMap>
  110. <resultMap type="com.zhongzheng.modules.course.vo.CourseSectionListVo" id="CourseSectionListResult">
  111. <result property="courseId" column="course_id"/>
  112. <result property="courseName" column="course_name"/>
  113. </resultMap>
  114. <select id="selectSectionList" parameterType="com.zhongzheng.modules.course.bo.CourseSectionQueryBo" resultMap="CourseSectionResultVo">
  115. SELECT
  116. c.*
  117. FROM
  118. course_section c
  119. WHERE
  120. 1 = 1 AND c.status !=-1
  121. <if test="name != null and name != ''">
  122. AND c.name like concat('%', #{name}, '%')
  123. </if>
  124. <if test="publishStatus != null ">
  125. AND c.publish_status = #{publishStatus}
  126. </if>
  127. <if test="educationTypeId != null and educationTypeId != ''">
  128. AND (select count(*) from course_section_business csb where csb.section_id = c.section_id and education_type_id = #{educationTypeId})>0
  129. </if>
  130. <if test="subjectId != null and subjectId != ''">
  131. AND (select count(*) from course_section_business csb where csb.section_id = c.section_id and subject_id = #{subjectId})>0
  132. </if>
  133. <if test="businessId != null and businessId != ''">
  134. AND (select count(*) from course_section_business csb where csb.section_id = c.section_id and business_id = #{businessId})>0
  135. </if>
  136. <if test="sectionType != null and sectionType != ''">
  137. AND c.section_type = #{sectionType}
  138. </if>
  139. <if test="viewSign != null and viewSign != ''">
  140. AND c.view_sign = #{viewSign}
  141. </if>
  142. <if test="prefixName != null and prefixName != ''">
  143. AND c.prefix_name like concat('%', #{prefixName}, '%')
  144. </if>
  145. <if test="key != null and key != ''">
  146. AND (c.name like concat('%', #{key}, '%') or c.prefix_name like concat('%', #{key}, '%') or c.code = #{key})
  147. </if>
  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="sectionIds != null and sectionIds.size()!=0 ">
  155. AND c.section_id in
  156. <foreach collection="sectionIds" item="item" index="index" open="(" close=")" separator=",">
  157. #{item}
  158. </foreach>
  159. </if>
  160. <if test="importNo != null and importNo != ''">
  161. AND c.import_no = #{importNo}
  162. </if>
  163. ORDER BY c.section_id DESC
  164. </select>
  165. <select id="overSectionList" parameterType="map" resultMap="CourseSectionResultVo">
  166. SELECT * from course_section cs where cs.section_type = 2 and cs.live_end_time >= #{startTime} and #{endTime} >= cs.live_end_time
  167. </select>
  168. <select id="livingSectionList" parameterType="map" resultMap="CourseSectionResultVo">
  169. SELECT * from course_section cs where cs.section_type = 2 and cs.live_end_time >= #{nowTime} and #{nowTime} >= cs.live_start_time
  170. </select>
  171. <select id="checkUserHaveLiveGoods" parameterType="map" resultType="long">
  172. SELECT
  173. og.order_goods_id
  174. FROM
  175. `order` o
  176. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  177. WHERE
  178. o.user_id = #{userId}
  179. AND og.goods_id = #{goodsId}
  180. and og.`status` = 1
  181. and og.refund_status in (0,1,3)
  182. and og.pay_status in (2,3,4)
  183. limit 1
  184. </select>
  185. <select id="checkCrossLiveTime" parameterType="map" resultType="long">
  186. SELECT count(*) from course_section cs where ((#{startTime} >= cs.live_start_time and cs.live_end_time >= #{startTime})
  187. or (cs.live_end_time >= #{endTime} and #{endTime} >= cs.live_start_time) or (cs.live_start_time >= #{startTime} and
  188. #{endTime} >= cs.live_end_time))
  189. <if test="sectionId != null and sectionId != ''">
  190. AND cs.section_id != #{sectionId}
  191. </if>
  192. AND cs.live_url = #{liveUrl}
  193. AND cs.`status` != -1
  194. </select>
  195. <select id="getSectionByTenant" parameterType="map" resultType="com.zhongzheng.modules.course.domain.CourseSection">
  196. SELECT * from course_section where code = #{code} and tenant_id = #{newTenantId}
  197. </select>
  198. <select id="getSectionByNotTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.course.domain.CourseSection">
  199. SELECT * from course_section where section_id = #{sid}
  200. </select>
  201. <select id="getSectionByTenantTwo" parameterType="map" resultType="com.zhongzheng.modules.course.domain.CourseSection">
  202. SELECT * from course_section where `name` = #{name} and code = #{code} and tenant_id = #{tenantId}
  203. </select>
  204. </mapper>