<?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.gradeclass.GroupStudentMapper">
    <!--分组学生列表-->
    <select id="findAll" resultType="com.xhkjedu.suser.vo.gradeclass.GroupStudentVo">
        select gs.gsid,gs.groupid,tu.studentno,tu.username studentname,tu.usersex,gs.studentid,tu.headpic
        from t_group_student gs left join t_user tu on gs.studentid = tu.userid
        where gs.groupid=#{groupid}
        order by convert(tu.username using gbk)
    </select>
    <!--删除分组学生-->
    <delete id="deleteByGroupId">
        delete from t_group_student where groupid=#{groupid}
    </delete>
    <!--添加-->
    <insert id="save">
        insert ignore into t_group_student (classid,groupid,studentid,createid,createtime,schoolid)
        values (#{student.classid},#{student.groupid},#{student.studentid},#{student.createid},#{student.createtime},#{student.schoolid})
    </insert>

    <!--批量保存班级分组学生-->
    <insert id="saveBatchGroupStudent">
        insert ignore into t_group_student (classid,groupid,studentid,createid,createtime,schoolid)
        values
        <foreach collection="list" item="student" index="index" separator=",">
            (#{student.classid},#{student.groupid},#{student.studentid},#{student.createid},#{student.createtime},#{student.schoolid})
        </foreach>
    </insert>

</mapper>
