<?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.ym.mec.biz.dal.dao.ClassGroupDao">
    <resultMap type="com.ym.mec.biz.dal.entity.ClassGroup" id="ClassGroup">
        <result column="id_" property="id"/>
        <result column="music_group_id_" property="musicGroupId"/>
        <result column="subject_id_list_" property="subjectIdList"/>
        <result column="subject_name_" property="subjectName"/>
        <result column="name_" property="name"/>
        <result column="student_num_" property="studentNum"/>
        <result column="create_time_" property="createTime"/>
        <result column="update_time_" property="updateTime"/>
        <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="del_flag_" property="delFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="expect_student_num_" property="expectStudentNum"/>
        <result column="total_class_times_" property="totalClassTimes"/>
        <result column="img_" property="img"/>
        <!--<association property="musicGroupId" javaType="com.ym.mec.biz.dal.entity.MusicGroup" >-->
        <!--<result column="name_" property="name"/>-->
        <!--<result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>-->
        <!--</association>-->
    </resultMap>

    <resultMap type="com.ym.mec.biz.dal.entity.ClassGroup4Teacher" id="ClassGroup4Teacher">
        <result column="id_" property="id"/>
        <result column="music_group_id_" property="musicGroupId"/>
        <result column="subject_id_list_" property="subjectIdList"/>
        <result column="subject_name" property="subjectName"/>
        <result column="name_" property="name"/>
        <result column="student_num_" property="studentNum"/>
        <result column="create_time_" property="createTime"/>
        <result column="update_time_" property="updateTime"/>
        <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="name_" property="musicGroupName"/>
        <result column="status" property="musicGroupStatus" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
    </resultMap>

    <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ClassGroup" useGeneratedKeys="true" keyColumn="id"
            keyProperty="id">
        INSERT INTO class_group
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id!=null">id_,</if>
            <if test="musicGroupId!=null">music_group_id_,</if>
            <if test="subjectIdList!=null">subject_id_list_,</if>
            <if test="name!=null">name_,</if>
            <if test="studentNum!=null">student_num_,</if>
            <if test="createTime!=null">create_time_,</if>
            <if test="updateTime!=null">update_time_,</if>
            <if test="type!=null">type_,</if>
            <if test="expectStudentNum!=null">expect_student_num_,</if>
            <if test="totalClassTimes!=null">total_class_times_,</if>
            <if test="currentClassTimes!=null">current_class_times_,</if>
            <if test="img!=null">img_,</if>
        </trim>
        VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id!=null">#{id},</if>
            <if test="musicGroupId!=null">#{musicGroupId},</if>
            <if test="subjectIdList!=null">#{subjectIdList},</if>
            <if test="name!=null">#{name},</if>
            <if test="studentNum!=null">#{studentNum},</if>
            <if test="createTime!=null">#{createTime},</if>
            <if test="updateTime!=null">#{updateTime},</if>
            <if test="type!=null">#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},</if>
            <if test="expectStudentNum!=null">#{expectStudentNum},</if>
            <if test="totalClassTimes!=null">#{totalClassTimes},</if>
            <if test="currentClassTimes!=null">#{currentClassTimes},</if>
            <if test="img!=null">#{img},</if>
        </trim>
    </insert>

    <!-- 根据主键查询一条记录 -->
    <select id="get" resultMap="ClassGroup">
        SELECT * FROM class_group WHERE id_ = #{id}
    </select>

    <!-- 全查询 -->
    <select id="findAll" resultMap="ClassGroup">
        SELECT *
        FROM class_group
        ORDER BY id_
    </select>

    <!-- 根据主键查询一条记录 -->
    <update id="update" parameterType="com.ym.mec.biz.dal.entity.ClassGroup">
        UPDATE class_group
        <set>
            <if test="subjectIdList != null">
                subject_id_list_ = #{subjectIdList},
            </if>
            <if test="studentNum != null">
                student_num_ = #{studentNum},
            </if>
            <if test="updateTime != null">
                update_time_ = #{updateTime},
            </if>
            <if test="musicGroupId != null">
                music_group_id_ = #{musicGroupId},
            </if>
            <if test="type != null">
                type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
            </if>
            <if test="name != null">
                name_ = #{name},
            </if>
            <if test="expectStudentNum != null">
                expect_student_num_ = #{expectStudentNum},
            </if>
            <if test="totalClassTimes != null">
                total_class_times_ = #{totalClassTimes},
            </if>
            <if test="currentClassTimes!=null">
                current_class_times_=#{currentClassTimes},
            </if>
            <if test="img!=null">
                img_=#{img},
            </if>
        </set>
        WHERE id_ = #{id}
    </update>

    <!-- 根据主键删除一条记录 -->
    <delete id="delete">
        UPDATE class_group SET del_flag_ = 1 WHERE id_ = #{id}
    </delete>

    <!-- 分页查询 -->
    <select id="queryPage" resultMap="ClassGroup" parameterType="map">
        SELECT * FROM class_group where del_flag_ = 0 ORDER BY id_
        <include refid="global.limit"/>
    </select>

    <!-- 查询当前表的总记录数 -->
    <select id="queryCount" resultType="int">
        SELECT COUNT(*) FROM class_group where del_flag_ = 0
    </select>

    <!-- 查询根据主教助教查询班级信息 -->
    <select id="findClassGroup4Teacher" resultMap="ClassGroup4Teacher">
        SELECT c.*,m.* FROM
        class_group c, music_group m
        WHERE
        (c.main_teacher_id_ = #{teacherId} OR c.assistant_teacher_id_ = #{teacherId})
        AND c.del_flag_ = 0
    </select>
    <select id="findAllMixClassGroup" resultMap="ClassGroup">
        SELECT * FROM
        class_group cg
        WHERE cg.type_="MIX" AND cg.music_group_id_=#{musicGroupId} AND del_flag_='0'
    </select>
    <select id="findMixClassChildClassGroup" resultMap="ClassGroup">
        SELECT * FROM class_group WHERE id_ IN
        (SELECT sub_class_group_id_ FROM class_group_relation
        WHERE class_group_id_ = #{mixClassGroupId}) AND del_flag_ = 0
    </select>

    <!-- 根据乐团id获取单技班信息 -->
    <select id="findAllNormalClassGroupByMusicGroupId" resultMap="ClassGroup">
        SELECT
        cg.*, (SELECT group_concat(sb.name_) FROM subject sb WHERE FIND_IN_SET(sb.id_,cg.subject_id_list_)) AS
        subject_name_
        FROM
        class_group cg
        WHERE cg.music_group_id_=#{musicGroupId} AND cg.type_='NORMAL' AND cg.del_flag_='0'
    </select>

    <!-- 查询合奏班包含子班名字信息 -->
    <select id="findMixClassChildClassGroupNames" resultMap="ClassGroup">
        SELECT
        group_concat(cg.name_) as name_
        FROM
        class_group_relation cgr
        LEFT JOIN class_group cg ON cgr.sub_class_group_id_=cg.id_
        WHERE cgr.class_group_id_=#{classGroupId} AND del_flag_='0'
    </select>

    <!-- 根据ids查询班级列表 -->
    <select id="findClassGroupByIds" resultMap="ClassGroup">
        SELECT * FROM class_group WHERE FIND_IN_SET(id_,#{ids}) AND del_flag_ = 0
    </select>

    <resultMap type="com.ym.mec.biz.dal.dto.TeacherMusicClassInfoDto" id="getTeaCourseInfosMap">
        <result column="music_group_id_" property="musicGroupId"/>
        <result column="music_group_name_" property="musicGroupName"/>
        <result column="educational_teacher_id_" property="educationalTeacherId"/>
        <result column="team_teacher_id_" property="teamTeacherId"/>
        <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="job_type_" property="jobType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="job_nature_" property="jobNature" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <collection property="classGroupNames" ofType="string">
            <result column="class_group_name_"/>
        </collection>
    </resultMap>
    <select id="queryGroupCourses" resultMap="getTeaCourseInfosMap">
        SELECT mg.id_ music_group_id_,mg.name_ music_group_name_,
        mg.team_teacher_id_,mg.educational_teacher_id_,cg.name_ class_group_name_,mg.status_,t.job_type_,t.job_nature_
        FROM class_group_teacher_mapper cgtm
        LEFT JOIN music_group mg ON cgtm.music_group_id_ = mg.id_
        LEFT JOIN class_group cg ON cg.id_ = cgtm.class_group_id_
		LEFT JOIN teacher t ON t.id_ = cgtm.user_id_
        WHERE cgtm.user_id_ = #{userId} AND cg.del_flag_ = 0 AND (cg.type_ = 'NORMAL' OR cg.type_ = 'MIX')
    </select>


    <resultMap type="com.ym.mec.biz.dal.dto.TeacherVipClassInfoDto" id="getTeacherVipClassMap">
        <result column="price_" property="vipClassFee"/>
        <result column="vip_group_id_" property="vipClassId"/>
        <result column="student_num_" property="studentNum"/>
        <result column="courses_expire_date_" property="coursesExpireDate"/>
        <result column="payment_expire_date_" property="paymentExpireDate"/>
        <result column="create_time_" property="createDate"/>
        <result column="current_class_times_" property="currentClassTimes"/>
        <result column="total_class_times_" property="totalClassTimes"/>
        <result column="vip_group_name_" property="vipClassName"/>
        <result column="audit_status_" property="auditStatus"
                typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
    </resultMap>
    <select id="getTeacherVipClass" resultMap="getTeacherVipClassMap">
        SELECT vg.id_ vip_group_id_,vg.name_ vip_group_name_,vg.audit_status_,cs.status_,
        cg.student_num_,vg.price_,vg.payment_expire_date_,vg.courses_expire_date_,vg.create_time_,
        cs.current_class_times_,cg.total_class_times_
        FROM vip_group vg
        LEFT JOIN sys_user su ON vg.user_id_ = su.id_
        LEFT JOIN vip_group_class_group_mapper vgcgm ON vg.id_ = vgcgm.vip_group_id_
        LEFT JOIN class_group cg ON vgcgm.class_group_id_ = cg.id_
        LEFT JOIN course_schedule cs ON cg.id_ = cs.class_group_id_
        WHERE vg.user_id_ = #{teacherId}
        <include refid="global.limit"/>
    </select>
    <select id="countTeacherVipClass" resultType="java.lang.Integer">
        SELECT COUNT(vg.id_) FROM vip_group vg
        WHERE vg.user_id_ = #{teacherId}
    </select>


    <resultMap type="com.ym.mec.biz.dal.dto.ClassGroupTeachersDto" id="ClassGroupTeachers">
        <result column="id_" property="id"/>
        <result column="music_group_id_" property="musicGroupId"/>
        <result column="subject_id_list_" property="subjectIdList"/>
        <result column="name_" property="name"/>
        <result column="student_num_" property="studentNum"/>
        <result column="create_time_" property="createTime"/>
        <result column="update_time_" property="updateTime"/>
        <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="del_flag_" property="delFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="expect_student_num_" property="expectStudentNum"/>
        <result column="total_class_times_" property="totalClassTimes"/>
    </resultMap>
    <!-- 根据乐团id获取乐团下所有班级 -->
    <select id="findClassGroupByMusicGroupId" resultMap="ClassGroupTeachers">
        SELECT * FROM class_group WHERE music_group_id_ = #{musicGroupId}
        <if test="type !=null and type !=''">
        AND FIND_IN_SET(type_,#{type})
        </if>
        AND del_flag_ = 0
    </select>

    <resultMap type="com.ym.mec.biz.dal.dto.CourseListDto" id="CourseListDto">
        <result column="music_group_name_" property="musicGroupName"/>
        <result column="music_group_id_" property="musicGroupId"/>
        <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="total_class_times_" property="totalClassTimes"/>
        <result column="teach_mode_" property="teachMode"/>
        <result column="current_class_times_" property="currentClassTimes"/>
        <result column="address_" property="address"/>
        <result column="single_class_minutes_" property="singleClassMinutes"/>
    </resultMap>
    <select id="queryCoursePage" resultMap="CourseListDto">
        SELECT * FROM (
        SELECT cg.type_,s.address_,mg.name_ music_group_name_,
        cg.total_class_times_,cg.current_class_times_,'' single_class_minutes_,mg.id_
        music_group_id_,cg.create_time_,cs.teach_mode_
        FROM student_registration sr
        LEFT JOIN class_group cg ON cg.id_ = sr.class_group_id_
        LEFT JOIN course_schedule cs ON cs.class_group_id_ = cg.id_
        LEFT JOIN music_group mg ON cg.music_group_id_ = mg.id_
        LEFT JOIN school s ON mg.school_id_ = s.id_
        WHERE sr.user_id_ = #{search} AND cg.type_ != 'VIP'
        UNION ALL
        SELECT cg.type_,ts.address_,vg.name_ music_group_name_,
        cg.total_class_times_,cg.current_class_times_,vg.single_class_minutes_,vg.id_
        music_group_id_,cg.create_time_,cs.teach_mode_
        FROM class_group_student_mapper cgsm
        LEFT JOIN class_group cg ON cgsm.class_group_id_ = cg.id_
        LEFT JOIN course_schedule cs ON cs.class_group_id_ = cg.id_
        LEFT JOIN vip_group_class_group_mapper vgcgm ON vgcgm.class_group_id_ = cgsm.class_group_id_
        LEFT JOIN vip_group vg ON vg.id_ = vgcgm.vip_group_id_
        LEFT JOIN teacher_school ts ON vg.teacher_school_id_ = ts.id_
        WHERE cgsm.user_id_ = #{search} AND cg.type_ = 'VIP') a
        ORDER BY a.create_time_ DESC
        <include refid="global.limit"/>
    </select>

    <resultMap id="imGroupModel" type="com.ym.mec.common.entity.ImGroupModel">
        <result column="id_" property="id"/>
        <result column="name_" property="name"/>
        <result column="student_num_" property="count"/>
        <result column="img_" property="img"/>
    </resultMap>
    <select id="queryUserGroups" resultMap="imGroupModel">
        SELECT cg.id_,cg.name_,cg.student_num_,cg.img_ FROM class_group_student_mapper cgsm
        LEFT JOIN class_group cg ON cgsm.class_group_id_ = cg.id_
        <where>
            cg.del_flag_ = 0
            <if test="userId != null">
                AND cgsm.user_id_ = #{userId}
            </if>
            <if test="search != null and search != ''">
                AND cg.name_ LIKE CONCAT('%',#{search},'%')
            </if>
        </where>
    </select>
    <select id="findVipStuNames" resultType="java.lang.String">
        SELECT su.username_ FROM vip_group_class_group_mapper vgcgm
        LEFT JOIN class_group_student_mapper cgsm ON vgcgm.class_group_id_ = cgsm.class_group_id_
        LEFT JOIN sys_user su ON cgsm.user_id_ = su.id_
        WHERE vgcgm.vip_group_id_ = #{musicGroupId}
    </select>
    <select id="findGroupUsers" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.ImUserModel">
        SELECT su.id_,su.avatar_,su.username_ FROM class_group_student_mapper cgsm
        LEFT JOIN sys_user su ON cgsm.user_id_ = su.id_
        WHERE cgsm.class_group_id_ = #{musicGroupId} GROUP BY su.id_
    </select>
    <select id="countStudentPayLog" resultType="java.lang.Integer">
        SELECT COUNT(spo.id_)
        FROM student_payment_order spo
        LEFT JOIN class_group cg ON cg.id_ = spo.class_group_id_
        <where>
            <if test="search != null and search != ''">
                AND cg.name_ LIKE CONCAT('%',#{search},'%')
            </if>
            <if test="date != null and date != ''">
                AND spo.create_time_ LIKE CONCAT(#{date},'%')
            </if>
            <if test="userId != null">
                AND spo.user_id_ = #{userId}
            </if>
            <if test="type != null">
                AND spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
            </if>
        </where>
    </select>
    <resultMap id="StudentPayInfoDto" type="com.ym.mec.biz.dal.dto.StudentPayInfoDto">
        <result column="actual_amount_" property="actualAmount"/>
        <result column="name_" property="name"/>
        <result column="create_time_" property="createTime"/>
        <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
    </resultMap>
    <select id="queryStudentPayLog" resultMap="StudentPayInfoDto">
        SELECT spo.actual_amount_,spo.status_,spo.type_,cg.name_,spo.create_time_
        FROM student_payment_order spo
        LEFT JOIN class_group cg ON cg.id_ = spo.class_group_id_
        <where>
            <if test="search != null and search != ''">
                AND cg.name_ LIKE CONCAT('%',#{search},'%')
            </if>
            <if test="date != null and date != ''">
                AND spo.create_time_ LIKE CONCAT(#{date},'%')
            </if>
            <if test="userId != null">
                AND spo.user_id_ = #{userId}
            </if>
            <if test="type != null">
                AND spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
            </if>
        </where>
        <include refid="global.limit"/>
    </select>
    <select id="countCoursePage" resultType="java.lang.Integer">
        SELECT COUNT(id_) FROM (
        SELECT cg.type_,s.address_,mg.name_ music_group_name_,
        cg.total_class_times_,cg.current_class_times_,'' single_class_minutes_,mg.id_
        music_group_id_,cg.create_time_,cg.id_
        FROM student_registration sr
        LEFT JOIN class_group cg ON cg.id_ = sr.class_group_id_
        LEFT JOIN music_group mg ON cg.music_group_id_ = mg.id_
        LEFT JOIN school s ON mg.school_id_ = s.id_
        WHERE sr.user_id_ = #{search} AND cg.type_ != 'VIP'
        UNION ALL
        SELECT cg.type_,ts.address_,vg.name_ music_group_name_,
        cg.total_class_times_,cg.current_class_times_,vg.single_class_minutes_,vg.id_
        music_group_id_,cg.create_time_,cg.id_
        FROM class_group_student_mapper cgsm
        LEFT JOIN class_group cg ON cgsm.class_group_id_ = cg.id_
        LEFT JOIN vip_group_class_group_mapper vgcgm ON vgcgm.class_group_id_ = cgsm.class_group_id_
        LEFT JOIN vip_group vg ON vg.id_ = vgcgm.vip_group_id_
        LEFT JOIN teacher_school ts ON vg.teacher_school_id_ = ts.id_
        WHERE cgsm.user_id_ = #{search} AND cg.type_ = 'VIP') a
    </select>

    <select id="countClassStudent" resultType="int">
        select count(*) from class_group_student_mapper where class_group_id_=#{classGroupId}
    </select>

    <select id="findAllClassGroupByMusicGroup" resultMap="ClassGroup">
        SELECT * FROM class_group cg
        WHERE cg.music_group_id_=#{musicGroupId} AND del_flag_='0'
    </select>

    <select id="queryTeacherIds" resultType="java.lang.Integer">
        SELECT DISTINCT cgtm.user_id_ FROM class_group_teacher_mapper cgtm WHERE cgtm.class_group_id_ = #{id}
    </select>

    <select id="queryTeacherGroups" resultMap="imGroupModel">
        SELECT cg.id_,cg.name_,cg.student_num_,cg.img_ FROM class_group_teacher_mapper cgtm
        LEFT JOIN class_group cg ON cgtm.class_group_id_ = cg.id_
        WHERE cgtm.user_id_ = #{userId} AND cg.del_flag_ = 0
        <if test="search != null">
            AND cg.name_ LIKE CONCAT('%',#{search},'%')
        </if>
    </select>
    <select id="findNoClassSubjects" resultMap="ClassGroup">
        SELECT * FROM class_group cg
        WHERE cg.id_ NOT IN
        (SELECT cgr.sub_class_group_id_ FROM class_group_relation cgr
        LEFT JOIN class_group cg ON cg.id_ = cgr.class_group_id_
        WHERE cg.music_group_id_ = #{musicGroupId})
        AND cg.music_group_id_ = #{musicGroupId} AND type_ = 'NORMAL' AND cg.del_flag_ = 0
    </select>

    <select id="countTeacherNum" resultType="java.lang.Integer">
        SELECT COUNT(DISTINCT cgtm.user_id_) FROM class_group_teacher_mapper cgtm
        WHERE cgtm.class_group_id_ = #{classGroupId}
    </select>

    <select id="countTeacherNums" resultType="java.util.Map">
        SELECT COUNT(DISTINCT cgtm.user_id_) `value`,cgtm.class_group_id_ `key`
        FROM class_group_teacher_mapper cgtm
        WHERE FIND_IN_SET(cgtm.class_group_id_,#{classGroupIds}) GROUP BY cgtm.class_group_id_
    </select>
    <select id="findByVipGroup" resultMap="ClassGroup">
        SELECT
            cg.*
        FROM
            vip_group_class_group_mapper vcgm
            LEFT JOIN class_group cg ON vcgm.class_group_id_ = cg.id_
            WHERE vcgm.vip_group_id_=#{vipGroupId}
    </select>

    <select id="lockClassGroup" resultMap="ClassGroup">
        SELECT
            cg.*
        FROM
            class_group cg
            WHERE cg.id_=#{classGroupId} FOR UPDATE
    </select>
    <select id="countTeacherVipNum" resultType="java.util.Map">
        SELECT vg.user_id_ `key`,COUNT(vg.id_) `value` FROM vip_group vg
        WHERE FIND_IN_SET(vg.user_id_,#{teacherIds}) GROUP BY user_id_
    </select>

    <resultMap id="TeacherClassGroupDto" type="com.ym.mec.biz.dal.dto.TeacherClassGroupDto">
        <result property="classGroupId" column="class_group_id_"/>
        <result property="classGroupName" column="class_group_name_"/>
        <result property="studentNum" column="student_num_"/>
        <result property="currentClassTimes" column="current_class_times_"/>
        <result property="totalClassTimes" column="total_class_times_"/>
        <result property="musicGroupId" column="music_group_id_"/>
        <result property="musicGroupName" column="music_group_name_"/>
        <result property="schoolId" column="school_id_"/>
        <result property="schoolName" column="school_name_"/>
        <result property="subjectIdList" column="subject_id_list_"/>
    </resultMap>

    <select id="findTeacherMusicClassGroup" resultType="com.ym.mec.biz.dal.dto.TeacherClassGroupDto">
        SELECT
            cg.id_ class_group_id_,
            cg.name_ class_group_name_,
            cg.student_num_,
            cg.current_class_times_,
            cg.total_class_times_,
            cg.subject_id_list_,
            mg.id_ music_group_id_,
            mg.name_ music_group_name_,
            s.id_ school_id_,
            s.name_ school_name_
        FROM
            class_group_teacher_mapper cgtm
            LEFT JOIN class_group cg ON cgtm.class_group_id_=cg.id_
            LEFT JOIN music_group mg ON cg.music_group_id_=mg.id_
            LEFT JOIN school s ON mg.school_id_=s.id_
        WHERE cgtm.user_id_=#{teacherId} AND cg.type_!="VIP" AND cg.type_!="DEMO"
    </select>

    <!-- 增加实际学生人数 -->
    <update id="addStudentNum" parameterType="com.ym.mec.biz.dal.entity.ClassGroup">
        UPDATE class_group SET student_num_ = student_num_+1,update_time_=#{updateTime} WHERE id_ = #{id} AND
        student_num_=#{studentNum}
    </update>
</mapper>
