<?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.xhkjedu.suser.mapper.liveplay.CourseMapper">
    <!--更新已报学生数量-->
    <update id="updateStuNum">
        update l_course c set c.stunum=(select tc.classnum from t_class tc where tc.classid=c.classid)
        where c.courseid=#{courseid}
    </update>
    <!--行政班的所有直播课-->
    <select id="listXzCourse" resultType="java.util.Map">
        select c.courseid,c.classid,c.createid,c.schoolid,g.groupid
        from l_course c left join l_course_class cc on cc.courseid=c.courseid
        left join t_group g on c.classid=g.classid and g.grouptype=1
        where c.coursetype=1 and cc.classid=#{classid}
        group by c.courseid
    </select>
    <!--指定班级的直播课-->
    <select id="listXzCourse2" resultType="java.util.Map">
        select c.courseid,c.classid,c.createid,c.schoolid,g.groupid,cc.classid oldclassid
        from l_course c left join l_course_class cc on cc.courseid=c.courseid
        left join t_group g on c.classid=g.classid and g.grouptype=1
        where c.coursetype=1 and cc.classid in
        <foreach collection="classids" item="classid" index="index" open="(" separator="," close=")">
            ${classid}
        </foreach>
        group by c.courseid,cc.classid
    </select>

    <!--批量更改课程学生数量-->
    <update id="updateStuNumBatch">
        update l_course c set c.stunum=(select tc.classnum from t_class tc where tc.classid=c.classid)
        where c.courseid in (${courseids})
    </update>

    <!--某些班的直播课-->
    <select id="listCourse" resultType="java.util.Map">
        select c.courseid,c.classid,c.createid,c.schoolid,g.groupid
        from l_course c left join l_course_class cc on cc.courseid=c.courseid
        left join t_group g on c.classid=g.classid and g.grouptype=1
        where c.coursetype=1 and cc.classid in (${classids})
        group by c.courseid
    </select>
</mapper>
