<?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.slive.mapper.gradeclass.GroupMapper">
    <!--更新分组人数-->
    <update id="updateNum">
        update t_group g set g.groupnum=
        (select count(*) from t_group_student gs where gs.groupid=#{groupid})
        where g.groupid=#{groupid}
    </update>

    <!--获取班级对应的全班学生分组-->
    <select id="getGroupIdByClassid" resultType="java.lang.Integer">
        select groupid from t_group where classid=#{classid} and grouptype=1
    </select>
    <!--保存全部分组学生-->
    <insert id="saveAllClassGroupStu">
        insert ignore into t_group_student (classid,groupid,studentid,createid,createtime,schoolid)
        SELECT #{zbclassid},#{zbgroupid},studentid,#{student.createid},#{student.createtime},#{student.schoolid} FROM t_class_student WHERE classid=#{student.classid};
    </insert>
</mapper>
