CourseScheduleMapper.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.yonge.cooleshow.biz.dal.dao.CourseScheduleDao">
  4. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.CourseSchedule">
  5. <id column="id_" jdbcType="INTEGER" property="id"/>
  6. <result column="course_group_id_" jdbcType="INTEGER" property="courseGroupId"/>
  7. <result column="type_" jdbcType="VARCHAR" property="type"/>
  8. <result column="status_" jdbcType="VARCHAR" property="status"/>
  9. <result column="class_num_" jdbcType="INTEGER" property="classNum"/>
  10. <result column="teacher_id_" jdbcType="INTEGER" property="teacherId"/>
  11. <result column="class_date_" jdbcType="TIMESTAMP" property="classDate"/>
  12. <result column="start_time_" jdbcType="TIMESTAMP" property="startTime"/>
  13. <result column="end_time_" jdbcType="TIMESTAMP" property="endTime"/>
  14. <result column="lock_" jdbcType="INTEGER" property="lock"/>
  15. <result column="lock_time_" jdbcType="TIMESTAMP" property="lockTime"/>
  16. <result column="ex_student_num_" jdbcType="INTEGER" property="exStudentNum"/>
  17. <result column="created_by_" jdbcType="INTEGER" property="createdBy"/>
  18. <result column="created_time_" jdbcType="TIMESTAMP" property="createdTime"/>
  19. <result column="updated_by_" jdbcType="INTEGER" property="updatedBy"/>
  20. <result column="updated_time_" jdbcType="TIMESTAMP" property="updatedTime"/>
  21. </resultMap>
  22. <sql id="Base_Column_List">
  23. id_
  24. , course_group_id_, type_, status_,class_num_, teacher_id_, class_date_, start_time_, end_time_, lock_, lock_time_, ex_student_num_, created_by_, created_time_, updated_by_, updated_time_
  25. </sql>
  26. <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
  27. parameterType="com.yonge.cooleshow.biz.dal.entity.CourseSchedule">
  28. insert into course_schedule(course_group_id_, type_, status_,class_num_, teacher_id_, class_date_, start_time_,
  29. end_time_, lock_, lock_time_, ex_student_num_, created_by_, created_time_, updated_by_,
  30. updated_time_)
  31. values
  32. <foreach collection="entities" item="entity" separator=",">
  33. (#{entity.courseGroupId}, #{entity.type}, #{entity.status},#{entity.classNum}, #{entity.teacherId}, #{entity.classDate},
  34. #{entity.startTime}, #{entity.endTime}, #{entity.lock}, #{entity.lockTime},
  35. #{entity.exStudentNum}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy},
  36. #{entity.updatedTime})
  37. </foreach>
  38. </insert>
  39. <select id="queryTeacherTotal" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherTotalVo">
  40. select a.*,b.starGrade from (
  41. <!-- 统计查询已上课时数,未上课时数 -->
  42. select
  43. a.teacher_id_ as userId,
  44. sum(if(a.end_time_ &lt;= now(),1,0)) as expTime,
  45. sum(if(a.end_time_ &gt; now(),1,0)) as unExpTime
  46. from course_schedule a
  47. where a.lock_ = 0 and a.type_ = 'PRACTICE'
  48. group by a.teacher_id_
  49. ) a
  50. left join (
  51. <!-- 统计老师星级评分 -->
  52. select
  53. a.teacher_id_ as userId,
  54. avg (b.score_) as starGrade
  55. from course_schedule a
  56. join course_schedule_replied b on a.id_ = b.course_schedule_id_
  57. where a.lock_ = 0 and type_ = 'PRACTICE' and b.score_ is not null
  58. group by a.teacher_id_
  59. ) b on a.userId = b.userId
  60. </select>
  61. <select id="queryStudentTotal" resultType="com.yonge.cooleshow.biz.dal.vo.StudentTotalVo">
  62. select
  63. b.user_id_ as userId,
  64. sum(if(a.end_time_ &lt;= now(),1,0)) as finshHours,
  65. sum(if(a.end_time_ &gt; now(),1,0)) as unfinshHours
  66. from course_schedule a
  67. join course_schedule_student_payment b on a.id_ = b.course_id_
  68. where a.lock_ = 0 and a.type_ = 'PRACTICE'
  69. group by b.user_id_
  70. </select>
  71. <select id="queryStudentCourse" resultMap="BaseResultMap">
  72. select b.id_,
  73. b.course_group_id_,
  74. b.type_,
  75. b.class_num_,
  76. b.teacher_id_,
  77. b.class_date_,
  78. b.start_time_,
  79. b.end_time_,
  80. b.lock_,
  81. b.lock_time_,
  82. b.ex_student_num_,
  83. b.status_,
  84. b.created_by_,
  85. b.created_time_,
  86. b.updated_by_,
  87. b.updated_time_
  88. from course_schedule_student_payment as a
  89. left join course_schedule as b on a.course_id_ = b.id_
  90. <where>
  91. a.user_id_ = #{param.studentId}
  92. <if test="param.greaterDate != null">
  93. AND <![CDATA[ b.start_time_ > #{param.greaterDate} ]]>
  94. </if>
  95. <if test="param.startClassDate != null">
  96. AND <![CDATA[ b.class_date_ >= #{param.startClassDate} ]]>
  97. </if>
  98. <if test="param.endClassDate != null">
  99. AND <![CDATA[ b.class_date_ <= #{param.endClassDate} ]]>
  100. </if>
  101. <if test="param.classDate != null">
  102. AND b.class_date_ = #{param.classDate}
  103. </if>
  104. <if test="param.status != null">
  105. AND b.status_ = #{param.status}
  106. </if>
  107. <if test="param.statusList != null">
  108. AND b.status_ IN
  109. <foreach collection="param.statusList" item="item" open="(" separator="," close=")">
  110. #{item}
  111. </foreach>
  112. </if>
  113. </where>
  114. order by b.start_time_ desc
  115. </select>
  116. <select id="queryLiveTeacherCourse" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherLiveCourseInfoVo">
  117. select
  118. b.id_ as courseGroupId,
  119. b.name_ as courseGroupName,
  120. s.name_ as subjectName,
  121. a.start_time_ as startTime,
  122. a.end_time_ as endTime,
  123. a.status_ as `status`,
  124. b.pre_student_num_ as studentCount,
  125. b.background_pic_ as backgroundPic,
  126. b.im_group_id_ as imGroupId
  127. from course_schedule as a
  128. left join course_group as b on a.course_group_id_ = b.id_
  129. left join subject as s on b.subject_id_ = s.id_
  130. where b.teacher_id_ = #{param.teacherId}
  131. AND a.lock_ = 0
  132. AND a.type_ = #{param.type}
  133. <![CDATA[ AND a.class_date_ >= #{param.startDate} ]]>
  134. <![CDATA[ AND a.class_date_ <= #{param.endDate} ]]>
  135. <if test="param.status !=null and param.status !=''">
  136. AND a.status_ = #{param.status}
  137. </if>
  138. <if test="param.subjectId != null">
  139. AND b.subject_id_ = #{param.subjectId}
  140. </if>
  141. </select>
  142. <select id="queryTeacherPracticeCourse" resultType="com.yonge.cooleshow.biz.dal.vo.MyCourseVo">
  143. SELECT
  144. u.id_ AS userId,
  145. u.username_ AS userName,
  146. u.real_name_ AS realName,
  147. u.avatar_ AS avatar,
  148. cs.class_date_ AS classDate,
  149. cs.start_time_ AS startTime,
  150. cs.end_time_ AS endTime,
  151. cs.status_ AS `status`,
  152. g.subject_id_ AS subjectId,
  153. sb.name_ AS subjectName,
  154. p.course_id_ AS courseId,
  155. p.course_group_id_ AS courseGoupId
  156. FROM course_schedule_student_payment p
  157. LEFT JOIN sys_user u ON p.user_id_ =u.id_
  158. LEFT JOIN course_schedule cs ON p.course_id_=cs.id_
  159. LEFT JOIN course_group g ON p.course_group_id_ = g.id_
  160. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  161. WHERE p.course_id_ IN
  162. (SELECT s.id_ FROM course_schedule s WHERE s.type_='PRACTICE' AND s.teacher_id_=#{param.teacherId})
  163. <if test="param.status !=null and param.status !=''">
  164. AND cs.status_ = #{param.status}
  165. </if>
  166. <if test="param.subjectId !=null">
  167. AND g.subject_id_ = #{param.subjectId}
  168. </if>
  169. <if test="param.classDate !=null and param.classDate !=''">
  170. AND cs.class_date_ = #{param.classDate}
  171. </if>
  172. <if test="param.startDate !=null and param.startDate !=''">
  173. <![CDATA[ AND cs.class_date_ >= #{param.startDate} ]]>
  174. </if>
  175. <if test="param.endDate !=null and param.endDate !=''">
  176. <![CDATA[ AND cs.class_date_ <= #{param.endDate} ]]>
  177. </if>
  178. <if test="param.repliedIds !=null">
  179. AND p.user_id_ IN
  180. <foreach collection="param.repliedIds" item="repliedIds" open="(" close=")" separator=",">
  181. #{repliedIds}
  182. </foreach>
  183. </if>
  184. <if test="param.studentName !=null and param.studentName !=''">
  185. AND u.username_ LIKE CONCAT('%', #{param.studentName}, '%')
  186. </if>
  187. </select>
  188. <select id="countTeacherNoDecorateHomework" resultType="java.lang.Integer">
  189. select count(1)
  190. from course_schedule cs
  191. left join course_homework ch on ch.course_schedule_id_ = cs.id_
  192. <where>
  193. <!-- 没有布置作业记录 -->
  194. <if test="param.decorate != null">
  195. <if test="param.decorate.code == 0">
  196. and ch.id_ is null
  197. </if>
  198. <if test="param.decorate.code == 1">
  199. and ch.id_ is not null
  200. </if>
  201. </if>
  202. <if test="param.courseStatus != null">
  203. and cs.type_ = #{param.courseType}
  204. </if>
  205. <if test="param.courseType != null">
  206. and cs.status_ = #{param.courseStatus}
  207. </if>
  208. <if test="param.teacherId != null">
  209. and cs.teacher_id_ = #{param.teacherId}
  210. </if>
  211. <if test="param.courseScheduleId != null ">
  212. and cs.id_ = #{param.courseScheduleId}
  213. </if>
  214. </where>
  215. </select>
  216. <select id="queryCourseSchedule" resultType="java.lang.String"
  217. parameterType="com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch">
  218. SELECT s.class_date_
  219. FROM course_schedule_student_payment p
  220. LEFT JOIN course_schedule s ON p.course_id_ = s.id_
  221. WHERE s.teacher_id_=#{teacherId}
  222. <![CDATA[ AND s.class_date_ >= #{startDate} ]]>
  223. <![CDATA[ AND s.class_date_ <= #{endDate} ]]>
  224. </select>
  225. <select id="queryStudentPracticeCourse" resultType="com.yonge.cooleshow.biz.dal.vo.MyCourseVo">
  226. SELECT
  227. s.id_ AS courseId,
  228. s.course_group_id_ AS courseGoupId,
  229. s.class_date_ AS classDate,
  230. s.start_time_ AS startTime,
  231. s.end_time_ AS endTime,
  232. s.status_ AS `status`,
  233. s.teacher_id_ AS teacherId,
  234. u.id_ AS userId,
  235. u.username_ AS userName,
  236. u.real_name_ AS realName,
  237. u.avatar_ AS avatar,
  238. g.subject_id_ AS subjectId,
  239. b.name_ AS subjectName
  240. FROM course_schedule s
  241. LEFT JOIN sys_user u ON s.teacher_id_ = u.id_
  242. LEFT JOIN course_group g ON s.course_group_id_ = g.id_
  243. LEFT JOIN `subject` b ON g.subject_id_ = b.id_
  244. WHERE s.id_ IN
  245. (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{param.studentId} AND course_type_ = 'PRACTICE')
  246. <if test="param.status !=null and param.status !=''">
  247. AND s.status_ = #{param.status}
  248. </if>
  249. <if test="param.subjectId !=null">
  250. AND g.subject_id_ = #{param.subjectId}
  251. </if>
  252. <if test="param.classDate !=null and param.classDate !=''">
  253. AND s.class_date_ = #{param.classDate}
  254. </if>
  255. <if test="param.startDate !=null and param.startDate !=''">
  256. <![CDATA[ AND s.class_date_ >= #{param.startDate} ]]>
  257. </if>
  258. <if test="param.endDate !=null and param.endDate !=''">
  259. <![CDATA[ AND s.class_date_ <= #{param.endDate} ]]>
  260. </if>
  261. </select>
  262. <select id="queryCourseUser" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudent">
  263. SELECT
  264. cs.id_ AS courseId,
  265. cs.course_group_id_ AS courseGoupId,
  266. cs.class_date_ AS classDate,
  267. cs.start_time_ AS startTime,
  268. cs.end_time_ AS endTime,
  269. cs.status_ AS `status`,
  270. cs.type_ AS courseType,
  271. NULL AS userId,
  272. CONCAT(g.name_,'-第',cs.class_num_,'课') AS name,
  273. NULL AS realName,
  274. p.payCount AS payCount,
  275. g.background_pic_ AS cover,
  276. g.subject_id_ AS subjectId,
  277. sb.name_ AS subjectName
  278. FROM course_schedule cs
  279. LEFT JOIN course_group g ON cs.course_group_id_ = g.id_
  280. LEFT JOIN (SELECT course_id_ AS pid,count(*) AS payCount FROM course_schedule_student_payment GROUP BY course_id_ ) p ON cs.id_=p.pid
  281. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  282. WHERE cs.type_='LIVE'
  283. AND cs.teacher_id_=#{param.teacherId}
  284. AND cs.class_date_=#{param.classDate}
  285. AND cs.id_ IN(
  286. SELECT c.id_
  287. FROM course_schedule_student_payment p,course_schedule c
  288. WHERE p.course_id_=c.id_
  289. AND p.course_group_id_ = c.course_group_id_
  290. AND c.teacher_id_=#{param.teacherId}
  291. AND c.class_date_=#{param.classDate}
  292. AND c.type_='LIVE')
  293. UNION
  294. SELECT
  295. p.course_id_ AS courseId,
  296. p.course_group_id_ AS courseGoupId,
  297. cs.class_date_ AS classDate,
  298. cs.start_time_ AS startTime,
  299. cs.end_time_ AS endTime,
  300. cs.status_ AS `status`,
  301. cs.type_ AS courseType,
  302. u.id_ AS userId,
  303. u.username_ AS name,
  304. u.real_name_ AS realName,
  305. NULL AS payCount,
  306. u.avatar_ AS cover,
  307. g.subject_id_ AS subjectId,
  308. sb.name_ AS subjectName
  309. FROM course_schedule_student_payment p
  310. LEFT JOIN sys_user u ON p.user_id_ =u.id_
  311. LEFT JOIN course_schedule cs ON p.course_id_=cs.id_
  312. LEFT JOIN course_group g ON p.course_group_id_ = g.id_
  313. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  314. WHERE p.course_id_ IN (SELECT s.id_ FROM course_schedule s WHERE s.type_='PRACTICE' AND s.teacher_id_=#{param.teacherId})
  315. AND cs.class_date_=#{param.classDate}
  316. ORDER BY startTime
  317. </select>
  318. <select id="queryCourseScheduleStudent" resultType="java.lang.String"
  319. parameterType="com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch">
  320. SELECT class_date_ FROM course_schedule
  321. WHERE id_ IN (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{studentId} AND course_type_ = 'PRACTICE')
  322. <![CDATA[ AND class_date_ >= #{startDate} ]]>
  323. <![CDATA[ AND class_date_ <= #{endDate} ]]>
  324. </select>
  325. <select id="teacherList" resultType="com.yonge.cooleshow.biz.dal.vo.PracticeTeacherVo">
  326. SELECT
  327. t.user_id_ AS teacherId,
  328. u.username_ AS userName,
  329. u.real_name_ AS realName,
  330. u.avatar_ AS avatar,
  331. tt.star_grade_ AS starGrade,
  332. tt.exp_time_ AS expTime,
  333. t.graduate_school_ AS school,
  334. t.subject_ AS schoolSubject,
  335. (SELECT group_concat(p.subject_name_) FROM teacher_subject_price p WHERE find_in_set(t.user_id_,p.teacher_id_)) AS configSubject,
  336. sp.subjectId AS subjectId,
  337. sp.subjectName AS subjectName,
  338. sp.subjectPrice AS subjectPrice,
  339. sp.courseMinutes AS courseMinutes
  340. FROM teacher t
  341. LEFT JOIN sys_user u ON t.user_id_ = u.id_
  342. LEFT JOIN teacher_total tt ON t.user_id_=tt.user_id_
  343. LEFT JOIN (SELECT
  344. f.teacher_id_ AS teacherId,
  345. p.subject_id_ AS subjectId,
  346. p.subject_name_ AS subjectName,
  347. p.subject_price_ AS subjectPrice,
  348. p.course_minutes_ AS courseMinutes
  349. FROM teacher_free_time f
  350. LEFT JOIN teacher_subject_price p ON f.id_=p.teacher_free_time_id
  351. WHERE f.default_flag_=1
  352. AND p.subject_id_=#{param.subjectId}) sp ON t.user_id_=sp.teacherId
  353. WHERE t.user_id_ IN (SELECT teacher_id_ FROM teacher_free_time GROUP BY teacher_id_)
  354. <if test="param.subjectId !=null">
  355. AND sp.subjectId=#{param.subjectId}
  356. </if>
  357. <if test="param.search !=null and param.search !=''">
  358. AND u.username_ LIKE CONCAT('%', #{param.search}, '%')
  359. </if>
  360. <choose>
  361. <when test="param.sort !=null and param.sort !=''">
  362. ORDER BY ${param.sort}
  363. </when>
  364. </choose>
  365. </select>
  366. <select id="queryCourseTeacher" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudent"
  367. parameterType="com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch">
  368. SELECT
  369. s.id_ AS courseId,
  370. s.course_group_id_ AS courseGoupId,
  371. s.class_date_ AS classDate,
  372. s.start_time_ AS startTime,
  373. s.end_time_ AS endTime,
  374. s.type_ AS courseType,
  375. s.status_ AS `status`,
  376. u.id_ AS userId,
  377. u.username_ AS name,
  378. u.real_name_ AS realName,
  379. u.avatar_ AS cover,
  380. g.subject_id_ AS subjectId,
  381. b.name_ AS subjectName
  382. FROM course_schedule s
  383. LEFT JOIN sys_user u ON s.teacher_id_ = u.id_
  384. LEFT JOIN course_group g ON s.course_group_id_ = g.id_
  385. LEFT JOIN `subject` b ON g.subject_id_ = b.id_
  386. WHERE s.id_ IN
  387. (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{param.studentId} AND course_type_ = 'PRACTICE')
  388. AND s.class_date_ = #{param.classDate}
  389. UNION
  390. SELECT
  391. s.id_ AS courseId,
  392. s.course_group_id_ AS courseGoupId,
  393. s.class_date_ AS classDate,
  394. s.start_time_ AS startTime,
  395. s.end_time_ AS endTime,
  396. s.type_ AS courseType,
  397. s.status_ AS `status`,
  398. NULL AS userId,
  399. CONCAT(g.name_,'-第',s.class_num_,'课') AS name,
  400. NULL AS realName,
  401. g.background_pic_ AS cover,
  402. g.subject_id_ AS subjectId,
  403. sb.name_ AS subjectName
  404. FROM course_schedule s
  405. LEFT JOIN course_group g ON s.course_group_id_ = g.id_
  406. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  407. WHERE s.id_ IN
  408. (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{param.studentId} AND course_type_ = 'LIVE')
  409. AND s.class_date_ = #{param.classDate}
  410. ORDER BY startTime
  411. </select>
  412. <select id="queryStudentLiveCourse" parameterType="map" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudent">
  413. SELECT distinct
  414. cs.id_ AS courseId,
  415. cs.course_group_id_ AS courseGoupId,
  416. cs.class_date_ AS classDate,
  417. cs.start_time_ AS startTime,
  418. cs.end_time_ AS endTime,
  419. cs.status_ AS `status`,
  420. cs.type_ AS courseType,
  421. su.username_ AS userId,
  422. CONCAT(g.name_,'-第',cs.class_num_,'课') AS name,
  423. IFNULL(g.pre_student_num_, 0) AS payCount,
  424. g.background_pic_ AS cover,
  425. g.subject_id_ AS subjectId,
  426. sb.name_ AS subjectName,
  427. su.avatar_ AS avatar,
  428. g.im_group_id_ as imGroupId
  429. FROM
  430. course_schedule_student_payment as a
  431. LEFT JOIN course_schedule cs on a.course_id_ = cs.id_
  432. LEFT JOIN course_group g ON cs.course_group_id_ = g.id_
  433. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  434. LEFT JOIN sys_user su on g.teacher_id_ = su.id_
  435. LEFT JOIN user_order o on a.order_no_ = o.order_no_
  436. WHERE cs.type_=#{param.type}
  437. AND a.user_id_ = #{param.studentId}
  438. <![CDATA[ AND class_date_ >= #{param.startDate} ]]>
  439. <![CDATA[ AND class_date_ <= #{param.endDate} ]]>
  440. <if test="param.orderState != null">
  441. AND o.status_ = #{param.orderState}
  442. </if>
  443. <if test="param.subjectId != null">
  444. AND g.subject_id_ = #{param.subjectId}
  445. </if>
  446. <if test="param.courseState != null">
  447. and cs.status_ = #{param.courseState}
  448. </if>
  449. </select>
  450. <insert id="addCourseGroup" parameterType="com.yonge.cooleshow.biz.dal.dto.PracticeScheduleDto" useGeneratedKeys="true" keyProperty="groupId">
  451. Insert INTO course_group(teacher_id_,type_,name_,subject_id_,single_course_minutes_,course_num_,course_introduce_,
  452. course_price_,status_,created_by_,mix_student_num_,course_start_time_,pre_student_num_)
  453. VALUES (#{teacherId},#{type},#{courseGroupName},#{subjectId},#{singleCourseMinutes},#{courseNum},#{courseIntroduce},
  454. #{coursePrice},#{status},#{studentId},#{mixStudentNum},#{courseStartTime},1)
  455. </insert>
  456. <update id="updateLock" parameterType="java.util.List">
  457. UPDATE course_schedule SET lock_ = 0 WHERE id_ IN
  458. <foreach collection="list" item="item" open="(" separator="," close=")">
  459. #{item}
  460. </foreach>
  461. </update>
  462. <update id="courseAdjust" parameterType="com.yonge.cooleshow.biz.dal.vo.CourseAdjustVo">
  463. UPDATE course_schedule
  464. SET class_date_=#{classDate},start_time_=#{startTime},end_time_=#{endTime}
  465. WHERE id_ = #{courseId}
  466. </update>
  467. <select id="selectLive" resultType="com.yonge.cooleshow.biz.dal.vo.StudentHomePage$Live">
  468. SELECT
  469. u.id_ AS teacherId,
  470. u.username_ AS teacherName,
  471. u.real_name_ AS realName,
  472. u.avatar_ AS avatar,
  473. g.id_ AS courseGroupId,
  474. g.name_ AS courseGroupName,
  475. g.course_price_ AS courseGroupPrice,
  476. g.course_start_time_ AS courseStartTime,
  477. g.background_pic_ AS backgroundPic,
  478. g.course_num_ AS courseNum,
  479. g.pre_student_num_ AS buyCount,
  480. g.subject_id_ AS subjectId,
  481. s.name_ AS subjectName
  482. FROM course_group g
  483. LEFT JOIN sys_user u ON g.teacher_id_=u.id_
  484. LEFT JOIN subject s ON g.subject_id_=s.id_
  485. WHERE type_='LIVE' and g.status_ = 'APPLY' and #{appAuditVersion} = g.audit_version_
  486. ORDER BY courseStartTime DESC LIMIT 4
  487. </select>
  488. <select id="selectVideo" resultType="com.yonge.cooleshow.biz.dal.vo.StudentHomePage$Video">
  489. SELECT
  490. u.id_ AS teacherId,
  491. u.username_ AS teacherName,
  492. u.real_name_ AS realName,
  493. u.avatar_ AS avatar,
  494. g.id_ AS videoGroupId,
  495. g.lesson_name_ AS videoGroupName,
  496. g.lesson_price_ AS lessonPrice,
  497. g.create_time_ AS createTime,
  498. g.lesson_cover_url_ AS lessonCoverUrl,
  499. g.lesson_count_ AS lessonCount,
  500. g.lesson_subject_ AS subjectId,
  501. s.name_ AS subjectName,
  502. IFNULL(r.count_,0) AS buyCount
  503. FROM video_lesson_group g
  504. LEFT JOIN sys_user u ON g.teacher_id_=u.id_
  505. LEFT JOIN `subject` s ON g.lesson_subject_=s.id_
  506. LEFT JOIN (SELECT video_lesson_group_id_ ,COUNT(1) AS count_ FROM video_lesson_purchase_record WHERE order_status_='PAID' GROUP BY video_lesson_group_id_) r ON g.id_= r.video_lesson_group_id_
  507. WHERE g.audit_status_='PASS' and #{appAuditVersion} = g.audit_version_
  508. ORDER BY g.create_time_ DESC LIMIT 4
  509. </select>
  510. <select id="selectRecentCourses" resultType="com.yonge.cooleshow.biz.dal.vo.StudentHomePage$RecentCourses">
  511. SELECT
  512. u.id_ AS teacherId,
  513. u.username_ AS teacherName,
  514. u.real_name_ AS realName,
  515. u.avatar_ AS avatar,
  516. p.course_group_id_ AS courseGroupId,
  517. p.course_id_ AS courseId,
  518. g.name_ AS courseGroupName,
  519. p.course_type_ AS courseType,
  520. s.status_ AS `status`,
  521. s.start_time_ AS courseStartTime
  522. FROM course_schedule_student_payment p
  523. LEFT JOIN course_schedule s ON p.course_id_=s.id_
  524. LEFT JOIN sys_user u ON s.teacher_id_=u.id_
  525. LEFT JOIN course_group g ON p.course_group_id_=g.id_
  526. WHERE p.user_id_=#{studentId}
  527. AND s.status_ IN ('NOT_START','ING')
  528. ORDER BY ABS(NOW() - s.start_time_) ASC
  529. limit 1
  530. </select>
  531. <select id="selectRecentCoursesTeacher" resultType="com.yonge.cooleshow.biz.dal.vo.StudentHomePage$RecentCourses">
  532. SELECT
  533. u.id_ AS teacherId,
  534. u.username_ AS teacherName,
  535. u.real_name_ AS realName,
  536. u.avatar_ AS avatar,
  537. s.course_group_id_ AS courseGroupId,
  538. s.id_ AS courseId,
  539. g.name_ AS courseGroupName,
  540. s.type_ AS courseType,
  541. s.status_ AS `status`,
  542. s.start_time_ AS courseStartTime
  543. FROM course_schedule s
  544. LEFT JOIN sys_user u ON s.teacher_id_=u.id_
  545. LEFT JOIN course_group g ON s.course_group_id_=g.id_
  546. WHERE s.teacher_id_=#{teacherId}
  547. AND s.status_ = 'NOT_START'
  548. ORDER BY ABS(NOW() - s.start_time_) ASC
  549. limit 1
  550. </select>
  551. <select id="selectWeekNotStartCourseSchedule" resultType="java.lang.Integer">
  552. select count(1)
  553. from course_schedule cs
  554. where cs.teacher_id_ = #{userId} and cs.status_ = 'NOT_START'
  555. and YEARWEEK(date_format(cs.class_date_,'%Y-%m-%d'),7) = YEARWEEK(now(),7)
  556. </select>
  557. <select id="selectHomeworkNotDecorate" resultType="java.lang.Integer">
  558. select count(1)
  559. from course_schedule cs
  560. left join course_homework ch on cs.id_ = ch.course_schedule_id_
  561. where cs.teacher_id_ = #{userId} and cs.status_ = 'COMPLETE' and cs.type_ = 'PRACTICE'
  562. and YEARWEEK(date_format(cs.class_date_,'%Y-%m-%d'),7) = YEARWEEK(now(),7)
  563. and ch.id_ is null
  564. </select>
  565. <select id="selectNotRepliedCourseSchedule" resultType="java.lang.Integer">
  566. select count(1)
  567. from course_schedule cs
  568. left join course_schedule_replied csr on cs.id_ = csr.course_schedule_id_
  569. where cs.teacher_id_ = #{userId} and cs.status_ = 'COMPLETE' and cs.type_ = 'PRACTICE'
  570. and csr.teacher_replied_ is null
  571. </select>
  572. <select id="selectWeekStudentRepliedCourseSchedule" resultType="java.lang.Integer">
  573. select count(1)
  574. from course_schedule cs
  575. left join course_schedule_replied csr on cs.id_ = csr.course_schedule_id_
  576. where cs.teacher_id_ = #{userId} and cs.status_ = 'COMPLETE' and cs.type_ = 'PRACTICE'
  577. and csr.student_replied_ is not null
  578. </select>
  579. <select id="selectStartTime" resultType="java.lang.String" parameterType="java.lang.String">
  580. SELECT s.start_time_
  581. FROM course_schedule_student_payment p
  582. LEFT JOIN course_schedule s ON p.course_id_=s.id_
  583. WHERE p.order_no_=#{orderNo}
  584. </select>
  585. <select id="selectTeacher" resultType="com.yonge.cooleshow.auth.api.entity.SysUser"
  586. parameterType="java.lang.String">
  587. SELECT s.teacher_id_ AS id,u.phone_ AS phone
  588. FROM course_schedule s
  589. LEFT JOIN sys_user u ON s.teacher_id_=u.id_
  590. WHERE class_date_=#{tomorrow} AND lock_=0
  591. GROUP BY s.teacher_id_
  592. </select>
  593. <select id="selectTypeCount" resultType="com.yonge.cooleshow.biz.dal.vo.CountVo">
  594. SELECT type_ AS type, COUNT(1) AS count
  595. FROM course_schedule
  596. WHERE class_date_=#{tomorrow}
  597. AND teacher_id_=#{teacherId} AND lock_=0
  598. GROUP BY type_
  599. </select>
  600. <select id="selectTodayNotRepliedAndNotDecorateHomework"
  601. resultType="com.yonge.cooleshow.biz.dal.vo.TodayNotRepliedAndNotDecorateHomeworkVo">
  602. select sum(if(ch.id_ is null,1,0)) as decorateNum,
  603. sum(if(csr.teacher_replied_ is null,1,0)) as repliedNum,
  604. su.id_ as teacherId,
  605. su.phone_ as phone
  606. from course_schedule cs
  607. left join course_schedule_replied csr on cs.id_ = csr.course_schedule_id_
  608. left join course_homework ch on cs.id_ = ch.course_schedule_id_
  609. left join sys_user su on cs.teacher_id_ = su.id_
  610. where cs.status_ = 'COMPLETE' and date_format(cs.class_date_,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
  611. and cs.type_ = 'PRACTICE'
  612. group by su.id_,su.phone_
  613. </select>
  614. <select id="countAllReplie" resultType="com.yonge.cooleshow.biz.dal.vo.RepliedCountVo"
  615. parameterType="java.lang.String">
  616. SELECT
  617. p.user_id_ AS userId,
  618. u.phone_ AS phone,
  619. COUNT(1) AS count
  620. FROM course_schedule_student_payment p
  621. LEFT JOIN sys_user u ON p.user_id_=u.id_
  622. WHERE p.course_id_ IN (SELECT id_ FROM course_schedule WHERE class_date_=#{today} AND lock_=0 AND type_='PRACTICE')
  623. GROUP BY p.user_id_;
  624. </select>
  625. <select id="countReplies" resultType="java.lang.Integer" parameterType="java.lang.Integer">
  626. SELECT COUNT(1)
  627. FROM course_schedule_replied
  628. WHERE student_id_=#{studentId}
  629. </select>
  630. </mapper>