serv-mapper和.xml 基本增删改

This commit is contained in:
2025-10-16 14:31:56 +08:00
parent 7f65404f28
commit 1199cbc176
54 changed files with 7516 additions and 197 deletions

View File

@@ -47,4 +47,159 @@
ORDER BY order_num ASC, create_time ASC
</select>
<!-- 根据章节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
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
</select>
<!-- 统计课程章节总数 -->
<select id="countCourseChapters" resultType="long">
SELECT COUNT(1)
FROM tb_course_chapter
<include refid="Where_Clause" />
</select>
</mapper>

View File

@@ -59,4 +59,209 @@
ORDER BY order_num ASC, create_time DESC
</select>
<!-- 根据课程ID查询课程信息 -->
<select id="selectByCourseId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_course
WHERE course_id = #{courseId} AND deleted = 0
</select>
<!-- 根据课程名称查询课程 -->
<select id="selectByName" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_course
WHERE name = #{name} AND deleted = 0
</select>
<!-- 根据状态查询课程列表 -->
<select id="selectByStatus" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_course
WHERE status = #{status} AND deleted = 0
ORDER BY order_num ASC, create_time DESC
</select>
<!-- 根据类型查询课程列表 -->
<select id="selectByType" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_course
WHERE deleted = 0
ORDER BY order_num ASC, create_time DESC
</select>
<!-- 根据难度查询课程列表 -->
<select id="selectByDifficulty" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_course
WHERE deleted = 0
ORDER BY order_num ASC, create_time DESC
</select>
<!-- 查询热门课程列表 -->
<select id="selectHotCourses" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_course
WHERE status = 1 AND deleted = 0
ORDER BY view_count DESC, learn_count DESC, create_time DESC
<if test="limit != null and limit > 0">
LIMIT #{limit}
</if>
</select>
<!-- 查询最新课程列表 -->
<select id="selectLatestCourses" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_course
WHERE status = 1 AND deleted = 0
ORDER BY create_time DESC
<if test="limit != null and limit > 0">
LIMIT #{limit}
</if>
</select>
<!-- 根据关键词搜索课程 -->
<select id="searchByKeyword" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_course
WHERE (name LIKE CONCAT('%', #{keyword}, '%')
OR description LIKE CONCAT('%', #{keyword}, '%')
OR content LIKE CONCAT('%', #{keyword}, '%')
OR teacher LIKE CONCAT('%', #{keyword}, '%'))
AND status = 1 AND deleted = 0
ORDER BY order_num ASC, create_time DESC
</select>
<!-- 检查课程名称是否存在 -->
<select id="countByName" resultType="int">
SELECT COUNT(1)
FROM tb_course
WHERE name = #{name} AND deleted = 0
<if test="excludeId != null and excludeId != ''">
AND id != #{excludeId}
</if>
</select>
<!-- 插入课程 -->
<insert id="insertCourse" parameterType="org.xyzh.common.dto.study.TbCourse">
INSERT INTO tb_course (
id, course_id, name, cover_image, description, content, duration,
teacher, status, view_count, learn_count, order_num, creator, updater,
create_time, update_time, delete_time, deleted
) VALUES (
#{id}, #{courseID}, #{name}, #{coverImage}, #{description}, #{content}, #{duration},
#{teacher}, #{status}, #{viewCount}, #{learnCount}, #{orderNum}, #{creator}, #{updater},
#{createTime}, #{updateTime}, #{deleteTime}, #{deleted}
)
</insert>
<!-- 更新课程 -->
<update id="updateCourse" parameterType="org.xyzh.common.dto.study.TbCourse">
UPDATE tb_course
<set>
<if test="courseID != null and courseID != ''">
course_id = #{courseID},
</if>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="coverImage != null and coverImage != ''">
cover_image = #{coverImage},
</if>
<if test="description != null and description != ''">
description = #{description},
</if>
<if test="content != null and content != ''">
content = #{content},
</if>
<if test="duration != null">
duration = #{duration},
</if>
<if test="teacher != null and teacher != ''">
teacher = #{teacher},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="viewCount != null">
view_count = #{viewCount},
</if>
<if test="learnCount != null">
learn_count = #{learnCount},
</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="deleteCourse" parameterType="org.xyzh.common.dto.study.TbCourse">
DELETE FROM tb_course
WHERE id = #{id}
</delete>
<!-- 批量插入课程 -->
<insert id="batchInsertCourses" parameterType="java.util.List">
INSERT INTO tb_course (
id, course_id, name, cover_image, description, content, duration,
teacher, status, view_count, learn_count, order_num, creator, updater,
create_time, update_time, delete_time, deleted
) VALUES
<foreach collection="courseList" item="item" separator=",">
(
#{item.id}, #{item.courseID}, #{item.name}, #{item.coverImage}, #{item.description},
#{item.content}, #{item.duration}, #{item.teacher}, #{item.status}, #{item.viewCount},
#{item.learnCount}, #{item.orderNum}, #{item.creator}, #{item.updater},
#{item.createTime}, #{item.updateTime}, #{item.deleteTime}, #{item.deleted}
)
</foreach>
</insert>
<!-- 批量删除课程 -->
<delete id="batchDeleteCourses">
DELETE FROM tb_course
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 分页查询课程 -->
<select id="selectCoursesPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_course
<include refid="Where_Clause" />
ORDER BY order_num ASC, create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
</select>
<!-- 统计课程总数 -->
<select id="countCourses" resultType="long">
SELECT COUNT(1)
FROM tb_course
<include refid="Where_Clause" />
</select>
</mapper>

View File

@@ -37,4 +37,133 @@
ORDER BY create_time DESC
</select>
<!-- 根据关联ID查询关联信息 -->
<select id="selectByRelationId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_course_tag
WHERE id = #{relationId}
</select>
<!-- 根据课程ID查询标签关联列表 -->
<select id="selectByCourseId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_course_tag
WHERE course_id = #{courseId}
ORDER BY create_time DESC
</select>
<!-- 根据标签ID查询课程关联列表 -->
<select id="selectByTagId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_course_tag
WHERE tag_id = #{tagId}
ORDER BY create_time DESC
</select>
<!-- 根据课程ID和标签ID查询关联信息 -->
<select id="selectByCourseIdAndTagId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_course_tag
WHERE course_id = #{courseId} AND tag_id = #{tagId}
</select>
<!-- 检查课程标签关联是否存在 -->
<select id="countByCourseIdAndTagId" resultType="int">
SELECT COUNT(1)
FROM tb_course_tag
WHERE course_id = #{courseId} AND tag_id = #{tagId}
<if test="excludeId != null and excludeId != ''">
AND id != #{excludeId}
</if>
</select>
<!-- 插入课程标签关联 -->
<insert id="insertCourseTag" parameterType="org.xyzh.common.dto.study.TbCourseTag">
INSERT INTO tb_course_tag (
id, course_id, tag_id, creator, create_time
) VALUES (
#{id}, #{courseID}, #{tagID}, #{creator}, #{createTime}
)
</insert>
<!-- 更新课程标签关联 -->
<update id="updateCourseTag" parameterType="org.xyzh.common.dto.study.TbCourseTag">
UPDATE tb_course_tag
<set>
<if test="courseID != null and courseID != ''">
course_id = #{courseID},
</if>
<if test="tagID != null and tagID != ''">
tag_id = #{tagID},
</if>
<if test="creator != null and creator != ''">
creator = #{creator},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
</set>
WHERE id = #{id}
</update>
<!-- 删除课程标签关联 -->
<delete id="deleteCourseTag" parameterType="org.xyzh.common.dto.study.TbCourseTag">
DELETE FROM tb_course_tag
WHERE id = #{id}
</delete>
<!-- 批量插入课程标签关联 -->
<insert id="batchInsertCourseTags" parameterType="java.util.List">
INSERT INTO tb_course_tag (
id, course_id, tag_id, creator, create_time
) VALUES
<foreach collection="courseTagList" item="item" separator=",">
(
#{item.id}, #{item.courseID}, #{item.tagID}, #{item.creator}, #{item.createTime}
)
</foreach>
</insert>
<!-- 批量删除课程标签关联 -->
<delete id="batchDeleteCourseTags">
DELETE FROM tb_course_tag
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 根据课程ID批量删除标签关联 -->
<delete id="deleteByCourseId">
DELETE FROM tb_course_tag
WHERE course_id = #{courseId}
</delete>
<!-- 根据标签ID批量删除课程关联 -->
<delete id="deleteByTagId">
DELETE FROM tb_course_tag
WHERE tag_id = #{tagId}
</delete>
<!-- 分页查询课程标签关联 -->
<select id="selectCourseTagsPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_course_tag
<include refid="Where_Clause" />
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
</select>
<!-- 统计课程标签关联总数 -->
<select id="countCourseTags" resultType="long">
SELECT COUNT(1)
FROM tb_course_tag
<include refid="Where_Clause" />
</select>
</mapper>

View File

@@ -54,4 +54,156 @@
ORDER BY last_learn_time DESC, create_time DESC
</select>
<!-- 根据记录ID查询记录信息 -->
<select id="selectByRecordId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_record
WHERE id = #{recordId}
</select>
<!-- 根据用户ID查询学习记录列表 -->
<select id="selectByUserId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_record
WHERE user_id = #{userId}
ORDER BY last_learn_time DESC, create_time DESC
</select>
<!-- 根据课程ID查询学习记录列表 -->
<select id="selectByCourseId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_record
WHERE resource_id = #{courseId}
ORDER BY last_learn_time DESC, create_time DESC
</select>
<!-- 根据用户ID和课程ID查询学习记录 -->
<select id="selectByUserIdAndCourseId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_record
WHERE user_id = #{userId} AND resource_id = #{courseId}
</select>
<!-- 根据状态查询学习记录列表 -->
<select id="selectByStatus" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_record
WHERE is_complete = #{status}
ORDER BY last_learn_time DESC, create_time DESC
</select>
<!-- 查询用户学习统计信息 -->
<select id="selectLearningStatistics" resultMap="BaseResultMap">
SELECT
user_id,
COUNT(*) as total_records,
SUM(duration) as total_duration,
AVG(progress) as avg_progress,
COUNT(CASE WHEN is_complete = 1 THEN 1 END) as completed_count
FROM tb_learning_record
WHERE user_id = #{userId}
GROUP BY user_id
</select>
<!-- 插入学习记录 -->
<insert id="insertLearningRecord" parameterType="org.xyzh.common.dto.study.TbLearningRecord">
INSERT INTO tb_learning_record (
id, user_id, resource_type, resource_id, task_id, duration, progress,
is_complete, complete_time, last_learn_time, create_time, update_time
) VALUES (
#{id}, #{userID}, #{resourceType}, #{resourceID}, #{taskID}, #{duration}, #{progress},
#{isComplete}, #{completeTime}, #{lastLearnTime}, #{createTime}, #{updateTime}
)
</insert>
<!-- 更新学习记录 -->
<update id="updateLearningRecord" parameterType="org.xyzh.common.dto.study.TbLearningRecord">
UPDATE tb_learning_record
<set>
<if test="userID != null and userID != ''">
user_id = #{userID},
</if>
<if test="resourceType != null">
resource_type = #{resourceType},
</if>
<if test="resourceID != null and resourceID != ''">
resource_id = #{resourceID},
</if>
<if test="taskID != null and taskID != ''">
task_id = #{taskID},
</if>
<if test="duration != null">
duration = #{duration},
</if>
<if test="progress != null">
progress = #{progress},
</if>
<if test="isComplete != null">
is_complete = #{isComplete},
</if>
<if test="completeTime != null">
complete_time = #{completeTime},
</if>
<if test="lastLearnTime != null">
last_learn_time = #{lastLearnTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE id = #{id}
</update>
<!-- 删除学习记录 -->
<delete id="deleteLearningRecord" parameterType="org.xyzh.common.dto.study.TbLearningRecord">
DELETE FROM tb_learning_record
WHERE id = #{id}
</delete>
<!-- 批量插入学习记录 -->
<insert id="batchInsertLearningRecords" parameterType="java.util.List">
INSERT INTO tb_learning_record (
id, user_id, resource_type, resource_id, task_id, duration, progress,
is_complete, complete_time, last_learn_time, create_time, update_time
) VALUES
<foreach collection="learningRecordList" item="item" separator=",">
(
#{item.id}, #{item.userID}, #{item.resourceType}, #{item.resourceID}, #{item.taskID},
#{item.duration}, #{item.progress}, #{item.isComplete}, #{item.completeTime},
#{item.lastLearnTime}, #{item.createTime}, #{item.updateTime}
)
</foreach>
</insert>
<!-- 批量删除学习记录 -->
<delete id="batchDeleteLearningRecords">
DELETE FROM tb_learning_record
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 分页查询学习记录 -->
<select id="selectLearningRecordsPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_record
<include refid="Where_Clause" />
ORDER BY last_learn_time DESC, create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
</select>
<!-- 统计学习记录总数 -->
<select id="countLearningRecords" resultType="long">
SELECT COUNT(1)
FROM tb_learning_record
<include refid="Where_Clause" />
</select>
</mapper>

View File

@@ -42,4 +42,144 @@
ORDER BY stat_date DESC
</select>
<!-- 根据统计ID查询统计信息 -->
<select id="selectByStatisticsId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_statistics
WHERE id = #{statisticsId}
</select>
<!-- 根据用户ID查询学习统计 -->
<select id="selectByUserId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_statistics
WHERE user_id = #{userId}
ORDER BY stat_date DESC
</select>
<!-- 根据课程ID查询学习统计列表 -->
<select id="selectByCourseId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_statistics
ORDER BY stat_date DESC
</select>
<!-- 根据用户ID和课程ID查询学习统计 -->
<select id="selectByUserIdAndCourseId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_statistics
WHERE user_id = #{userId}
ORDER BY stat_date DESC
</select>
<!-- 根据统计类型查询学习统计列表 -->
<select id="selectByType" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_statistics
ORDER BY stat_date DESC
</select>
<!-- 查询用户学习排行榜 -->
<select id="selectLearningRanking" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_statistics
ORDER BY total_duration DESC, complete_count DESC, stat_date DESC
<if test="limit != null and limit > 0">
LIMIT #{limit}
</if>
</select>
<!-- 插入学习统计 -->
<insert id="insertLearningStatistics" parameterType="org.xyzh.common.dto.study.TbLearningStatistics">
INSERT INTO tb_learning_statistics (
id, user_id, stat_date, total_duration, resource_count, course_count,
complete_count, create_time, update_time
) VALUES (
#{id}, #{userID}, #{statDate}, #{totalDuration}, #{resourceCount}, #{courseCount},
#{completeCount}, #{createTime}, #{updateTime}
)
</insert>
<!-- 更新学习统计 -->
<update id="updateLearningStatistics" parameterType="org.xyzh.common.dto.study.TbLearningStatistics">
UPDATE tb_learning_statistics
<set>
<if test="userID != null and userID != ''">
user_id = #{userID},
</if>
<if test="statDate != null">
stat_date = #{statDate},
</if>
<if test="totalDuration != null">
total_duration = #{totalDuration},
</if>
<if test="resourceCount != null">
resource_count = #{resourceCount},
</if>
<if test="courseCount != null">
course_count = #{courseCount},
</if>
<if test="completeCount != null">
complete_count = #{completeCount},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE id = #{id}
</update>
<!-- 删除学习统计 -->
<delete id="deleteLearningStatistics" parameterType="org.xyzh.common.dto.study.TbLearningStatistics">
DELETE FROM tb_learning_statistics
WHERE id = #{id}
</delete>
<!-- 批量插入学习统计 -->
<insert id="batchInsertLearningStatistics" parameterType="java.util.List">
INSERT INTO tb_learning_statistics (
id, user_id, stat_date, total_duration, resource_count, course_count,
complete_count, create_time, update_time
) VALUES
<foreach collection="learningStatisticsList" item="item" separator=",">
(
#{item.id}, #{item.userID}, #{item.statDate}, #{item.totalDuration},
#{item.resourceCount}, #{item.courseCount}, #{item.completeCount},
#{item.createTime}, #{item.updateTime}
)
</foreach>
</insert>
<!-- 批量删除学习统计 -->
<delete id="batchDeleteLearningStatistics">
DELETE FROM tb_learning_statistics
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 分页查询学习统计 -->
<select id="selectLearningStatisticsPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_statistics
<include refid="Where_Clause" />
ORDER BY stat_date DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
</select>
<!-- 统计学习统计总数 -->
<select id="countLearningStatistics" resultType="long">
SELECT COUNT(1)
FROM tb_learning_statistics
<include refid="Where_Clause" />
</select>
</mapper>

View File

@@ -50,4 +50,171 @@
ORDER BY create_time DESC
</select>
<!-- 根据任务ID查询任务信息 -->
<select id="selectByTaskId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_task
WHERE task_id = #{taskId} AND deleted = 0
</select>
<!-- 根据用户ID查询学习任务列表 -->
<select id="selectByUserId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_task
WHERE deleted = 0
ORDER BY create_time DESC
</select>
<!-- 根据任务名称查询任务 -->
<select id="selectByName" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_task
WHERE name = #{name} AND deleted = 0
</select>
<!-- 根据状态查询学习任务列表 -->
<select id="selectByStatus" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_task
WHERE status = #{status} AND deleted = 0
ORDER BY create_time DESC
</select>
<!-- 根据优先级查询学习任务列表 -->
<select id="selectByPriority" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_task
WHERE deleted = 0
ORDER BY create_time DESC
</select>
<!-- 查询用户待完成任务列表 -->
<select id="selectPendingTasksByUserId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_task
WHERE status = 0 AND deleted = 0
ORDER BY create_time DESC
</select>
<!-- 查询用户已完成任务列表 -->
<select id="selectCompletedTasksByUserId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_task
WHERE status = 1 AND deleted = 0
ORDER BY create_time DESC
</select>
<!-- 检查任务名称是否存在 -->
<select id="countByName" resultType="int">
SELECT COUNT(1)
FROM tb_learning_task
WHERE name = #{name} AND deleted = 0
<if test="excludeId != null and excludeId != ''">
AND id != #{excludeId}
</if>
</select>
<!-- 插入学习任务 -->
<insert id="insertLearningTask" parameterType="org.xyzh.common.dto.study.TbLearningTask">
INSERT INTO tb_learning_task (
id, task_id, name, description, start_time, end_time, status,
creator, updater, create_time, update_time, delete_time, deleted
) VALUES (
#{id}, #{taskID}, #{name}, #{description}, #{startTime}, #{endTime}, #{status},
#{creator}, #{updater}, #{createTime}, #{updateTime}, #{deleteTime}, #{deleted}
)
</insert>
<!-- 更新学习任务 -->
<update id="updateLearningTask" parameterType="org.xyzh.common.dto.study.TbLearningTask">
UPDATE tb_learning_task
<set>
<if test="taskID != null and taskID != ''">
task_id = #{taskID},
</if>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="description != null and description != ''">
description = #{description},
</if>
<if test="startTime != null">
start_time = #{startTime},
</if>
<if test="endTime != null">
end_time = #{endTime},
</if>
<if test="status != null">
status = #{status},
</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="deleteLearningTask" parameterType="org.xyzh.common.dto.study.TbLearningTask">
DELETE FROM tb_learning_task
WHERE id = #{id}
</delete>
<!-- 批量插入学习任务 -->
<insert id="batchInsertLearningTasks" parameterType="java.util.List">
INSERT INTO tb_learning_task (
id, task_id, name, description, start_time, end_time, status,
creator, updater, create_time, update_time, delete_time, deleted
) VALUES
<foreach collection="learningTaskList" item="item" separator=",">
(
#{item.id}, #{item.taskID}, #{item.name}, #{item.description}, #{item.startTime},
#{item.endTime}, #{item.status}, #{item.creator}, #{item.updater},
#{item.createTime}, #{item.updateTime}, #{item.deleteTime}, #{item.deleted}
)
</foreach>
</insert>
<!-- 批量删除学习任务 -->
<delete id="batchDeleteLearningTasks">
DELETE FROM tb_learning_task
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 分页查询学习任务 -->
<select id="selectLearningTasksPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_learning_task
<include refid="Where_Clause" />
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
</select>
<!-- 统计学习任务总数 -->
<select id="countLearningTasks" resultType="long">
SELECT COUNT(1)
FROM tb_learning_task
<include refid="Where_Clause" />
</select>
</mapper>

View File

@@ -42,4 +42,140 @@
ORDER BY order_num ASC, create_time ASC
</select>
<!-- 根据关联ID查询关联信息 -->
<select id="selectByRelationId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_course
WHERE id = #{relationId}
</select>
<!-- 根据任务ID查询课程关联列表 -->
<select id="selectByTaskId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_course
WHERE task_id = #{taskId}
ORDER BY order_num ASC, create_time ASC
</select>
<!-- 根据课程ID查询任务关联列表 -->
<select id="selectByCourseId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_course
WHERE course_id = #{courseId}
ORDER BY order_num ASC, create_time ASC
</select>
<!-- 根据任务ID和课程ID查询关联信息 -->
<select id="selectByTaskIdAndCourseId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_course
WHERE task_id = #{taskId} AND course_id = #{courseId}
</select>
<!-- 检查任务课程关联是否存在 -->
<select id="countByTaskIdAndCourseId" resultType="int">
SELECT COUNT(1)
FROM tb_task_course
WHERE task_id = #{taskId} AND course_id = #{courseId}
<if test="excludeId != null and excludeId != ''">
AND id != #{excludeId}
</if>
</select>
<!-- 插入任务课程关联 -->
<insert id="insertTaskCourse" parameterType="org.xyzh.common.dto.study.TbTaskCourse">
INSERT INTO tb_task_course (
id, task_id, course_id, required, order_num, creator, create_time
) VALUES (
#{id}, #{taskID}, #{courseID}, #{required}, #{orderNum}, #{creator}, #{createTime}
)
</insert>
<!-- 更新任务课程关联 -->
<update id="updateTaskCourse" parameterType="org.xyzh.common.dto.study.TbTaskCourse">
UPDATE tb_task_course
<set>
<if test="taskID != null and taskID != ''">
task_id = #{taskID},
</if>
<if test="courseID != null and courseID != ''">
course_id = #{courseID},
</if>
<if test="required != null">
required = #{required},
</if>
<if test="orderNum != null">
order_num = #{orderNum},
</if>
<if test="creator != null and creator != ''">
creator = #{creator},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
</set>
WHERE id = #{id}
</update>
<!-- 删除任务课程关联 -->
<delete id="deleteTaskCourse" parameterType="org.xyzh.common.dto.study.TbTaskCourse">
DELETE FROM tb_task_course
WHERE id = #{id}
</delete>
<!-- 批量插入任务课程关联 -->
<insert id="batchInsertTaskCourses" parameterType="java.util.List">
INSERT INTO tb_task_course (
id, task_id, course_id, required, order_num, creator, create_time
) VALUES
<foreach collection="taskCourseList" item="item" separator=",">
(
#{item.id}, #{item.taskID}, #{item.courseID}, #{item.required},
#{item.orderNum}, #{item.creator}, #{item.createTime}
)
</foreach>
</insert>
<!-- 批量删除任务课程关联 -->
<delete id="batchDeleteTaskCourses">
DELETE FROM tb_task_course
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 根据任务ID批量删除课程关联 -->
<delete id="deleteByTaskId">
DELETE FROM tb_task_course
WHERE task_id = #{taskId}
</delete>
<!-- 根据课程ID批量删除任务关联 -->
<delete id="deleteByCourseId">
DELETE FROM tb_task_course
WHERE course_id = #{courseId}
</delete>
<!-- 分页查询任务课程关联 -->
<select id="selectTaskCoursesPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_course
<include refid="Where_Clause" />
ORDER BY order_num ASC, create_time ASC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
</select>
<!-- 统计任务课程关联总数 -->
<select id="countTaskCourses" resultType="long">
SELECT COUNT(1)
FROM tb_task_course
<include refid="Where_Clause" />
</select>
</mapper>

View File

@@ -42,4 +42,140 @@
ORDER BY order_num ASC, create_time ASC
</select>
<!-- 根据关联ID查询关联信息 -->
<select id="selectByRelationId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_resource
WHERE id = #{relationId}
</select>
<!-- 根据任务ID查询资源关联列表 -->
<select id="selectByTaskId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_resource
WHERE task_id = #{taskId}
ORDER BY order_num ASC, create_time ASC
</select>
<!-- 根据资源ID查询任务关联列表 -->
<select id="selectByResourceId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_resource
WHERE resource_id = #{resourceId}
ORDER BY order_num ASC, create_time ASC
</select>
<!-- 根据任务ID和资源ID查询关联信息 -->
<select id="selectByTaskIdAndResourceId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_resource
WHERE task_id = #{taskId} AND resource_id = #{resourceId}
</select>
<!-- 检查任务资源关联是否存在 -->
<select id="countByTaskIdAndResourceId" resultType="int">
SELECT COUNT(1)
FROM tb_task_resource
WHERE task_id = #{taskId} AND resource_id = #{resourceId}
<if test="excludeId != null and excludeId != ''">
AND id != #{excludeId}
</if>
</select>
<!-- 插入任务资源关联 -->
<insert id="insertTaskResource" parameterType="org.xyzh.common.dto.study.TbTaskResource">
INSERT INTO tb_task_resource (
id, task_id, resource_id, required, order_num, creator, create_time
) VALUES (
#{id}, #{taskID}, #{resourceID}, #{required}, #{orderNum}, #{creator}, #{createTime}
)
</insert>
<!-- 更新任务资源关联 -->
<update id="updateTaskResource" parameterType="org.xyzh.common.dto.study.TbTaskResource">
UPDATE tb_task_resource
<set>
<if test="taskID != null and taskID != ''">
task_id = #{taskID},
</if>
<if test="resourceID != null and resourceID != ''">
resource_id = #{resourceID},
</if>
<if test="required != null">
required = #{required},
</if>
<if test="orderNum != null">
order_num = #{orderNum},
</if>
<if test="creator != null and creator != ''">
creator = #{creator},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
</set>
WHERE id = #{id}
</update>
<!-- 删除任务资源关联 -->
<delete id="deleteTaskResource" parameterType="org.xyzh.common.dto.study.TbTaskResource">
DELETE FROM tb_task_resource
WHERE id = #{id}
</delete>
<!-- 批量插入任务资源关联 -->
<insert id="batchInsertTaskResources" parameterType="java.util.List">
INSERT INTO tb_task_resource (
id, task_id, resource_id, required, order_num, creator, create_time
) VALUES
<foreach collection="taskResourceList" item="item" separator=",">
(
#{item.id}, #{item.taskID}, #{item.resourceID}, #{item.required},
#{item.orderNum}, #{item.creator}, #{item.createTime}
)
</foreach>
</insert>
<!-- 批量删除任务资源关联 -->
<delete id="batchDeleteTaskResources">
DELETE FROM tb_task_resource
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 根据任务ID批量删除资源关联 -->
<delete id="deleteByTaskId">
DELETE FROM tb_task_resource
WHERE task_id = #{taskId}
</delete>
<!-- 根据资源ID批量删除任务关联 -->
<delete id="deleteByResourceId">
DELETE FROM tb_task_resource
WHERE resource_id = #{resourceId}
</delete>
<!-- 分页查询任务资源关联 -->
<select id="selectTaskResourcesPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_resource
<include refid="Where_Clause" />
ORDER BY order_num ASC, create_time ASC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
</select>
<!-- 统计任务资源关联总数 -->
<select id="countTaskResources" resultType="long">
SELECT COUNT(1)
FROM tb_task_resource
<include refid="Where_Clause" />
</select>
</mapper>

View File

@@ -49,4 +49,170 @@
ORDER BY create_time DESC
</select>
<!-- 根据关联ID查询关联信息 -->
<select id="selectByRelationId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_user
WHERE id = #{relationId}
</select>
<!-- 根据任务ID查询用户关联列表 -->
<select id="selectByTaskId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_user
WHERE task_id = #{taskId}
ORDER BY create_time DESC
</select>
<!-- 根据用户ID查询任务关联列表 -->
<select id="selectByUserId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_user
WHERE user_id = #{userId}
ORDER BY create_time DESC
</select>
<!-- 根据任务ID和用户ID查询关联信息 -->
<select id="selectByTaskIdAndUserId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_user
WHERE task_id = #{taskId} AND user_id = #{userId}
</select>
<!-- 根据状态查询任务用户关联列表 -->
<select id="selectByStatus" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_user
WHERE status = #{status}
ORDER BY create_time DESC
</select>
<!-- 根据用户ID和状态查询任务关联列表 -->
<select id="selectByUserIdAndStatus" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_user
WHERE user_id = #{userId} AND status = #{status}
ORDER BY create_time DESC
</select>
<!-- 检查任务用户关联是否存在 -->
<select id="countByTaskIdAndUserId" resultType="int">
SELECT COUNT(1)
FROM tb_task_user
WHERE task_id = #{taskId} AND user_id = #{userId}
<if test="excludeId != null and excludeId != ''">
AND id != #{excludeId}
</if>
</select>
<!-- 插入任务用户关联 -->
<insert id="insertTaskUser" parameterType="org.xyzh.common.dto.study.TbTaskUser">
INSERT INTO tb_task_user (
id, task_id, user_id, dept_id, status, progress, complete_time,
creator, create_time, update_time
) VALUES (
#{id}, #{taskID}, #{userID}, #{deptID}, #{status}, #{progress}, #{completeTime},
#{creator}, #{createTime}, #{updateTime}
)
</insert>
<!-- 更新任务用户关联 -->
<update id="updateTaskUser" parameterType="org.xyzh.common.dto.study.TbTaskUser">
UPDATE tb_task_user
<set>
<if test="taskID != null and taskID != ''">
task_id = #{taskID},
</if>
<if test="userID != null and userID != ''">
user_id = #{userID},
</if>
<if test="deptID != null and deptID != ''">
dept_id = #{deptID},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="progress != null">
progress = #{progress},
</if>
<if test="completeTime != null">
complete_time = #{completeTime},
</if>
<if test="creator != null and creator != ''">
creator = #{creator},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE id = #{id}
</update>
<!-- 删除任务用户关联 -->
<delete id="deleteTaskUser" parameterType="org.xyzh.common.dto.study.TbTaskUser">
DELETE FROM tb_task_user
WHERE id = #{id}
</delete>
<!-- 批量插入任务用户关联 -->
<insert id="batchInsertTaskUsers" parameterType="java.util.List">
INSERT INTO tb_task_user (
id, task_id, user_id, dept_id, status, progress, complete_time,
creator, create_time, update_time
) VALUES
<foreach collection="taskUserList" item="item" separator=",">
(
#{item.id}, #{item.taskID}, #{item.userID}, #{item.deptID}, #{item.status},
#{item.progress}, #{item.completeTime}, #{item.creator}, #{item.createTime}, #{item.updateTime}
)
</foreach>
</insert>
<!-- 批量删除任务用户关联 -->
<delete id="batchDeleteTaskUsers">
DELETE FROM tb_task_user
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 根据任务ID批量删除用户关联 -->
<delete id="deleteByTaskId">
DELETE FROM tb_task_user
WHERE task_id = #{taskId}
</delete>
<!-- 根据用户ID批量删除任务关联 -->
<delete id="deleteByUserId">
DELETE FROM tb_task_user
WHERE user_id = #{userId}
</delete>
<!-- 分页查询任务用户关联 -->
<select id="selectTaskUsersPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM tb_task_user
<include refid="Where_Clause" />
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
</select>
<!-- 统计任务用户关联总数 -->
<select id="countTaskUsers" resultType="long">
SELECT COUNT(1)
FROM tb_task_user
<include refid="Where_Clause" />
</select>
</mapper>