<?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.distributed.print.business.mapper.BasicTeachClazzMapper">

    <select id="findTeachClazzList"
            resultType="com.qmth.distributed.print.business.bean.result.BasicTeachClazzResult">
        SELECT
            btc.id,
            btc.exam_id AS examId,
            bc.name AS courseName,
            course_code AS courseCode,
            clazz_name AS clazzName
        FROM
            basic_teach_clazz btc
        LEFT JOIN
            basic_course bc ON btc.school_id = bc.school_id AND btc.course_code = bc.code
        <where>
            <if test="examId != null">
                AND btc.exam_id = #{examId}
            </if>
            <if test="courseCode != null and courseCode != ''">
                AND btc.course_code = #{courseCode}
            </if>
            <if test="clazzName != null and clazzName != ''">
                AND btc.clazz_name LIKE CONCAT('%',#{clazzName},'%')
            </if>
        </where>
    </select>
</mapper>
