<?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.paper.library.business.mapper.ExamStudentMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qmth.paper.library.common.entity.ExamStudent">
        <result column="id" property="id"/>
        <result column="school_id" property="schoolId"/>
        <result column="semester_id" property="semesterId"/>
        <result column="exam_id" property="examId"/>
        <result column="course_code" property="courseCode"/>
        <result column="course_name" property="courseName"/>
        <result column="student_code" property="studentCode"/>
        <result column="student_name" property="studentName"/>
        <result column="college_name" property="collegeName"/>
        <result column="major_name" property="majorName"/>
        <result column="class_name" property="className"/>
        <result column="teacher" property="teacher"/>
        <result column="teach_class" property="teachClass"/>
        <result column="exam_room" property="examRoom"/>
        <result column="source" property="source"/>
        <result column="score" property="score"/>
        <result column="remark" property="remark"/>
        <result column="extend_fields" property="extendFields"/>
        <result column="enable" property="enable"/>
        <result column="bind_count" property="bindCount"/>
        <result column="create_id" property="createId"/>
        <result column="create_time" property="createTime"/>
        <result column="update_id" property="updateId"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        select id, school_id, semester_id, exam_id, course_code, course_name, student_code, student_name, college_name, major_name, class_name, teacher,teach_class,
               exam_room, `source`, score,remark,extend_fields, enable, bind_count, create_id, create_time, update_id, update_time from exam_student
    </sql>

    <select id="findStudentPage"
            resultType="com.qmth.paper.library.common.entity.ExamStudent">
        <include refid="Base_Column_List"></include>
        <where>
            <if test="examId != null">
                and exam_id = #{examId}
            </if>
            <if test="courseCode != null and courseCode != ''">
                and course_code = #{courseCode}
            </if>
            <if test="collegeName != null and collegeName != ''">
                and college_name like concat(#{collegeName},'%')
            </if>
            <if test="majorName != null and majorName != ''">
                and major_name like concat(#{majorName},'%')
            </if>
            <if test="className != null and className != ''">
                and class_name like concat(#{className},'%')
            </if>
            <if test="queryParams != null and queryParams != ''">
                and (student_name like concat(#{queryParams},'%') or student_code like concat(#{queryParams},'%'))
            </if>
            and enable = true
        </where>
        ORDER BY course_code, student_code
    </select>
</mapper>
