MockApplyMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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.mock.mapper.MockApplyMapper">
  6. <resultMap type="com.zhongzheng.modules.mock.domain.MockApply" id="MockApplyResult">
  7. <result property="applyId" column="apply_id"/>
  8. <result property="applyUrl" column="apply_url"/>
  9. <result property="applyName" column="apply_name"/>
  10. <result property="applyIntroduce" column="apply_introduce"/>
  11. <result property="applyStartTime" column="apply_start_time"/>
  12. <result property="applyEndTime" column="apply_end_time"/>
  13. <result property="createTime" column="create_time"/>
  14. <result property="updateTime" column="update_time"/>
  15. <result property="status" column="status"/>
  16. <result property="educationTypeId" column="education_type_id"/>
  17. <result property="businessId" column="business_id"/>
  18. <result property="projectId" column="project_id"/>
  19. <result property="code" column="code"/>
  20. <result property="mockRemind" column="mockRemind"/>
  21. </resultMap>
  22. <resultMap type="com.zhongzheng.modules.mock.vo.MockApplyVo" id="MockApplyVoResult">
  23. <result property="applyId" column="apply_id"/>
  24. <result property="applyUrl" column="apply_url"/>
  25. <result property="applyName" column="apply_name"/>
  26. <result property="applyIntroduce" column="apply_introduce"/>
  27. <result property="applyStartTime" column="apply_start_time"/>
  28. <result property="applyEndTime" column="apply_end_time"/>
  29. <result property="status" column="status"/>
  30. <result property="educationTypeId" column="education_type_id"/>
  31. <result property="educationName" column="education_name"/>
  32. <result property="businessId" column="business_id"/>
  33. <result property="businessName" column="business_name"/>
  34. <result property="projectId" column="project_id"/>
  35. <result property="projectName" column="project_name"/>
  36. <result property="code" column="code"/>
  37. <result property="mockMajorId" column="mock_major_id"/>
  38. <result property="mockMajorSubjectId" column="mock_major_subject_id"/>
  39. <result property="subjectId" column="subject_id"/>
  40. <result property="subjectName" column="subject_name"/>
  41. <result property="examId" column="exam_id"/>
  42. <result property="sectionId" column="section_id"/>
  43. <result property="subscribeNum" column="subscribe_num"/>
  44. <result property="subscribeCancelNum" column="subscribe_cancel_num"/>
  45. <result property="majorId" column="major_id"/>
  46. <result property="categoryName" column="category_name"/>
  47. <result property="eachExamId" column="each_exam_id"/>
  48. <result property="sectionType" column="section_type"/>
  49. <result property="liveUrl" column="live_url"/>
  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="coverUrl" column="cover_url"/>
  54. <result property="mockRemind" column="mockRemind"/>
  55. </resultMap>
  56. <resultMap type="com.zhongzheng.modules.course.vo.CourseSectionVo" id="CourseSectionResultVo">
  57. <result property="sectionId" column="section_id"/>
  58. <result property="name" column="name"/>
  59. <result property="sort" column="sort"/>
  60. <result property="prefixName" column="prefix_name"/>
  61. <result property="status" column="status"/>
  62. <result property="sectionType" column="section_type"/>
  63. <result property="publishStatus" column="publish_status"/>
  64. <result property="liveUrl" column="live_url"/>
  65. <result property="liveStartTime" column="live_start_time"/>
  66. <result property="liveEndTime" column="live_end_time"/>
  67. <result property="recordingUrl" column="recording_url"/>
  68. <result property="durationTime" column="duration_time"/>
  69. <result property="coverUrl" column="cover_url"/>
  70. <result property="code" column="code"/>
  71. <result property="createTime" column="create_time"/>
  72. <result property="updateTime" column="update_time"/>
  73. <result property="sessionId" column="session_id"/>
  74. <result property="realLiveStartTime" column="real_live_start_time"/>
  75. <result property="realLiveEndTime" column="real_live_end_time"/>
  76. <result property="realDuration" column="real_duration"/>
  77. <result property="teacherId" column="teacher_id"/>
  78. <collection property="businessList" column="section_id" select="findBusinessList"/>
  79. <collection property="chapterList" column="section_id" select="findChapterList"/>
  80. <!-- <collection property="moduleList" javaType="java.util.List" resultMap="CourseModuleChapterListResult"/>
  81. <collection property="courseList" javaType="java.util.List" resultMap="CourseSectionListResult"/> -->
  82. </resultMap>
  83. <select id="getMockSubjectInfo" parameterType="java.lang.Long" resultMap="MockApplyVoResult">
  84. SELECT ma.*,
  85. mm.mock_major_id,
  86. major_id,
  87. mms.mock_major_subject_id,
  88. mms.subject_id,
  89. mms.site_time,
  90. mms.exam_id,
  91. mms.section_id
  92. FROM mock_apply ma
  93. LEFT JOIN mock_major mm ON ma.apply_id = mm.apply_id
  94. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  95. WHERE
  96. mms.mock_major_subject_id = #{mockMajorSubjectId}
  97. </select>
  98. <select id="listApply" parameterType="com.zhongzheng.modules.mock.bo.MockApplyQueryBo" resultMap="MockApplyVoResult">
  99. SELECT ma.*,
  100. cet.education_name,
  101. cb.business_name,
  102. cpt.project_name
  103. FROM mock_apply ma
  104. LEFT JOIN course_education_type cet ON ma.education_type_id = cet.id
  105. LEFT JOIN course_business cb ON ma.business_id = cb.id
  106. LEFT JOIN course_project_type cpt ON ma.project_id = cpt.id
  107. WHERE
  108. 1=1
  109. <if test="status != null and status.size()!=0 ">
  110. AND ma.status in
  111. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  112. #{item}
  113. </foreach>
  114. </if>
  115. ORDER BY ma.create_time desc
  116. </select>
  117. <select id="queryApplyList" parameterType="com.zhongzheng.modules.mock.bo.MockApplyQueryBo" resultMap="MockApplyVoResult">
  118. SELECT ma.apply_id,
  119. ma.business_id,
  120. cb.business_name,
  121. ma.apply_name,
  122. ma.project_id,
  123. cpt.project_name,
  124. mm.major_id,
  125. m.category_name,
  126. mms.subject_id,
  127. cs.subject_name,
  128. mms.exam_id,
  129. mms.section_id,
  130. mmst.exam_time,
  131. mmst.start_time,
  132. mmst.end_time,
  133. mms.mock_major_subject_id,
  134. ma.apply_start_time,
  135. ma.apply_end_time,
  136. mmst.id each_exam_id
  137. FROM mock_apply ma
  138. LEFT JOIN course_business cb ON ma.business_id = cb.id
  139. LEFT JOIN course_project_type cpt ON ma.project_id = cpt.id
  140. LEFT JOIN mock_major mm ON ma.apply_id = mm.apply_id
  141. LEFT JOIN major m ON mm.major_id = m.id
  142. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  143. LEFT JOIN course_subject cs ON mms.subject_id = cs.id
  144. LEFT JOIN mock_major_subject_time mmst ON mms.mock_major_subject_id = mmst.mock_major_subject_id
  145. WHERE
  146. UNIX_TIMESTAMP(NOW()) &lt; mmst.exam_time
  147. <if test="timeLimitMillisecond != null">
  148. + #{timeLimitMillisecond}
  149. </if>
  150. and ma.`status` = 1
  151. <if test="projectId != null and projectId != ''">
  152. and ma.project_id = #{projectId}
  153. </if>
  154. <if test="majorId != null and majorId != ''">
  155. and mm.major_id = #{majorId}
  156. </if>
  157. <if test="subjectId != null and subjectId != ''">
  158. and mms.subject_id = #{subjectId}
  159. </if>
  160. <if test="businessId != null and businessId != ''">
  161. and ma.business_id = #{businessId}
  162. </if>
  163. <if test="startTime != null and startTime != ''">
  164. and mmst.exam_time &gt; #{startTime}
  165. </if>
  166. <if test="endTime != null and endTime != ''">
  167. and mmst.exam_time &lt; #{endTime}
  168. </if>
  169. ORDER BY mmst.exam_time
  170. </select>
  171. <select id="listApplyBusiness" resultType="com.zhongzheng.modules.mock.vo.MockApplyVo">
  172. SELECT a.business_id,a.business_name,a.project_id,a.project_name,a.education_type_id,a.education_name
  173. FROM
  174. (SELECT DISTINCT
  175. ma.business_id,
  176. cb.business_name,
  177. ma.project_id,
  178. cpt.project_name,
  179. ma.education_type_id,
  180. cet.education_name
  181. FROM mock_apply ma
  182. LEFT JOIN course_project_type cpt ON ma.project_id = cpt.id
  183. LEFT JOIN course_business cb ON ma.business_id = cb.id
  184. LEFT JOIN mock_major mm ON ma.apply_id = mm.apply_id
  185. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  186. LEFT JOIN mock_major_subject_time mmst ON mms.mock_major_subject_id = mmst.id
  187. LEFT JOIN course_education_type cet ON ma.education_type_id = cet.id
  188. WHERE 1=1 and ma.mock_activity = 0
  189. <if test="startTime != null and startTime != ''">
  190. and mmst.exam_time &gt; #{startTime}
  191. </if>
  192. <if test="endTime != null and endTime != ''">
  193. and mmst.exam_time &lt; #{endTime}
  194. </if>
  195. UNION ALL
  196. SELECT DISTINCT
  197. g.business_id,
  198. cb.business_name,
  199. g.project_id,
  200. cpt.project_name,
  201. g.education_type_id,
  202. cet.education_name
  203. FROM `order` o
  204. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  205. LEFT JOIN goods g ON og.goods_id = g.goods_id
  206. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  207. LEFT JOIN course_business cb ON g.business_id = cb.id
  208. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  209. WHERE 1=1
  210. <if test="userId != null and userId != ''">
  211. and o.user_id = #{userId}
  212. </if>
  213. ) a
  214. GROUP BY a.business_id,a.business_name,a.project_id,a.project_name,a.education_type_id,a.education_name
  215. HAVING COUNT(a.project_id)=2
  216. </select>
  217. <select id="listMockLive" parameterType="com.zhongzheng.modules.mock.bo.MockApplyQueryBo" resultMap="MockApplyVoResult">
  218. SELECT
  219. ma.*,
  220. cb.business_name,
  221. cpt.project_name,
  222. cs.section_type,
  223. cs.live_url,
  224. cs.live_start_time,
  225. cs.live_end_time,
  226. cs.recording_url,
  227. cs.cover_url
  228. FROM
  229. mock_apply ma
  230. LEFT JOIN mock_major mm ON ma.apply_id = mm.apply_id
  231. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  232. LEFT JOIN course_business cb ON ma.business_id = cb.id
  233. LEFT JOIN course_project_type cpt ON ma.project_id = cpt.id
  234. LEFT JOIN course_section cs ON mms.section_id = cs.section_id
  235. WHERE 1=1
  236. <if test="startTime != null and startTime != ''">
  237. AND cs.live_start_time &gt; #{startTime}
  238. </if>
  239. <if test="endTime != null and endTime != ''">
  240. AND cs.live_end_time &lt; #{endTime}
  241. </if>
  242. <if test="applyName != null and applyName != ''">
  243. AND ma.apply_name = #{applyName}
  244. </if>
  245. </select>
  246. <select id="listSubjects" resultMap="MockApplyVoResult">
  247. SELECT
  248. ma.*,
  249. mms.subject_id,
  250. mms.mock_major_subject_id,
  251. cb.business_name,
  252. cpt.project_name
  253. FROM
  254. mock_apply ma
  255. LEFT JOIN mock_major mm ON ma.apply_id = mm.apply_id
  256. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  257. LEFT JOIN course_business cb ON ma.business_id = cb.id
  258. LEFT JOIN course_project_type cpt ON ma.project_id = cpt.id
  259. WHERE
  260. unix_timestamp(now()) &lt; ma.apply_end_time
  261. AND ma.mock_remind = 0
  262. </select>
  263. <select id="mockLiving" parameterType="java.lang.Long" resultMap="CourseSectionResultVo">
  264. SELECT
  265. cs.*
  266. FROM
  267. user_mock_subscribe ums
  268. LEFT JOIN mock_major_subject mms ON ums.mock_major_subject_id = mms.mock_major_subject_id
  269. LEFT JOIN course_section cs ON mms.section_id = cs.section_id
  270. WHERE
  271. ums.user_id = #{userId}
  272. and unix_timestamp(now()) &gt; cs.live_start_time
  273. and unix_timestamp(now()) &lt; cs.live_end_time
  274. </select>
  275. <select id="listApplyName" parameterType="com.zhongzheng.modules.mock.bo.MockApplyQueryBo" resultMap="MockApplyVoResult">
  276. SELECT
  277. *
  278. FROM
  279. mock_apply
  280. WHERE 1=1
  281. <if test="startTime != null and startTime !=''">
  282. and apply_start_time &gt; #{startTime}
  283. </if>
  284. <if test="endTime != null and endTime !=''">
  285. and apply_end_time &lt; #{endTime}
  286. </if>
  287. </select>
  288. <select id="getMockMajorSubjectId" parameterType="com.zhongzheng.modules.mock.bo.MockTimeAddBo" resultType="java.lang.Long">
  289. SELECT
  290. mms.mock_major_subject_id
  291. FROM mock_major mm
  292. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  293. WHERE mm.apply_id = #{applyId} AND mm.major_id = #{majorId} AND mms.subject_id = #{subjectId}
  294. </select>
  295. </mapper>