<?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.smarking.mapper.paper.MsPaperFileMapper">

    <!--删除试卷指定类型附件-->
    <delete id="deleteByMpidAndType">
        delete from ms_paper_file where mpid=#{mpid} and filetype=#{filetype}
    </delete>

    <!--删除试卷文件-->
    <delete id="deleteByMpid">
        delete from ms_paper_file where mpid=#{mpid}
    </delete>

    <!--试卷附件-->
    <select id="listFilesbyMpidAndType" resultType="com.xhkjedu.smarking.model.paper.MsPaperFile">
        select * from ms_paper_file where mpid=#{mpid}
        <if test="filetype!=null and filetype!=0">
            and filetype=#{filetype}
        </if>
        order by fileorder
    </select>
    <!--试卷原卷或答案-->
    <select id="listFileByFiletype" resultType="java.util.Map">
        select filepath,sourcepath,filetype,fileorder from ms_paper_file where mpid=#{mpid} and filetype=#{filetype}
        order by fileorder
    </select>

    <!--更改试卷附件源文件路径-->
    <update id="updateSourcepathByMpid">
        update ms_paper_file set sourcepath=#{sourcepath} where mpid=#{mpid} and filetype=#{filetype}
    </update>
</mapper>
