<?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.sclass.mapper.classroom.ClassroomProfileMapper">

  <!--获取课堂资料-->
  <select id="listProfileByRoomid" resultType="java.util.Map">
    select profileid,profilename,profileurl,profilesuffix
    from t_classroom_profile where roomid=#{roomid} order by createtime desc
  </select>

  <!--资料产看学生-->
  <select id="listProfileStus" resultType="com.xhkjedu.sclass.model.classroom.TClassroomVoteStudent">
    select s.stuvote,s.createtime,s.studentid,u.username from t_classroom_profile_student s
    left join t_user u on s.studentid=u.userid
    where s.profileid=#{profileid} order by s.createtime
  </select>

  <!--资料信息-->
  <select id="listProfileStuByRoomAndStuid" resultType="java.util.Map">
    select p.profileid,p.profilename,p.profileurl,p.profilesuffix,
    ps.stusec,ps.createtime from t_classroom_profile p
    left join t_classroom_profile_student ps on p.profileid=ps.profileid and ps.studentid=#{studentid}
    where p.roomid=#{roomid} group by p.profileid order by p.profileid
  </select>

  <!--批量保存-->
  <insert id="insertBatch">
    insert into t_classroom_profile
    (profileid,roomid,profilename,profileurl,profilesuffix,createid,createtime,schoolid)
    values
    <foreach collection="profiles" item="p" separator=",">
      (#{p.profileid},#{p.roomid},#{p.profilename},#{p.profileurl},#{p.profilesuffix},#{p.createid},#{p.createtime},#{p.schoolid})
    </foreach>
  </insert>

</mapper>