<?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.jkserver.dao.ExamStageTempDao">

    <select id="findByExamCodeAndAttachmentId" resultType="com.qmth.jkserver.model.ExamStageTemp">
        select * from jk_exam_stage_temp t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
            <if test="attachmentId != null and attachmentId != ''">
                and t.attachment_id = #{attachmentId}
            </if>
        </where>
    </select>

    <select id="findByExamCodeAndAttachmentIdByMap" resultType="java.util.Map">
        select t.batch_id as batchId,t.batch_name as batchName from jk_exam_stage_temp t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
            <if test="attachmentId != null and attachmentId != ''">
                and t.attachment_id = #{attachmentId}
            </if>
        </where>
        group by t.batch_id,t.batch_name
        order by t.batch_id
    </select>

    <select id="findByExamCodeAndAttachmentIdAndBatchId" resultType="java.util.Map">
        select t.stage_id as stageId from jk_exam_stage_temp t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
            <if test="attachmentId != null and attachmentId != ''">
                and t.attachment_id = #{attachmentId}
            </if>
            <if test="batchId != null and batchId != ''">
                and t.batch_id = #{batchId}
            </if>
        </where>
        group by t.batch_id,t.stage_id
        order by t.stage_id
    </select>
</mapper>
