MockApplyMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. <select id="getMockSubjectInfo" parameterType="java.lang.Long" resultMap="MockApplyVoResult">
  57. SELECT ma.*,
  58. mm.mock_major_id,
  59. major_id,
  60. mms.mock_major_subject_id,
  61. mms.subject_id,
  62. mms.site_time,
  63. mms.exam_id,
  64. mms.section_id
  65. FROM mock_apply ma
  66. LEFT JOIN mock_major mm ON ma.apply_id = mm.apply_id
  67. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  68. WHERE
  69. mms.mock_major_subject_id = #{mockMajorSubjectId}
  70. </select>
  71. <select id="listApply" parameterType="com.zhongzheng.modules.mock.bo.MockApplyQueryBo" resultMap="MockApplyVoResult">
  72. SELECT ma.*,
  73. cet.education_name,
  74. cb.business_name,
  75. cpt.project_name
  76. FROM mock_apply ma
  77. LEFT JOIN course_education_type cet ON ma.education_type_id = cet.id
  78. LEFT JOIN course_business cb ON ma.business_id = cb.id
  79. LEFT JOIN course_project_type cpt ON ma.project_id = cpt.id
  80. WHERE
  81. 1=1
  82. <if test="status != null and status.size()!=0 ">
  83. AND ma.status in
  84. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  85. #{item}
  86. </foreach>
  87. </if>
  88. ORDER BY ma.create_time desc
  89. </select>
  90. <select id="queryApplyList" parameterType="com.zhongzheng.modules.mock.bo.MockApplyQueryBo" resultMap="MockApplyVoResult">
  91. SELECT ma.apply_id,
  92. ma.business_id,
  93. cb.business_name,
  94. ma.apply_name,
  95. ma.project_id,
  96. cpt.project_name,
  97. mm.major_id,
  98. m.category_name,
  99. mms.subject_id,
  100. cs.subject_name,
  101. mms.exam_id,
  102. mms.section_id,
  103. mmst.exam_time,
  104. mmst.start_time,
  105. mmst.end_time,
  106. mms.mock_major_subject_id,
  107. ma.apply_start_time,
  108. ma.apply_end_time,
  109. mmst.id each_exam_id
  110. FROM mock_apply ma
  111. LEFT JOIN course_business cb ON ma.business_id = cb.id
  112. LEFT JOIN course_project_type cpt ON ma.project_id = cpt.id
  113. LEFT JOIN mock_major mm ON ma.apply_id = mm.apply_id
  114. LEFT JOIN major m ON mm.major_id = m.id
  115. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  116. LEFT JOIN course_subject cs ON mms.subject_id = cs.id
  117. LEFT JOIN mock_major_subject_time mmst ON mms.mock_major_subject_id = mmst.mock_major_subject_id
  118. WHERE
  119. UNIX_TIMESTAMP(NOW()) &lt; mmst.exam_time
  120. <if test="timeLimitMillisecond != null">
  121. + #{timeLimitMillisecond}
  122. </if>
  123. and ma.`status` = 1
  124. <if test="projectId != null and projectId != ''">
  125. and ma.project_id = #{projectId}
  126. </if>
  127. <if test="majorId != null and majorId != ''">
  128. and mm.major_id = #{majorId}
  129. </if>
  130. <if test="subjectId != null and subjectId != ''">
  131. and mms.subject_id = #{subjectId}
  132. </if>
  133. <if test="businessId != null and businessId != ''">
  134. and ma.business_id = #{businessId}
  135. </if>
  136. <if test="startTime != null and startTime != ''">
  137. and mmst.exam_time &gt; #{startTime}
  138. </if>
  139. <if test="endTime != null and endTime != ''">
  140. and mmst.exam_time &lt; #{endTime}
  141. </if>
  142. ORDER BY mmst.exam_time
  143. </select>
  144. <select id="listApplyBusiness" resultType="com.zhongzheng.modules.mock.vo.MockApplyVo">
  145. SELECT a.business_id,a.business_name,a.project_id,a.project_name,a.education_type_id,a.education_name
  146. FROM
  147. (SELECT DISTINCT
  148. ma.business_id,
  149. cb.business_name,
  150. ma.project_id,
  151. cpt.project_name,
  152. ma.education_type_id,
  153. cet.education_name
  154. FROM mock_apply ma
  155. LEFT JOIN course_project_type cpt ON ma.project_id = cpt.id
  156. LEFT JOIN course_business cb ON ma.business_id = cb.id
  157. LEFT JOIN mock_major mm ON ma.apply_id = mm.apply_id
  158. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  159. LEFT JOIN mock_major_subject_time mmst ON mms.mock_major_subject_id = mmst.id
  160. LEFT JOIN course_education_type cet ON ma.education_type_id = cet.id
  161. WHERE 1=1
  162. <if test="startTime != null and startTime != ''">
  163. and mmst.exam_time &gt; #{startTime}
  164. </if>
  165. <if test="endTime != null and endTime != ''">
  166. and mmst.exam_time &lt; #{endTime}
  167. </if>
  168. UNION ALL
  169. SELECT DISTINCT
  170. g.business_id,
  171. cb.business_name,
  172. g.project_id,
  173. cpt.project_name,
  174. g.education_type_id,
  175. cet.education_name
  176. FROM `order` o
  177. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  178. LEFT JOIN goods g ON og.goods_id = g.goods_id
  179. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  180. LEFT JOIN course_business cb ON g.business_id = cb.id
  181. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  182. WHERE 1=1
  183. <if test="userId != null and userId != ''">
  184. and o.user_id = #{userId}
  185. </if>
  186. ) a
  187. GROUP BY a.business_id,a.business_name,a.project_id,a.project_name,a.education_type_id,a.education_name
  188. HAVING COUNT(a.project_id)=2
  189. </select>
  190. <select id="listMockLive" parameterType="com.zhongzheng.modules.mock.bo.MockApplyQueryBo" resultMap="MockApplyVoResult">
  191. SELECT
  192. ma.*,
  193. cb.business_name,
  194. cpt.project_name,
  195. cs.section_type,
  196. cs.live_url,
  197. cs.live_start_time,
  198. cs.live_end_time,
  199. cs.recording_url,
  200. cs.cover_url
  201. FROM
  202. mock_apply ma
  203. LEFT JOIN mock_major mm ON ma.apply_id = mm.apply_id
  204. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  205. LEFT JOIN course_business cb ON ma.business_id = cb.id
  206. LEFT JOIN course_project_type cpt ON ma.project_id = cpt.id
  207. LEFT JOIN course_section cs ON mms.section_id = cs.section_id
  208. WHERE 1=1
  209. <if test="startTime != null and startTime != ''">
  210. AND cs.live_start_time &gt; #{startTime}
  211. </if>
  212. <if test="endTime != null and endTime != ''">
  213. AND cs.live_end_time &lt; #{endTime}
  214. </if>
  215. <if test="applyName != null and applyName != ''">
  216. AND ma.apply_name = #{applyName}
  217. </if>
  218. </select>
  219. <select id="listSubjects" resultMap="MockApplyVoResult">
  220. SELECT
  221. ma.*,
  222. mms.subject_id
  223. FROM
  224. mock_apply ma
  225. LEFT JOIN mock_major mm ON ma.apply_id = mm.apply_id
  226. LEFT JOIN mock_major_subject mms ON mm.mock_major_id = mms.mock_major_id
  227. WHERE
  228. unix_timestamp(now()) &lt; ma.apply_end_time
  229. AND unix_timestamp(now()) &gt; ma.apply_start_time
  230. AND ma.mock_remind = 0
  231. </select>
  232. <select id="mockLiving" parameterType="java.lang.Long" resultType="java.lang.String">
  233. SELECT
  234. cs.live_url
  235. FROM
  236. user_mock_subscribe ums
  237. LEFT JOIN mock_major_subject mms ON ums.mock_major_subject_id = mms.mock_major_subject_id
  238. LEFT JOIN course_section cs ON mms.section_id = cs.section_id
  239. WHERE
  240. ums.user_id = #{userId}
  241. and unix_timestamp(now()) &gt; cs.live_start_time
  242. and unix_timestamp(now()) &lt; cs.live_end_time
  243. </select>
  244. </mapper>