CourseSectionMapper.xml 11 KB

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