<?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.sstudy.mapper.question.QuestionExplainMapper">
    <!--试题讲解列表-->
    <select id="listByQuestionId" resultType="com.xhkjedu.sstudy.model.question.TQuestionExplain">
        select qe.*,u.username createname
        from t_question_explain qe left join t_user u on qe.createid=u.userid
        where qe.questionid=#{questionid}
        <if test="qctype==2">
            and qe.qctype=2
        </if>
        <if test="qctype!=2">
            and qe.qctype!=2
        </if>
        order by qe.createtime desc
    </select>
    <!--更新播放次数-->
    <update id="updateReadCount">
        update t_question_explain set readcount=readcount+1 where qcpid=#{qcpid}
    </update>
    <!--修改讲解mp4code-->
    <update id="updateMp4code">
        update t_question_explain set filepath=#{explain.filepath},mp4code=#{explain.mp4code}
        where qcpid=#{explain.qcpid}
    </update>

    <select id="listAll" resultType="com.xhkjedu.sstudy.model.question.TQuestionExplain">
        select * from t_question_explain where duration is null
    </select>
    <!--修改视频时长和大小-->
    <update id="updateDurationAndSize">
        update t_question_explain set filesize=#{explain.filesize},duration=#{explain.duration} where qcpid=#{explain.qcpid}
    </update>
    <!--试题讲解列表-->
    <select id="listByQuestionIds" resultType="com.xhkjedu.sstudy.model.question.TQuestionExplain">
        select qe.*,u.username createname
        from t_question_explain qe left join t_user u on qe.createid=u.userid
        where
        <foreach collection="questions" item="question" index="index" separator="or">
            (qe.questionid=#{question.questionid}
            <if test="question.qctype==2">
                and qe.qctype=2
            </if>
            <if test="question.qctype!=2">
                and qe.qctype!=2
            </if>
            )
        </foreach>
        order by qe.createtime desc
    </select>
</mapper>
