<?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.CourseSectionPlaybackMapper">
    <!--修改回放地址-->
    <update id="updatePlayback">
        update l_course_section_playback set endtime=#{playback.endtime},mc=#{playback.mc},
        pb=#{playback.pb},cover=#{playback.cover},duration=#{playback.duration}
        where sid=#{playback.sid}
    </update>

    <!--课节下所有回放-->
    <select id="listSectionPlaybacks" resultType="java.util.Map">
        select p.pbid,p.sectionid,p.begintime,p.endtime,p.mc,p.pb,p.cover,p.duration,p.rn,p.dn,s.teacherid,u.username
        from l_course_section_playback p
        left join l_course_section s on p.sectionid=s.sectionid
        left join t_user u on s.teacherid=u.userid
        where p.sectionid=#{sectionid} and p.pb is not null and p.pb!='' order by p.pbid
    </select>

    <!--修改观看次数-->
    <update id="updateReadnum">
        update l_course_section_playback set rn = rn+1 where pbid=#{pbid};
    </update>

    <!--修改下载次数-->
    <update id="updateDownnum">
        update l_course_section_playback set dn = dn+1 where pbid=#{pbid};
    </update>
    <!--根据课节名称获取回放地址列表-->
    <resultMap id="pbResult" type="java.util.Map">
        <result property="rspath" column="rspath"/>
        <collection property="pbs" javaType="java.util.List" ofType="java.lang.String">
            <result property="pb" column="pb"/>
        </collection>
    </resultMap>
    <select id="listPb" resultMap="pbResult">
        select p.pb,r.rspath
        from l_course_section cs right join l_course_section_playback p on cs.sectionid=p.sectionid
        left join l_recordserver r on p.rsid=r.rsid
        where p.pb is not null and p.pb!=''
        <foreach collection="sectionnames" item="sectionname" open=" and (" separator="or" close=")">
            cs.sectionname LIKE '%${sectionname}%'
        </foreach>
    </select>
    <!--删除回放-->
    <update id="deletePb">
        update l_course_section_playback set pb=null where pb in
        <foreach collection="pbs" item="pb" open="(" separator="," close=")">'${pb}'</foreach>
    </update>

</mapper>
