<?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="cn.iocoder.byzs.module.bjdx.dal.mysql.course.CourseMapper">

    <sql id="selectCourseList">
        FROM bjdx_course c
        LEFT JOIN bjdx_course_type ct ON c.course_type = ct.id
        <where>
            c.deleted = 0 AND ct.deleted = 0
            <if test="courseName != null and courseName != ''">
                AND c.course_name LIKE CONCAT('%', #{courseName}, '%')
            </if>
            <if test="courseTeacher!= null and courseTeacher!= ''">
                AND c.course_teacher LIKE CONCAT('%', #{courseTeacher}, '%')
            </if>
            <if test="courseStatus!= null and courseStatus!= ''">
                AND c.course_status = #{courseStatus}
            </if>
            <if test="courseType!= null and courseType!= ''">
                AND c.course_type = #{courseType}
            </if>
            <if test="courseLabel!= null and courseLabel!= ''">
                AND c.course_label = #{courseLabel}
            </if>
            <if test="courseContentType!= null and courseContentType!= ''">
                AND c.course_content_type = #{courseContentType}
            </if>
            <if test="courseIsInspect!= null and courseIsInspect!= ''">
                AND c.course_is_inspect = #{courseIsInspect}
            </if>
            <if test="ctTypeNode!= null and ctTypeNode!= ''">
                AND (ct.ct_type_node = #{ctTypeNode})
            </if>
        </where>
        ORDER BY ct.ct_type_sort, c.course_order
    </sql>
    <select id="selectCoursePageCount" parameterType="cn.iocoder.byzs.module.bjdx.controller.admin.course.vo.CoursePageReqVO"
            resultType="int">
        SELECT COUNT(*)
        <include refid="selectCourseList"/>
    </select>
    <select id="selectCoursePage" parameterType="cn.iocoder.byzs.module.bjdx.controller.admin.course.vo.CoursePageReqVO"
            resultType="cn.iocoder.byzs.module.bjdx.controller.admin.course.vo.CoursePageReqVO">
        SELECT c.tenant_id as tenantId,c.id, c.course_name courseName, c.course_image_path courseImagePath, c.course_music_path courseMusicPath, c.course_video_path courseVideoPath, c.course_content_type courseContentType, c.course_author courseAuthor, c.course_teacher courseTeacher, c.course_size courseSize,
        c.course_time courseTime, c.course_is_inspect courseIsInspect, c.course_label courseLabel, c.course_order courseOrder, c.course_status courseStatus, ct.ct_type courseTypeName
        <include refid="selectCourseList"/>
        <if test="pageSize != null and pageSize != -1">
            limit #{pageNo}, #{pageSize}
        </if>
    </select>
    <select id="selectCourseList" parameterType="cn.iocoder.byzs.module.bjdx.controller.admin.course.vo.CoursePageReqVO"
            resultType="cn.iocoder.byzs.module.bjdx.controller.admin.course.vo.CoursePageReqVO">
        SELECT c.tenant_id as tenantId,c.id, c.course_name courseName, c.course_type courseType, c.course_content courseContent, c.course_image_path courseImagePath, c.course_music_path courseMusicPath, c.course_video_path courseVideoPath, c.course_content_type courseContentType, c.course_author courseAuthor, c.course_teacher courseTeacher, c.course_size courseSize,
        c.course_time courseTime, c.course_is_inspect courseIsInspect, c.course_label courseLabel, c.course_order courseOrder, c.course_status courseStatus, ct.ct_type courseTypeName
        <include refid="selectCourseList"/>
    </select>
</mapper>