<?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.qmth.teachcloud.mark.mapper.ScanAnswerCardMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qmth.teachcloud.mark.entity.ScanAnswerCard">
        <id column="id" property="id" />
        <result column="exam_id" property="examId" />
        <result column="paper_number" property="paperNumber" />
        <result column="course_paper_id" property="coursePaperId" />
        <result column="card_id" property="cardId" />
        <result column="number" property="number" />
        <result column="source" property="source" />
        <result column="uri" property="uri" />
        <result column="md5" property="md5" />
        <result column="parameter" property="parameter" />
        <result column="remark" property="remark" />
        <result column="update_time" property="updateTime" />
        <result column="need_adapte" property="needAdapte" />
        <result column="paper_count" property="paperCount" />
        <result column="single_page" property="singlePage" />
        <result column="slice_config" property="sliceConfig" />
        <result column="dpi" property="dpi" />
        <result column="code" property="code" />
        <result column="adapte_md5" property="adapteMd5" />
        <result column="adapte_uri" property="adapteUri" />
    </resultMap>
    
	<select id="cardList"
            resultType="com.qmth.teachcloud.mark.bean.answercard.AnswerCardVo">
        select t.*,t.paper_number coursePaperNumber,f.course_code,f.course_name
        from scan_answer_card t
        left join (select * from mark_paper where status = #{status}) f on t.exam_id=f.exam_id and t.course_paper_id=f.course_paper_id
        left join sys_user su on f.user_id = su.id
        where t.exam_id=#{examId}
        <if test="coursePaperId != null and coursePaperId !=''">
            and t.course_paper_id=#{coursePaperId}
        </if>
        <if test="dpr != null">
            <if test="dpr.requestUserId != null">
                AND f.user_id = #{dpr.requestUserId}
            </if>
            <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
                AND su.org_id IN
                <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </if>
        order by t.exam_id, t.number
    </select>
    <select id="cardGet"
            resultType="com.qmth.teachcloud.mark.bean.answercard.AnswerCardVo">
        select t.*,t.paper_number coursePaperNumber,f.course_code,f.course_name
        from scan_answer_card t
        left join mark_paper f on t.exam_id=f.exam_id and t.course_paper_id=f.course_paper_id
        where t.exam_id=#{examId} and t.number=#{number}
    </select>
    
</mapper>
