<?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.report.business.mapper.TBExamRecordMapper">

    <select id="findByExamIdAndCourseCodeS"
            resultType="com.qmth.teachcloud.report.business.bean.dto.query.BasicExamRecordDto">
        SELECT
            bs.id AS examStudentId,
            bs.exam_id AS examId,
            bs.name AS studentName,
            student_id AS studentId,
            course_code AS courseCode,
            course_name AS courseName,
            teach_college_id AS teachCollegeId,
            inspect_college_id AS inspectCollegeId,
            clazz_id AS clazzId,
            major_id AS majorId,
            teacher_id AS teacherId,
            ticket_number AS ticketNumber,
            student_code AS studentCode,
            absent AS absent,
            student_current as studentCurrent,
            br.id AS tbExamRecordId,
            paper_id AS paperId,
            paper_type AS paperType,
            subjective_score AS subjectiveScore,
            objective_score AS objectiveScore,
            total_score AS totalScore
        FROM
            t_b_exam_student bs
                LEFT JOIN
            t_b_exam_record br ON bs.exam_id = br.exam_id
                AND bs.id = br.exam_student_id
        WHERE
        <if test="examId > 0">
            bs.exam_id = #{examId}
        </if>
        <if test="courseCodes != null and courseCodes.size() > 0">
            and bs.course_code IN
            <foreach collection="courseCodes" item="courseCode" index="index" open="(" close=")" separator=",">
                #{courseCode}
            </foreach>
        </if>
    </select>
</mapper>
