<?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.yida.data.school.exam.mapper.CoreExaminationTeacherMapper">
    <resultMap id="BaseResultMap" type="com.yida.data.common.core.entity.exam.CoreExaminationTeacher">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="create_id" property="createId" jdbcType="VARCHAR"/>
        <result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
        <result column="update_id" property="updateId" jdbcType="VARCHAR"/>
        <result column="update_date" property="updateDate" jdbcType="TIMESTAMP"/>
        <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
        <result column="core_examination_id" property="coreExaminationId" jdbcType="INTEGER"/>
        <result column="core_teacher_id" property="coreTeacherId" jdbcType="INTEGER"/>
        <result column="teacher_app_id" property="teacherAppId" jdbcType="VARCHAR"/>
        <result column="teacher_name" property="teacherName" jdbcType="VARCHAR"/>
        <result column="teacher_tel" property="teacherTel" jdbcType="VARCHAR"/>
        <result column="teacher_school" property="teacherSchool" jdbcType="VARCHAR"/>
    </resultMap>

    <!--查询本次考试对应的监考老师列表数据-->
    <select id="findExaminationTeacherPageList" parameterType="com.yida.data.common.core.entity.exam.CoreExaminationTeacher" resultMap="BaseResultMap">
        SELECT
            cet.id AS id,
            cet.teacher_name AS teacher_name,
            cet.teacher_tel AS teacher_tel,
            cet.teacher_school AS teacher_school,
            GROUP_CONCAT(
                cetd.teacher_type
                ORDER BY
                    cetd.id ASC SEPARATOR '/'
            ) AS teacher_type,
            GROUP_CONCAT(
                cetd.teacher_course_name
                ORDER BY
                    cetd.id ASC SEPARATOR '/'
            ) AS teacher_course_name,
            GROUP_CONCAT(
                cetd.teacher_examination_room
                ORDER BY
                    cetd.id ASC SEPARATOR '/'
            ) AS teacher_examination_room
        FROM
            core_examination_teacher cet
        LEFT JOIN core_examination_teacher_detail cetd ON cet.id = cetd.core_examination_teacher_id
        WHERE
            cet.del_flag = '0'
        AND cetd.del_flag = '0'
        AND cet.core_examination_id = #{examId}
        <if test='teacherName != null and teacherName != ""'>
            AND cet.teacher_name LIKE CONCAT('%', #{teacherName}, '%')
        </if>
        GROUP BY
            id,
            teacher_name,
            teacher_tel,
            teacher_school
        ORDER BY
            cet.create_date DESC
    </select>

</mapper>