<?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.TeachCourseMapper">

    <select id="findTeachCoursePage"
            resultType="com.qmth.distributed.print.business.bean.result.TeachCourseResult">
        SELECT
            tc.id,
            bc.code AS courseCode,
            bc.name AS courseName,
            tc.create_time AS createTime
        FROM
            teach_course tc
                INNER JOIN
            basic_course bc ON tc.basic_course_id = bc.id AND bc.enable = TRUE
        <where>
            <if test="schoolId != null and schoolId != ''">
                AND tc.school_id = #{schoolId}
            </if>
            <if test="courseName != null and courseName != ''">
                AND bc.name LIKE CONCAT('%',#{courseName},'%')
            </if>
            <if test="userId != null and userId != ''">
                AND tc.user_id = #{userId}
            </if>
            AND tc.enable = true
        </where>
        ORDER BY tc.create_time DESC
    </select>
</mapper>


