<?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.ClassStudentMapper">
    <!--删除班级、分组对应学生-->
    <delete id="deleteById">
        delete cs.*,gs.*
        from t_class_student cs left join t_group g on g.classid=cs.classid
        left join t_group_student gs on g.groupid = gs.groupid AND gs.studentid=cs.studentid
        where cs.classid=#{classid} and cs.studentid=#{studentid}
    </delete>
    <!--获取班级学生id-->
    <select id="getByClassIdStudentId" resultType="java.lang.Integer">
        select csid from t_class_student where classid=#{classid} and studentid=#{studentid} limit 1
    </select>
    <!--添加-->
    <insert id="save">
        insert ignore into t_class_student (classid,studentid,createid,createtime,schoolid)
        values (#{student.classid},#{student.studentid},#{student.createid},#{student.createtime},#{student.schoolid})
    </insert>
    <!--保存班级学生到指定班级-->
    <insert id="saveAllClassStu">
        insert ignore into t_class_student (classid,studentid,createid,createtime,schoolid)
        SELECT #{zbclassid},studentid,#{student.createid}, UNIX_TIMESTAMP(),#{student.schoolid} FROM t_class_student WHERE classid=#{student.classid};
    </insert>
    <!--班级学生列表-->
    <select id="listByClassIds" resultType="com.xhkjedu.slive.vo.gradeclass.CStudentVo">
        select classid,studentid from t_class_student where classid in(${classids})
    </select>
</mapper>
