<?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.liveplay.CourseSectionChatroomMapper">
    <!--课节聊天记录-->
   <select id="listChatrooms" resultType="com.xhkjedu.slive.model.liveplay.LCourseSectionChatroom">
       select * from l_course_section_chatroom where sectionid=#{sectionid} order by chatrid asc
   </select>
    <!--获取课节在线人数和学生总数-->
    <resultMap id="sectionStuResult" type="java.util.Map">
        <collection property="students" javaType="java.util.List" ofType="java.util.Map"
                    select="listStu" column="{classid=classid,sectionid=sectionid}"></collection>
    </resultMap>
    <select id="getSectionStu" resultMap="sectionStuResult">
       select c.stunum,c.classid,cs.sectionid
       ,(select count(*)  from t_agoralicense where used=1 and userid=#{userid})onteacher
       from l_course_section cs left join l_course c on cs.courseid=c.courseid
       where cs.sectionid=#{sectionid}
   </select>
    <!--学生列表-->
    <select id="listStu" resultType="java.util.Map">
       select cs.onlined,u.username studentname,u.headpic
       from(select cs.studentid,ifnull(min(css.onlined),3)onlined
       from t_class_student cs left join l_course_section_student css on cs.studentid=css.studentid and css.sectionid=#{sectionid}
       where cs.classid=#{classid}
       group by cs.studentid)cs left join t_user u on cs.studentid=u.userid
       order by cs.onlined
    </select>
</mapper>
