MockApplyMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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 mock_major mj ON ma.apply_id = mj.apply_id
  105. LEFT JOIN course_education_type cet ON ma.education_type_id = cet.id
  106. LEFT JOIN course_business cb ON ma.business_id = cb.id
  107. LEFT JOIN course_project_type cpt ON ma.project_id = cpt.id
  108. WHERE
  109. 1=1
  110. <if test="status != null and status.size()!=0 ">
  111. AND ma.status in
  112. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  113. #{item}
  114. </foreach>
  115. </if>
  116. <if test="mockActivity != null and mockActivity != ''">
  117. and ma.mock_activity = #{mockActivity}
  118. </if>
  119. <if test="educationTypeId != null and educationTypeId != ''">
  120. and ma.education_type_id = #{educationTypeId}
  121. </if>
  122. <if test="businessId != null and businessId != ''">
  123. and ma.business_id = #{businessId}
  124. </if>
  125. <if test="majorId != null and majorId != ''">
  126. and mj.major_id = #{majorId}
  127. </if>
  128. <if test="searchKey != null and searchKey != ''">
  129. and (ma.apply_name LIKE CONCAT('%',#{searchKey},'%') OR ma.code LIKE CONCAT('%',#{searchKey},'%'))
  130. </if>
  131. ORDER BY ma.create_time desc
  132. </select>
  133. <select id="queryApplyList" parameterType="com.zhongzheng.modules.mock.bo.MockApplyQueryBo" resultMap="MockApplyVoResult">
  134. SELECT ma.apply_id,
  135. ma.business_id,
  136. cb.business_name,
  137. ma.apply_name,
  138. ma.project_id,
  139. cpt.project_name,
  140. mm.major_id,
  141. m.category_name,
  142. mms.subject_id,
  143. cs.subject_name,
  144. mms.exam_id,
  145. mms.section_id,
  146. mmst.exam_time,
  147. mmst.start_time,
  148. mmst.end_time,
  149. mms.mock_major_subject_id,
  150. ma.apply_start_time,
  151. ma.apply_end_time,
  152. mmst.id each_exam_id
  153. FROM mock_apply ma
  154. LEFT JOIN course_business cb ON ma.business_id = cb.id
  155. LEFT JOIN course_project_type cpt ON ma.project_id = cpt.id
  156. LEFT JOIN mock_major mm ON ma.apply_id = mm.apply_id
  157. LEFT JOIN major m ON mm.major_id = m.id
  158. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  159. LEFT JOIN course_subject cs ON mms.subject_id = cs.id
  160. LEFT JOIN mock_major_subject_time mmst ON mms.mock_major_subject_id = mmst.mock_major_subject_id
  161. WHERE
  162. UNIX_TIMESTAMP(NOW()) &lt; mmst.exam_time
  163. <if test="timeLimitMillisecond != null">
  164. + #{timeLimitMillisecond}
  165. </if>
  166. and ma.`status` = 1
  167. <if test="projectId != null and projectId != ''">
  168. and ma.project_id = #{projectId}
  169. </if>
  170. <if test="majorId != null and majorId != ''">
  171. and mm.major_id = #{majorId}
  172. </if>
  173. <if test="subjectId != null and subjectId != ''">
  174. and mms.subject_id = #{subjectId}
  175. </if>
  176. <if test="businessId != null and businessId != ''">
  177. and ma.business_id = #{businessId}
  178. </if>
  179. <if test="startTime != null and startTime != ''">
  180. and mmst.exam_time &gt; #{startTime}
  181. </if>
  182. <if test="endTime != null and endTime != ''">
  183. and mmst.exam_time &lt; #{endTime}
  184. </if>
  185. ORDER BY mmst.exam_time
  186. </select>
  187. <select id="listApplyBusiness" resultType="com.zhongzheng.modules.mock.vo.MockApplyVo">
  188. SELECT a.business_id,a.business_name,a.project_id,a.project_name,a.education_type_id,a.education_name
  189. FROM
  190. (SELECT DISTINCT
  191. ma.business_id,
  192. cb.business_name,
  193. ma.project_id,
  194. cpt.project_name,
  195. ma.education_type_id,
  196. cet.education_name
  197. FROM mock_apply ma
  198. LEFT JOIN course_project_type cpt ON ma.project_id = cpt.id
  199. LEFT JOIN course_business cb ON ma.business_id = cb.id
  200. LEFT JOIN mock_major mm ON ma.apply_id = mm.apply_id
  201. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  202. LEFT JOIN mock_major_subject_time mmst ON mms.mock_major_subject_id = mmst.id
  203. LEFT JOIN course_education_type cet ON ma.education_type_id = cet.id
  204. WHERE 1=1 and ma.mock_activity = 0
  205. <if test="startTime != null and startTime != ''">
  206. and mmst.exam_time &gt; #{startTime}
  207. </if>
  208. <if test="endTime != null and endTime != ''">
  209. and mmst.exam_time &lt; #{endTime}
  210. </if>
  211. UNION ALL
  212. SELECT DISTINCT
  213. g.business_id,
  214. cb.business_name,
  215. g.project_id,
  216. cpt.project_name,
  217. g.education_type_id,
  218. cet.education_name
  219. FROM `order` o
  220. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  221. LEFT JOIN goods g ON og.goods_id = g.goods_id
  222. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  223. LEFT JOIN course_business cb ON g.business_id = cb.id
  224. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  225. WHERE 1=1
  226. <if test="userId != null and userId != ''">
  227. and o.user_id = #{userId}
  228. </if>
  229. ) a
  230. GROUP BY a.business_id,a.business_name,a.project_id,a.project_name,a.education_type_id,a.education_name
  231. HAVING COUNT(a.project_id)=2
  232. </select>
  233. <select id="listMockLive" parameterType="com.zhongzheng.modules.mock.bo.MockApplyQueryBo" resultMap="MockApplyVoResult">
  234. SELECT
  235. ma.*,
  236. cb.business_name,
  237. cpt.project_name,
  238. cs.section_type,
  239. cs.live_url,
  240. cs.live_start_time,
  241. cs.live_end_time,
  242. cs.recording_url,
  243. cs.cover_url
  244. FROM
  245. mock_apply ma
  246. LEFT JOIN mock_major mm ON ma.apply_id = mm.apply_id
  247. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  248. LEFT JOIN course_business cb ON ma.business_id = cb.id
  249. LEFT JOIN course_project_type cpt ON ma.project_id = cpt.id
  250. LEFT JOIN course_section cs ON mms.section_id = cs.section_id
  251. WHERE 1=1
  252. <if test="startTime != null and startTime != ''">
  253. AND cs.live_start_time &gt; #{startTime}
  254. </if>
  255. <if test="endTime != null and endTime != ''">
  256. AND cs.live_end_time &lt; #{endTime}
  257. </if>
  258. <if test="applyName != null and applyName != ''">
  259. AND ma.apply_name = #{applyName}
  260. </if>
  261. </select>
  262. <select id="listSubjects" resultMap="MockApplyVoResult">
  263. SELECT
  264. ma.*,
  265. mms.subject_id,
  266. mms.mock_major_subject_id,
  267. cb.business_name,
  268. cpt.project_name
  269. FROM
  270. mock_apply ma
  271. LEFT JOIN mock_major mm ON ma.apply_id = mm.apply_id
  272. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  273. LEFT JOIN course_business cb ON ma.business_id = cb.id
  274. LEFT JOIN course_project_type cpt ON ma.project_id = cpt.id
  275. WHERE
  276. unix_timestamp(now()) &lt; ma.apply_end_time
  277. AND ma.mock_remind = 0
  278. </select>
  279. <select id="mockLiving" parameterType="java.lang.Long" resultMap="CourseSectionResultVo">
  280. SELECT
  281. cs.*
  282. FROM
  283. user_mock_subscribe ums
  284. LEFT JOIN mock_major_subject mms ON ums.mock_major_subject_id = mms.mock_major_subject_id
  285. LEFT JOIN course_section cs ON mms.section_id = cs.section_id
  286. WHERE
  287. ums.user_id = #{userId}
  288. and unix_timestamp(now()) &gt; cs.live_start_time
  289. and unix_timestamp(now()) &lt; cs.live_end_time
  290. </select>
  291. <select id="listApplyName" parameterType="com.zhongzheng.modules.mock.bo.MockApplyQueryBo" resultMap="MockApplyVoResult">
  292. SELECT
  293. *
  294. FROM
  295. mock_apply
  296. WHERE 1=1
  297. <if test="startTime != null and startTime !=''">
  298. and apply_start_time &gt; #{startTime}
  299. </if>
  300. <if test="endTime != null and endTime !=''">
  301. and apply_end_time &lt; #{endTime}
  302. </if>
  303. </select>
  304. <select id="getMockMajorSubjectId" parameterType="com.zhongzheng.modules.mock.bo.MockTimeAddBo" resultType="java.lang.Long">
  305. SELECT
  306. mms.mock_major_subject_id
  307. FROM mock_major mm
  308. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  309. WHERE mm.apply_id = #{applyId} AND mm.major_id = #{majorId} AND mms.subject_id = #{subjectId}
  310. </select>
  311. </mapper>