<?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.sapi.mapper.system.SchoolFriendMapper">
    <!--获取关联学校id-->
    <select id="listFSchoolidsBySchoolid" resultType="java.util.Map">
        select f.fschoolid as schoolid,s.schoolname from t_school_friend f
            left join t_school s on s.schoolid=f.fschoolid  where f.schoolid=#{schoolid} order by f.schoolid
    </select>

    <!--删除学校附属学校-->
    <delete id="deleteBySchoolid">
        delete from t_school_friend where schoolid=#{schoolid}
    </delete>

    <!--获取学校关联的所有行政班-->
    <select id="listSchoolClass" resultType="java.util.Map">
        select s.schoolid,s.schoolname,c.classid,c.classname,c.gradeid,c.classnum
        from t_school s left join t_class c on s.schoolid=c.schoolid and s.year=c.year
        where s.schoolid=#{schoolid} and c.classtype=1 and c.classstate=1 and c.classnum>0
        order by c.gradeid,c.classorder
    </select>

    <!--获取附属学校关联的所有行政班-->
    <select id="listFriendSchoolClass" resultType="java.util.Map">
        select s.schoolid,s.schoolname,c.classid,c.classname,c.gradeid,c.classnum
        from t_school s
        left join t_school_friend sf on s.schoolid=sf.fschoolid
        left join t_class c on s.schoolid=c.schoolid and s.year=c.year
        where sf.schoolid=#{schoolid} and s.schoolstate=1 and c.classtype=1 and c.classstate=1 and c.classnum>0
        order by s.schoolid, c.gradeid,c.classorder
    </select>
</mapper>
