<?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.aicourse.dal.mysql.aiCourse.AiCourseMapper">

    <sql id="selectAiCourseList">
        FROM ai_course c
        LEFT JOIN ai_course_type ct ON c.ac_type = ct.id
        <where>
            c.deleted = 0
            <if test="acName != null and acName != ''">
                AND c.ac_name LIKE CONCAT('%', #{acName}, '%')
            </if>
            <if test="acStatus!= null and acStatus!= ''">
                AND c.ac_status = #{acStatus}
            </if>
            <if test="acType!= null and acType!= ''">
                AND c.ac_type = #{acType}
            </if>
            <if test="acLabel!= null and acLabel!= ''">
                AND c.ac_label = #{acLabel}
            </if>
            <if test="acContentType!= null and acContentType!= ''">
                AND c.ac_content_type = #{acContentType}
            </if>
            <if test="acIsInspect!= null and acIsInspect!= ''">
                AND c.ac_is_inspect = #{acIsInspect}
            </if>
        </where>
        ORDER BY ct.ct_type_sort, c.ac_order
    </sql>
    <select id="selectAiCoursePageCount" parameterType="cn.iocoder.byzs.module.aicourse.controller.admin.aiCourse.vo.AiCoursePageReqVO"
            resultType="int">
        SELECT COUNT(*)
        <include refid="selectAiCourseList"/>
    </select>
     <select id="selectAiCoursePage" parameterType="cn.iocoder.byzs.module.aicourse.controller.admin.aiCourse.vo.AiCoursePageReqVO"
            resultType="cn.iocoder.byzs.module.aicourse.controller.admin.aiCourse.vo.AiCoursePageReqVO">
        SELECT c.tenant_id as tenantId,c.id, c.ac_name acName,
               c.ac_content_type acContentType, c.ac_content acContent,
               c.ai_pre_dialogues aiPreDialogues, c.ai_reply_supplement aiReplySupplement,
               c.ac_is_inspect acIsInspect, c.ac_label acLabel, c.ac_order acOrder, c.ac_status acStatus,
               ct.ct_type acTypeName
        <include refid="selectAiCourseList"/>
        <if test="pageSize != null and pageSize != -1">
            limit #{pageNo}, #{pageSize}
        </if>
    </select>
    <select id="selectAiCourseList" parameterType="cn.iocoder.byzs.module.aicourse.controller.admin.aiCourse.vo.AiCoursePageReqVO"
            resultType="cn.iocoder.byzs.module.aicourse.controller.admin.aiCourse.vo.AiCoursePageReqVO">
        SELECT c.tenant_id as tenantId,c.id, c.ac_name acName, c.ac_type acType,
               c.ac_content_type acContentType, c.ac_content acContent,
               c.ai_pre_dialogues aiPreDialogues, c.ai_reply_supplement aiReplySupplement,
               c.ac_is_inspect acIsInspect, c.ac_label acLabel, c.ac_order acOrder, c.ac_status acStatus,
               ct.ct_type acTypeName
        <include refid="selectAiCourseList"/>
    </select>
</mapper>