<?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="jnpf.cultivate.mapper.FtbCultivateCoursePackageMapper">
  <!--查询课程包课程-->
  <select id="getPackageDetails"
            resultType="jnpf.model.cultivate.vo.coursepackage.FtbCultivateCoursePackageDetailsVO">
    SELECT
    a.F_Name as courseName,
    a.F_Id as courseId,
    a.F_Format as format,
    c.F_Name as courseType
    FROM ftb_cultivate_course a JOIN ftb_cultivate_package_course b ON a.F_Id=b.F_CourseId
     JOIN ftb_cultivate_label c ON a.F_TypeId=c.F_Id
    WHERE a.F_EnabledMark = 0 and b.F_CoursePackageId = #{id}
  </select>
  <!--课程包分页查询-->
  <select id="pagingQuery" resultType="jnpf.model.cultivate.vo.coursepackage.FtbCultivateCoursePackagePageVO">
    SELECT
    a.F_Name as name,
    a.F_Id as id,
    a.F_CreatorTime as createTime,
    a.F_CreatorUserId as createUserId,
    a.F_LastModifyTime as updateTime,
    a.F_LastModifyUserId as updateUserId,
    a.F_Highlights as highlights,
    a.F_CoursePackageId as coursePackageId,
    (SELECT COUNT(*)
    FROM ftb_cultivate_package_course b JOIN ftb_cultivate_course c ON c.F_Id=b.F_CourseId
    WHERE F_CoursePackageId = a.F_Id and c.F_EnabledMark = 0)
    as courseNumber
    FROM ftb_cultivate_course_package a
    WHERE a.F_EnabledMark = 0
    <if test="params.keyword != null">
      and (a.F_Name like concat('%',#{params.keyword},'%') or a.F_CoursePackageId = #{params.keyword})
    </if>

  </select>
  <!--根据课程包id查询课程数据-->
  <select id="queryCoursePackageCourses"
          resultType="jnpf.model.cultivate.vo.coursepackage.FtbCultivateCoursePackageDetailsVO">
    SELECT
    a.F_Name as courseName,a.F_Id as courseId, a.F_Format as format
    FROM ftb_cultivate_course a JOIN ftb_cultivate_package_course b ON a.F_Id = b.F_CourseId
    WHERE a.F_EnabledMark = 0 and b.F_CoursePackageId in
    <foreach collection="coursePackageIds" item="coursePackageId" separator="," open="(" close=")">
       #{coursePackageId}
    </foreach>
    group by a.F_Id,a.F_Name
  </select>

</mapper>