<?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.yudao.module.knowledge.mapper.TCoursewareMapper">

    <resultMap type="cn.iocoder.yudao.module.knowledge.entity.TCourseware" id="tCoursewareMap">
        <result property="id" column="id"/>
        <result property="courseId" column="course_id"/>
        <result property="name" column="name"/>
        <result property="desrc" column="desrc"/>
        <result property="code" column="code"/>
        <result property="order" column="order"/>
        <result property="fileUrl" column="file_url"/>
        <result property="fileName" column="file_name"/>
        <result property="fileSize" column="file_size"/>
    </resultMap>
    <delete id="deleteByCourseIds">
        delete from t_courseware where course_id in
        <foreach collection="courseIdList" item="courseId" open="(" separator="," close=")">
            #{courseId}
        </foreach>
        AND deleted = 0
    </delete>
    <select id="queryListByCourseId" resultType="cn.iocoder.yudao.module.knowledge.entity.TCourseware">
        select * from t_courseware where course_id = #{courseId} and deleted = 0
    </select>

    <select id="findList" resultType="cn.iocoder.yudao.module.knowledge.controller.responsevo.TCoursewarevos">
        select tc.id id,tc.name name,tco.name courseName,tcd.name dirName,tc.file_url
        from t_courseware tc
        inner join t_course tco on tc.course_id = tco.id
        inner join t_course_directory tcd on tco.course_directory_id = tcd.id
        <where>
            <if test="params.name != null and params.name != ''">
                tc.name LIKE CONCAT( '%',#{params.name}, '%')
            </if>
        </where>
    </select>

</mapper>
