123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457 |
- <?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.type_ = #{param.type}
- <![CDATA[ AND a.class_date_ >= #{param.startDate} ]]>
- <![CDATA[ AND a.class_date_ <= #{param.endDate} ]]>
- <if test="param.status !=null and param.status !=''">
- AND a.status_ = #{param.status}
- </if>
- <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.startDate !=null and param.startDate !=''">
- <![CDATA[ AND cs.class_date_ >= #{param.startDate} ]]>
- </if>
- <if test="param.endDate !=null and param.endDate !=''">
- <![CDATA[ AND cs.class_date_ <= #{param.endDate} ]]>
- </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>
- <select id="countTeacherNoDecorateHomework" resultType="java.lang.Integer">
- select count(1)
- from course_schedule cs
- left join course_homework ch on ch.course_schedule_id_ = cs.id_
- <where>
-
- <if test="param.decorate != null">
- <if test="param.decorate.code == 0">
- and ch.id_ is null
- </if>
- <if test="param.decorate.code == 1">
- and ch.id_ is not null
- </if>
- </if>
- <if test="param.courseStatus != null">
- and cs.type_ = #{param.courseType}
- </if>
- <if test="param.courseType != null">
- and cs.status_ = #{param.courseStatus}
- </if>
- <if test="param.teacherId != null">
- and cs.teacher_id_ = #{param.teacherId}
- </if>
- <if test="param.courseScheduleId != null ">
- and cs.id_ = #{param.courseScheduleId}
- </if>
- </where>
- </select>
- <select id="queryCourseSchedule" resultType="java.lang.String"
- parameterType="com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch">
- SELECT s.class_date_
- FROM course_schedule_student_payment p
- LEFT JOIN course_schedule s ON p.course_id_ = s.id_
- WHERE s.teacher_id_=#{teacherId}
- <![CDATA[ AND s.class_date_ >= #{startDate} ]]>
- <![CDATA[ AND s.class_date_ <= #{endDate} ]]>
- </select>
- <select id="queryStudentPracticeCourse" resultType="com.yonge.cooleshow.biz.dal.vo.MyCourseVo">
- SELECT
- s.id_ AS courseId,
- s.course_group_id_ AS courseGoupId,
- s.class_date_ AS classDate,
- s.start_time_ AS startTime,
- s.end_time_ AS endTime,
- s.status_ AS `status`,
- s.teacher_id_ AS teacherId,
- u.id_ AS userId,
- u.username_ AS userName,
- u.avatar_ AS avatar,
- g.subject_id_ AS subjectId,
- b.name_ AS subjectName
- FROM course_schedule s
- LEFT JOIN sys_user u ON s.teacher_id_ = u.id_
- LEFT JOIN course_group g ON s.course_group_id_ = g.id_
- LEFT JOIN `subject` b ON g.subject_id_ = b.id_
- WHERE s.id_ IN
- (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{param.studentId} AND course_type_ = 'PRACTICE')
- <if test="param.status !=null and param.status !=''">
- AND s.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 s.class_date_ = #{param.classDate}
- </if>
- <if test="param.startDate !=null and param.startDate !=''">
- <![CDATA[ AND s.class_date_ >= #{param.startDate} ]]>
- </if>
- <if test="param.endDate !=null and param.endDate !=''">
- <![CDATA[ AND s.class_date_ <= #{param.endDate} ]]>
- </if>
- </select>
- <select id="queryCourseUser" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudent">
- SELECT
- cs.id_ AS courseId,
- cs.course_group_id_ AS courseGoupId,
- cs.class_date_ AS classDate,
- cs.start_time_ AS startTime,
- cs.end_time_ AS endTime,
- cs.status_ AS `status`,
- cs.type_ AS courseType,
- NULL AS userId,
- CONCAT(g.name_,'-第',cs.class_num_,'课') AS name,
- p.payCount AS payCount,
- g.background_pic_ AS cover,
- g.subject_id_ AS subjectId,
- sb.name_ AS subjectName
- FROM course_schedule cs
- LEFT JOIN course_group g ON cs.course_group_id_ = g.id_
- 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
- LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
- WHERE cs.type_='LIVE'
- AND cs.teacher_id_=#{param.teacherId}
- AND cs.class_date_=#{param.classDate}
- AND cs.id_ IN(
- SELECT c.id_
- FROM course_schedule_student_payment p,course_schedule c
- WHERE p.course_id_=c.id_
- AND p.course_group_id_ = c.course_group_id_
- AND c.teacher_id_=#{param.teacherId}
- AND c.class_date_=#{param.classDate}
- AND c.type_='LIVE')
- UNION
- SELECT
- p.course_id_ AS courseId,
- p.course_group_id_ AS courseGoupId,
- cs.class_date_ AS classDate,
- cs.start_time_ AS startTime,
- cs.end_time_ AS endTime,
- cs.status_ AS `status`,
- cs.type_ AS courseType,
- u.id_ AS userId,
- u.username_ AS name,
- NULL AS payCount,
- u.avatar_ AS cover,
- g.subject_id_ AS subjectId,
- sb.name_ AS subjectName
- 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})
- AND cs.class_date_=#{param.classDate}
- ORDER BY startTime
- </select>
- <select id="queryCourseScheduleStudent" resultType="java.lang.String"
- parameterType="com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch">
- SELECT class_date_ FROM course_schedule
- WHERE id_ IN (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{studentId} AND course_type_ = 'PRACTICE')
- <![CDATA[ AND class_date_ >= #{startDate} ]]>
- <![CDATA[ AND class_date_ <= #{endDate} ]]>
- </select>
- <select id="teacherList" resultType="com.yonge.cooleshow.biz.dal.vo.PracticeTeacherVo">
- SELECT
- cs.teacher_id_ AS teacherId,
- u.username_ AS userName,
- u.avatar_ AS avatar,
- tt.star_grade_ AS starGrade,
- tt.exp_time_ AS expTime,
- t.graduate_school_ AS school,
- t.subject_ AS schoolSubject,
- (SELECT group_concat(p.subject_name_) FROM teacher_subject_price p WHERE find_in_set(cs.teacher_id_,p.teacher_id_)) AS configSubject,
- sp.subject_id_ AS subjectId,
- sp.subject_name_ AS subjectName,
- sp.subject_price_ AS subjectPrice,
- sp.course_minutes_ AS courseMinutes
- FROM course_schedule cs
- LEFT JOIN sys_user u ON cs.teacher_id_ = u.id_
- LEFT JOIN teacher_total tt ON cs.teacher_id_=tt.user_id_
- LEFT JOIN teacher t ON cs.teacher_id_=t.user_id_
- LEFT JOIN teacher_subject_price sp ON cs.teacher_id_=sp.teacher_id_
- WHERE cs.type_='PRACTICE'
- <if test="param.subjectId !=null">
- AND sp.subject_id_=#{param.subjectId}
- </if>
- <if test="param.search !=null and param.search !=''">
- AND u.username_ LIKE CONCAT('%', #{param.search}, '%')
- </if>
- <choose>
- <when test="param.sort !=null and param.sort !=''">
- ORDER BY ${param.sort}
- </when>
- </choose>
- </select>
- <select id="queryCourseTeacher" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudent"
- parameterType="com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch">
- SELECT
- s.id_ AS courseId,
- s.course_group_id_ AS courseGoupId,
- s.class_date_ AS classDate,
- s.start_time_ AS startTime,
- s.end_time_ AS endTime,
- s.type_ AS courseType,
- s.status_ AS `status`,
- u.id_ AS userId,
- u.username_ AS name,
- u.avatar_ AS cover,
- g.subject_id_ AS subjectId,
- b.name_ AS subjectName
- FROM course_schedule s
- LEFT JOIN sys_user u ON s.teacher_id_ = u.id_
- LEFT JOIN course_group g ON s.course_group_id_ = g.id_
- LEFT JOIN `subject` b ON g.subject_id_ = b.id_
- WHERE s.id_ IN
- (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{param.studentId} AND course_type_ = 'PRACTICE')
- AND s.class_date_ = #{param.classDate}
- UNION
- SELECT
- s.id_ AS courseId,
- s.course_group_id_ AS courseGoupId,
- s.class_date_ AS classDate,
- s.start_time_ AS startTime,
- s.end_time_ AS endTime,
- s.type_ AS courseType,
- s.status_ AS `status`,
- NULL AS userId,
- CONCAT(g.name_,'-第',s.class_num_,'课') AS name,
- g.background_pic_ AS cover,
- g.subject_id_ AS subjectId,
- sb.name_ AS subjectName
- FROM course_schedule s
- LEFT JOIN course_group g ON s.course_group_id_ = g.id_
- LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
- WHERE s.id_ IN
- (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{param.studentId} AND course_type_ = 'LIVE')
- AND s.class_date_ = #{param.classDate}
- ORDER BY startTime
- </select>
- <select id="queryStudentLiveCourse" parameterType="map" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudent">
- SELECT
- cs.id_ AS courseId,
- cs.course_group_id_ AS courseGoupId,
- cs.class_date_ AS classDate,
- cs.start_time_ AS startTime,
- cs.end_time_ AS endTime,
- cs.status_ AS `status`,
- cs.type_ AS courseType,
- su.real_name_ AS userId,
- CONCAT(g.name_,'-第',cs.class_num_,'课') AS name,
- IFNULL(g.pre_student_num_, 0) AS payCount,
- g.background_pic_ AS cover,
- g.subject_id_ AS subjectId,
- sb.name_ AS subjectName,
- su.avatar_ AS avatar
- FROM
- course_schedule_student_payment as a
- LEFT JOIN course_schedule cs on a.course_id_ = cs.id_
- LEFT JOIN course_group g ON cs.course_group_id_ = g.id_
- LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
- LEFT JOIN sys_user su on g.teacher_id_ = su.id_
- WHERE cs.type_=#{param.type}
- AND a.user_id_ = #{param.studentId}
- <![CDATA[ AND class_date_ >= #{param.startDate} ]]>
- <![CDATA[ AND class_date_ <= #{param.endDate} ]]>
- <if test="param.subjectId != null">
- AND g.subject_id_ = #{param.subjectId}
- </if>
- <if test="param.courseState != null">
- and cs.status_ = #{param.courseState}
- </if>
- </select>
- <insert id="addCourseGroup" parameterType="com.yonge.cooleshow.biz.dal.dto.PracticeScheduleDto" useGeneratedKeys="true" keyProperty="groupId">
- Insert INTO course_group(teacher_id_,type_,name_,subject_id_,single_course_minutes_,course_num_,course_introduce_,
- course_price_,status_,created_by_,mix_student_num_,course_start_time_,pre_student_num_)
- VALUES (#{teacherId},#{type},#{courseGroupName},#{subjectId},#{singleCourseMinutes},#{courseNum},#{courseIntroduce},
- #{coursePrice},#{status},#{studentId},#{mixStudentNum},#{courseStartTime},1)
- </insert>
- <update id="updateLock" parameterType="java.util.List">
- UPDATE course_schedule SET lock_ = 0 WHERE id_ IN
- <foreach collection="list" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </update>
- <update id="courseAdjust" parameterType="com.yonge.cooleshow.biz.dal.vo.CourseAdjustVo">
- UPDATE course_schedule
- SET class_date_=#{classDate},start_time_=#{startTime},end_time_=#{endTime}
- WHERE id_ = #{courseId}
- </update>
- </mapper>
|