<?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.CourseSectionStudentMapper">
    <!--添加-->
    <insert id="save">
        insert ignore into l_course_section_student (courseid, sectionid, classid, studentid
        , tostamp, outstamp, createtime,totaltime,logip,logaddress,device,onlined)
        values (#{student.courseid}, #{student.sectionid}, #{student.classid}, #{student.studentid}, #{student.tostamp}
        , #{student.outstamp}, #{student.createtime},#{student.totaltime},#{student.logip},#{student.logaddress},#{student.device},#{student.onlined})
    </insert>
    <!--课节学生列表-->
    <select id="listBySectionId" resultType="com.xhkjedu.slive.vo.liveplay.CSStudentVo">
        select cs.studentid,u.username studentname,u.headpic
        from t_class_student cs left join t_user u on cs.studentid=u.userid
        left join l_course c on cs.classid=c.classid
        left join l_course_section s on c.courseid=s.courseid
        where s.sectionid=#{sectionid} group by cs.studentid order by cs.createtime asc
    </select>
    <!--更新最晚出课堂时间-->
    <update id="updateById">
        update l_course_section_student set outstamp=#{student.outstamp},onlined=2
        where sectionid=#{student.sectionid} and studentid=#{student.studentid} and device=#{student.device}
    </update>
    <!--修改学生上课时长-->
    <update id="updateTime">
        update l_course_section_student set totaltime=totaltime+#{student.totaltime}
        where sectionid=#{student.sectionid} and studentid=#{student.studentid} and device=#{student.device}
    </update>
    <!--学生进入课节记录-->
    <select id="getByStudent" resultType="com.xhkjedu.slive.model.liveplay.LCourseSectionStudent">
        select * from l_course_section_student
        where sectionid=#{student.sectionid} and studentid=#{student.studentid} and device=#{student.device}
    </select>
</mapper>
