MockApplyMapper.xml 11 KB

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