2025-10-15 13:11:19 +08:00
|
|
|
<?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="org.xyzh.study.mapper.CourseChapterMapper">
|
|
|
|
|
|
|
|
|
|
<!-- 基础结果映射 -->
|
|
|
|
|
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.study.TbCourseChapter">
|
|
|
|
|
<id column="id" property="id" jdbcType="VARCHAR"/>
|
|
|
|
|
<result column="course_id" property="courseID" jdbcType="VARCHAR"/>
|
|
|
|
|
<result column="name" property="name" jdbcType="VARCHAR"/>
|
|
|
|
|
<result column="content" property="content" jdbcType="LONGVARCHAR"/>
|
|
|
|
|
<result column="video_url" property="videoUrl" jdbcType="VARCHAR"/>
|
|
|
|
|
<result column="duration" property="duration" jdbcType="INTEGER"/>
|
|
|
|
|
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
|
|
|
|
|
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
|
|
|
|
<result column="updater" property="updater" jdbcType="VARCHAR"/>
|
|
|
|
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
|
|
|
|
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
|
|
|
|
<result column="delete_time" property="deleteTime" jdbcType="TIMESTAMP"/>
|
|
|
|
|
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<!-- 基础字段 -->
|
|
|
|
|
<sql id="Base_Column_List">
|
|
|
|
|
id, course_id, name, content, video_url, duration, order_num,
|
|
|
|
|
creator, updater, create_time, update_time, delete_time, deleted
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<!-- 通用条件 -->
|
|
|
|
|
<sql id="Where_Clause">
|
|
|
|
|
<where>
|
|
|
|
|
deleted = 0
|
|
|
|
|
<if test="courseID != null and courseID != ''">
|
|
|
|
|
AND course_id = #{courseID}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="name != null and name != ''">
|
|
|
|
|
AND name LIKE CONCAT('%', #{name}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<!-- selectCourseChapters -->
|
|
|
|
|
<select id="selectCourseChapters" resultMap="BaseResultMap">
|
|
|
|
|
SELECT
|
|
|
|
|
<include refid="Base_Column_List"/>
|
|
|
|
|
FROM tb_course_chapter
|
|
|
|
|
<include refid="Where_Clause"/>
|
|
|
|
|
ORDER BY order_num ASC, create_time ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
2025-10-16 14:31:56 +08:00
|
|
|
<!-- 根据章节ID查询章节信息 -->
|
|
|
|
|
<select id="selectByChapterId" resultMap="BaseResultMap">
|
|
|
|
|
SELECT
|
|
|
|
|
<include refid="Base_Column_List" />
|
|
|
|
|
FROM tb_course_chapter
|
|
|
|
|
WHERE id = #{chapterId} AND deleted = 0
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 根据课程ID查询章节列表 -->
|
|
|
|
|
<select id="selectByCourseId" resultMap="BaseResultMap">
|
|
|
|
|
SELECT
|
|
|
|
|
<include refid="Base_Column_List" />
|
|
|
|
|
FROM tb_course_chapter
|
|
|
|
|
WHERE course_id = #{courseId} AND deleted = 0
|
|
|
|
|
ORDER BY order_num ASC, create_time ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 根据章节名称查询章节 -->
|
|
|
|
|
<select id="selectByName" resultMap="BaseResultMap">
|
|
|
|
|
SELECT
|
|
|
|
|
<include refid="Base_Column_List" />
|
|
|
|
|
FROM tb_course_chapter
|
|
|
|
|
WHERE name = #{name} AND deleted = 0
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 根据状态查询章节列表 -->
|
|
|
|
|
<select id="selectByStatus" resultMap="BaseResultMap">
|
|
|
|
|
SELECT
|
|
|
|
|
<include refid="Base_Column_List" />
|
|
|
|
|
FROM tb_course_chapter
|
|
|
|
|
WHERE deleted = 0
|
|
|
|
|
ORDER BY order_num ASC, create_time ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 根据课程ID和排序查询章节列表 -->
|
|
|
|
|
<select id="selectByCourseIdOrderBySort" resultMap="BaseResultMap">
|
|
|
|
|
SELECT
|
|
|
|
|
<include refid="Base_Column_List" />
|
|
|
|
|
FROM tb_course_chapter
|
|
|
|
|
WHERE course_id = #{courseId} AND deleted = 0
|
|
|
|
|
ORDER BY order_num ASC, create_time ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 检查章节名称是否存在 -->
|
|
|
|
|
<select id="countByName" resultType="int">
|
|
|
|
|
SELECT COUNT(1)
|
|
|
|
|
FROM tb_course_chapter
|
|
|
|
|
WHERE name = #{name} AND deleted = 0
|
|
|
|
|
<if test="excludeId != null and excludeId != ''">
|
|
|
|
|
AND id != #{excludeId}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 插入课程章节 -->
|
|
|
|
|
<insert id="insertCourseChapter" parameterType="org.xyzh.common.dto.study.TbCourseChapter">
|
|
|
|
|
INSERT INTO tb_course_chapter (
|
|
|
|
|
id, course_id, name, content, video_url, duration, order_num,
|
|
|
|
|
creator, updater, create_time, update_time, delete_time, deleted
|
|
|
|
|
) VALUES (
|
|
|
|
|
#{id}, #{courseID}, #{name}, #{content}, #{videoUrl}, #{duration}, #{orderNum},
|
|
|
|
|
#{creator}, #{updater}, #{createTime}, #{updateTime}, #{deleteTime}, #{deleted}
|
|
|
|
|
)
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<!-- 更新课程章节 -->
|
|
|
|
|
<update id="updateCourseChapter" parameterType="org.xyzh.common.dto.study.TbCourseChapter">
|
|
|
|
|
UPDATE tb_course_chapter
|
|
|
|
|
<set>
|
|
|
|
|
<if test="courseID != null and courseID != ''">
|
|
|
|
|
course_id = #{courseID},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="name != null and name != ''">
|
|
|
|
|
name = #{name},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="content != null and content != ''">
|
|
|
|
|
content = #{content},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="videoUrl != null and videoUrl != ''">
|
|
|
|
|
video_url = #{videoUrl},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="duration != null">
|
|
|
|
|
duration = #{duration},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="orderNum != null">
|
|
|
|
|
order_num = #{orderNum},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="updater != null and updater != ''">
|
|
|
|
|
updater = #{updater},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="updateTime != null">
|
|
|
|
|
update_time = #{updateTime},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deleteTime != null">
|
|
|
|
|
delete_time = #{deleteTime},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deleted != null">
|
|
|
|
|
deleted = #{deleted},
|
|
|
|
|
</if>
|
|
|
|
|
</set>
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<!-- 删除课程章节 -->
|
|
|
|
|
<delete id="deleteCourseChapter" parameterType="org.xyzh.common.dto.study.TbCourseChapter">
|
|
|
|
|
DELETE FROM tb_course_chapter
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<!-- 批量插入课程章节 -->
|
|
|
|
|
<insert id="batchInsertCourseChapters" parameterType="java.util.List">
|
|
|
|
|
INSERT INTO tb_course_chapter (
|
|
|
|
|
id, course_id, name, content, video_url, duration, order_num,
|
|
|
|
|
creator, updater, create_time, update_time, delete_time, deleted
|
|
|
|
|
) VALUES
|
|
|
|
|
<foreach collection="courseChapterList" item="item" separator=",">
|
|
|
|
|
(
|
|
|
|
|
#{item.id}, #{item.courseID}, #{item.name}, #{item.content}, #{item.videoUrl},
|
|
|
|
|
#{item.duration}, #{item.orderNum}, #{item.creator}, #{item.updater},
|
|
|
|
|
#{item.createTime}, #{item.updateTime}, #{item.deleteTime}, #{item.deleted}
|
|
|
|
|
)
|
|
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<!-- 批量删除课程章节 -->
|
|
|
|
|
<delete id="batchDeleteCourseChapters">
|
|
|
|
|
DELETE FROM tb_course_chapter
|
|
|
|
|
WHERE id IN
|
|
|
|
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<!-- 根据课程ID批量删除章节 -->
|
|
|
|
|
<delete id="deleteByCourseId">
|
|
|
|
|
DELETE FROM tb_course_chapter
|
|
|
|
|
WHERE course_id = #{courseId}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<!-- 分页查询课程章节 -->
|
|
|
|
|
<select id="selectCourseChaptersPage" resultMap="BaseResultMap">
|
|
|
|
|
SELECT
|
|
|
|
|
<include refid="Base_Column_List" />
|
|
|
|
|
FROM tb_course_chapter
|
|
|
|
|
<include refid="Where_Clause" />
|
|
|
|
|
ORDER BY order_num ASC, create_time ASC
|
2025-10-20 15:08:20 +08:00
|
|
|
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
2025-10-16 14:31:56 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 统计课程章节总数 -->
|
|
|
|
|
<select id="countCourseChapters" resultType="long">
|
|
|
|
|
SELECT COUNT(1)
|
|
|
|
|
FROM tb_course_chapter
|
|
|
|
|
<include refid="Where_Clause" />
|
|
|
|
|
</select>
|
|
|
|
|
|
2025-10-15 13:11:19 +08:00
|
|
|
</mapper>
|