| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.yonge.cooleshow.biz.dal.dao.CourseScheduleDao">
- <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.CourseSchedule">
- <id column="id_" jdbcType="INTEGER" property="id"/>
- <result column="course_group_id_" jdbcType="INTEGER" property="courseGroupId"/>
- <result column="type_" jdbcType="VARCHAR" property="type"/>
- <result column="status_" jdbcType="VARCHAR" property="status"/>
- <result column="class_num_" jdbcType="INTEGER" property="classNum"/>
- <result column="teacher_id_" jdbcType="INTEGER" property="teacherId"/>
- <result column="class_date_" jdbcType="TIMESTAMP" property="classDate"/>
- <result column="start_time_" jdbcType="TIMESTAMP" property="startTime"/>
- <result column="end_time_" jdbcType="TIMESTAMP" property="endTime"/>
- <result column="lock_" jdbcType="INTEGER" property="lock"/>
- <result column="lock_time_" jdbcType="TIMESTAMP" property="lockTime"/>
- <result column="ex_student_num_" jdbcType="INTEGER" property="exStudentNum"/>
- <result column="created_by_" jdbcType="INTEGER" property="createdBy"/>
- <result column="created_time_" jdbcType="TIMESTAMP" property="createdTime"/>
- <result column="updated_by_" jdbcType="INTEGER" property="updatedBy"/>
- <result column="updated_time_" jdbcType="TIMESTAMP" property="updatedTime"/>
- </resultMap>
- <sql id="Base_Column_List">
- id_
- , 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_
- </sql>
- <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
- parameterType="com.yonge.cooleshow.biz.dal.entity.CourseSchedule">
- insert into course_schedule(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_)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.courseGroupId}, #{entity.type}, #{entity.status},#{entity.classNum}, #{entity.teacherId}, #{entity.classDate},
- #{entity.startTime}, #{entity.endTime}, #{entity.lock}, #{entity.lockTime},
- #{entity.exStudentNum}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy},
- #{entity.updatedTime})
- </foreach>
- </insert>
- <select id="queryTeacherTotal" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherTotalVo">
- select a.*,b.starGrade from (
- <!-- 统计查询已上课时数,未上课时数 -->
- select
- a.teacher_id_ as userId,
- sum(if(a.end_time_ <= now(),1,0)) as expTime,
- sum(if(a.end_time_ > now(),1,0)) as unExpTime
- from course_schedule a
- where a.lock_ = 0 and a.type_ = 'PRACTICE'
- group by a.teacher_id_
- ) a
- left join (
- <!-- 统计老师星级评分 -->
- select
- a.teacher_id_ as userId,
- avg (b.score_) as starGrade
- from course_schedule a
- join course_schedule_replied b on a.id_ = b.course_schedule_id_
- where a.lock_ = 0 and type_ = 'PRACTICE' and b.score_ is not null
- group by a.teacher_id_
- ) b on a.userId = b.userId
- </select>
- <select id="queryStudentTotal" resultType="com.yonge.cooleshow.biz.dal.vo.StudentTotalVo">
- select
- b.user_id_ as userId,
- sum(if(a.end_time_ <= now(),1,0)) as finshHours,
- sum(if(a.end_time_ > now(),1,0)) as unfinshHours
- from course_schedule a
- join course_schedule_student_payment b on a.id_ = b.course_id_
- where a.lock_ = 0 and a.type_ = 'PRACTICE'
- group by b.user_id_
- </select>
- <select id="queryStudentCourse" resultMap="BaseResultMap">
- select b.id_,
- b.course_group_id_,
- b.type_,
- b.class_num_,
- b.teacher_id_,
- b.class_date_,
- b.start_time_,
- b.end_time_,
- b.lock_,
- b.lock_time_,
- b.ex_student_num_,
- b.status_,
- b.created_by_,
- b.created_time_,
- b.updated_by_,
- b.updated_time_
- from course_schedule_student_payment as a
- left join course_schedule as b on a.course_id_ = b.id_
- <where>
- a.user_id_ = #{param.studentId}
- <if test="param.greaterDate != null">
- AND <![CDATA[ b.start_time_ > #{param.greaterDate} ]]>
- </if>
- <if test="param.startClassDate != null">
- AND <![CDATA[ b.class_date_ >= #{param.startClassDate} ]]>
- </if>
- <if test="param.endClassDate != null">
- AND <![CDATA[ b.class_date_ <= #{param.endClassDate} ]]>
- </if>
- <if test="param.classDate != null">
- AND b.class_date_ = #{param.classDate}
- </if>
- <if test="param.status != null">
- AND b.status_ = #{param.status}
- </if>
- </where>
- order by b.start_time_ desc
- </select>
- <select id="queryLiveTeacherCourse" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherLiveCourseInfoVo">
- select
- b.id_ as courseGroupId,
- b.name_ as courseGroupName,
- s.name_ as subjectName,
- a.start_time_ as startTime,
- a.end_time_ as endTime,
- a.status_ as `status`,
- b.pre_student_num_ as studentCount,
- b.background_pic_ as backgroundPic
- from course_schedule as a
- left join course_group as b on a.course_group_id_ = b.id_
- left join subject as s on b.subject_id_ = s.id_
- where b.teacher_id_ = #{param.teacherId}
- and a.lock_ = 0
- and a.status_ = #{param.status}
- and a.type_ = #{param.type}
- <![CDATA[ AND a.class_date_ >= #{param.startDate} ]]>
- <![CDATA[ AND a.class_date_ <= #{param.endDate} ]]>
- <if test="param.subjectId != null">
- AND b.subject_id_ = #{param.subjectId}
- </if>
- </select>
- <select id="queryTeacherPracticeCourse" resultType="com.yonge.cooleshow.biz.dal.vo.MyCourseVo">
- SELECT
- u.id_ AS userId,
- u.username_ AS userName,
- u.avatar_ AS avatar,
- cs.class_date_ AS classDate,
- cs.start_time_ AS startTime,
- cs.end_time_ AS endTime,
- cs.status_ AS `status`,
- g.subject_id_ AS subjectId,
- sb.name_ AS subjectName,
- p.course_id_ AS courseId,
- p.course_group_id_ AS courseGoupId
- FROM course_schedule_student_payment p
- LEFT JOIN sys_user u ON p.user_id_ =u.id_
- LEFT JOIN course_schedule cs ON p.course_id_=cs.id_
- LEFT JOIN course_group g ON p.course_group_id_ = g.id_
- LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
- WHERE p.course_id_ IN
- (SELECT s.id_ FROM course_schedule s WHERE s.type_='PRACTICE' AND s.teacher_id_=#{param.teacherId})
- <if test="param.status !=null and param.status !=''">
- AND cs.status_ = #{param.status}
- </if>
- <if test="param.subjectId !=null">
- AND g.subject_id_ = #{param.subjectId}
- </if>
- <if test="param.classDate !=null and param.classDate !=''">
- AND cs.class_date_ = #{param.classDate}
- </if>
- <if test="param.repliedIds !=null">
- AND p.user_id_ IN
- <foreach collection="param.repliedIds" item="repliedIds" open="(" close=")" separator=",">
- #{repliedIds}
- </foreach>
- </if>
- <if test="param.studentName !=null and param.studentName !=''">
- AND u.username_ LIKE CONCAT('%', #{param.studentName}, '%')
- </if>
- </select>
- </mapper>
|