<?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.sapi.mapper.scantron.ScantronMapper">
    <!--答题卡列表-->
    <select id="listScantrons" resultType="java.util.Map">
        select s.sid,s.sname,s.subjectid,s.publiched,s.pdfpath,s.createid,
        s.createtime,u.username as createname,st.subjectname
        from t_scantron s left join t_user u on s.createid=u.userid
        left join t_subject st on s.subjectid=st.subjectid
        where s.schoolid=#{s.schoolid}
        <if test="s.createid!=null and s.createid!=0">
            and s.createid=#{s.createid}
        </if>
        <if test="s.subjectid!=null and s.subjectid!=''">
            and s.subjectid=#{s.subjectid}
        </if>
        <if test="s.publiched!=null and s.publiched!=0">
            and s.publiched=#{s.publiched}
        </if>
        <if test="s.sname!=null and s.sname!=''">
            and s.sname like concat('%',#{s.sname},'%')
        </if>
        order by s.createtime desc,s.sid desc
    </select>

    <!--修改答题卡公开状态-->
    <update id="updateScantronPubliched">
        update t_scantron set publiched=#{publiched} where sid=#{sid}
    </update>

    <!--获取答题卡所在学校区域信息-->
    <select id="getSchoolCloud" resultType="java.lang.String">
        select cloudcode from t_cloud order by cloudid limit 1
    </select>

    <!--更改pdf地址-->
    <update id="updatePdfpath">
        update t_scantron set pdfpath=#{pdfpath} where sid=#{sid}
    </update>

</mapper>
