<?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.sstudy.mapper.gradeclass.ClassMapper">
    <!--班级学生-学生所在行政班-->
    <select id="getClassBySchoolid" resultType="java.util.Map">
        select cs.studentid,c.gradeid,c.classname from t_class_student cs left join t_class c on cs.classid=c.classid
        left join t_school s on c.schoolid=s.schoolid
        where c.schoolid=#{schoolid} and c.year=#{year} and c.classtype=1 and c.classstate=1
    </select>
    <!--班级学生-学生列表-->
    <select id="listStu" resultType="com.xhkjedu.sstudy.vo.paper.AStudentPaperVo">
        select cs.studentid,u.username studentname,u.loginname,c.gradeid,c.classname
        from t_class_student cs left join t_class c on cs.classid=c.classid
        left join t_user u on cs.studentid=u.userid
        where c.schoolid=#{paper.schoolid} and c.gradeid=#{paper.gradeid} and c.year=#{paper.year}
        and u.userstate=1
        <if test="paper.classid==0 and (paper.classids==null or paper.classids=='')">
            and c.classtype=1
        </if>
        <if test="paper.classid!=0">
            and cs.classid=#{paper.classid}
        </if>
        <if test="paper.classids!=null and paper.classids!=''">
            and cs.classid in (${paper.classids})
        </if>
        group by cs.studentid
    </select>

    <!--班级教师-获取教师任教行政和提高班id-->
    <select id="getClassIds" resultType="java.lang.String">
        select group_concat(distinct c.classid)
        from t_class_teacher ct left join  t_class c on ct.classid=c.classid
        left join t_school s on ct.schoolid=s.schoolid
        where ct.teacherid=#{teacherid} and c.year=s.year and c.classstate=1
        and c.classtype in(1,2)
    </select>

    <!--班级分组-分组以及分组下所有学生id-->
    <select id="listStudentidsByGroupids" resultType="java.lang.Integer">
        SELECT DISTINCT studentid FROM t_group_student  WHERE groupid IN (${groupids})
    </select>
    <!--获取班级基本信息列表-->
    <select id="listByClassIds" resultType="java.util.Map">
        select classid,classname,gradeid from t_class
        where classid in
        <foreach collection="classids" item="classid" index="index" open="(" separator="," close=")">
            ${classid}
        </foreach>
    </select>
</mapper>
