CourseScheduleMapper.xml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. </where>
  108. order by b.start_time_ desc
  109. </select>
  110. <select id="queryLiveTeacherCourse" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherLiveCourseInfoVo">
  111. select
  112. b.id_ as courseGroupId,
  113. b.name_ as courseGroupName,
  114. s.name_ as subjectName,
  115. a.start_time_ as startTime,
  116. a.end_time_ as endTime,
  117. a.status_ as `status`,
  118. b.pre_student_num_ as studentCount,
  119. b.background_pic_ as backgroundPic
  120. from course_schedule as a
  121. left join course_group as b on a.course_group_id_ = b.id_
  122. left join subject as s on b.subject_id_ = s.id_
  123. where b.teacher_id_ = #{param.teacherId}
  124. and a.lock_ = 0
  125. and a.status_ = #{param.status}
  126. and a.type_ = #{param.type}
  127. <![CDATA[ AND a.class_date_ >= #{param.startDate} ]]>
  128. <![CDATA[ AND a.class_date_ <= #{param.endDate} ]]>
  129. <if test="param.subjectId != null">
  130. AND b.subject_id_ = #{param.subjectId}
  131. </if>
  132. </select>
  133. <select id="queryTeacherPracticeCourse" resultType="com.yonge.cooleshow.biz.dal.vo.MyCourseVo">
  134. SELECT
  135. u.id_ AS userId,
  136. u.username_ AS userName,
  137. u.avatar_ AS avatar,
  138. cs.class_date_ AS classDate,
  139. cs.start_time_ AS startTime,
  140. cs.end_time_ AS endTime,
  141. cs.status_ AS `status`,
  142. g.subject_id_ AS subjectId,
  143. sb.name_ AS subjectName,
  144. p.course_id_ AS courseId,
  145. p.course_group_id_ AS courseGoupId
  146. FROM course_schedule_student_payment p
  147. LEFT JOIN sys_user u ON p.user_id_ =u.id_
  148. LEFT JOIN course_schedule cs ON p.course_id_=cs.id_
  149. LEFT JOIN course_group g ON p.course_group_id_ = g.id_
  150. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  151. WHERE p.course_id_ IN
  152. (SELECT s.id_ FROM course_schedule s WHERE s.type_='PRACTICE' AND s.teacher_id_=#{param.teacherId})
  153. <if test="param.status !=null and param.status !=''">
  154. AND cs.status_ = #{param.status}
  155. </if>
  156. <if test="param.subjectId !=null">
  157. AND g.subject_id_ = #{param.subjectId}
  158. </if>
  159. <if test="param.classDate !=null and param.classDate !=''">
  160. AND cs.class_date_ = #{param.classDate}
  161. </if>
  162. <if test="param.repliedIds !=null">
  163. AND p.user_id_ IN
  164. <foreach collection="param.repliedIds" item="repliedIds" open="(" close=")" separator=",">
  165. #{repliedIds}
  166. </foreach>
  167. </if>
  168. <if test="param.studentName !=null and param.studentName !=''">
  169. AND u.username_ LIKE CONCAT('%', #{param.studentName}, '%')
  170. </if>
  171. </select>
  172. </mapper>