serv-学习
This commit is contained in:
@@ -21,12 +21,13 @@ CREATE TABLE `tb_learning_task` (
|
||||
KEY `idx_time` (`start_time`, `end_time`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='学习任务表';
|
||||
|
||||
-- 任务关联资源表
|
||||
DROP TABLE IF EXISTS `tb_task_resource`;
|
||||
CREATE TABLE `tb_task_resource` (
|
||||
-- 任务项关联表(统一管理资源和课程)
|
||||
DROP TABLE IF EXISTS `tb_task_item`;
|
||||
CREATE TABLE `tb_task_item` (
|
||||
`id` VARCHAR(50) NOT NULL COMMENT '关联ID',
|
||||
`task_id` VARCHAR(50) NOT NULL COMMENT '任务ID',
|
||||
`resource_id` VARCHAR(50) NOT NULL COMMENT '资源ID',
|
||||
`item_type` INT(4) NOT NULL COMMENT '项类型(1资源 2课程)',
|
||||
`item_id` VARCHAR(50) NOT NULL COMMENT '项ID(资源ID或课程ID)',
|
||||
`required` TINYINT(1) DEFAULT 1 COMMENT '是否必须完成',
|
||||
`order_num` INT(4) DEFAULT 0 COMMENT '排序号',
|
||||
`creator` VARCHAR(50) DEFAULT NULL COMMENT '创建者',
|
||||
@@ -36,30 +37,10 @@ CREATE TABLE `tb_task_resource` (
|
||||
`delete_time` TIMESTAMP NULL DEFAULT NULL COMMENT '删除时间',
|
||||
`deleted` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_task_resource` (`task_id`, `resource_id`),
|
||||
UNIQUE KEY `uk_task_item` (`task_id`, `item_type`, `item_id`),
|
||||
KEY `idx_task` (`task_id`),
|
||||
KEY `idx_resource` (`resource_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='任务资源关联表';
|
||||
|
||||
-- 任务关联课程表
|
||||
DROP TABLE IF EXISTS `tb_task_course`;
|
||||
CREATE TABLE `tb_task_course` (
|
||||
`id` VARCHAR(50) NOT NULL COMMENT '关联ID',
|
||||
`task_id` VARCHAR(50) NOT NULL COMMENT '任务ID',
|
||||
`course_id` VARCHAR(50) NOT NULL COMMENT '课程ID',
|
||||
`required` TINYINT(1) DEFAULT 1 COMMENT '是否必须完成',
|
||||
`order_num` INT(4) DEFAULT 0 COMMENT '排序号',
|
||||
`creator` VARCHAR(50) DEFAULT NULL COMMENT '创建者',
|
||||
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` VARCHAR(50) DEFAULT NULL COMMENT '更新者',
|
||||
`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`delete_time` TIMESTAMP NULL DEFAULT NULL COMMENT '删除时间',
|
||||
`deleted` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_task_course` (`task_id`, `course_id`),
|
||||
KEY `idx_task` (`task_id`),
|
||||
KEY `idx_course` (`course_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='任务课程关联表';
|
||||
KEY `idx_item` (`item_type`, `item_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='任务项关联表';
|
||||
|
||||
-- 任务接收人员表
|
||||
DROP TABLE IF EXISTS `tb_task_user`;
|
||||
@@ -89,9 +70,12 @@ DROP TABLE IF EXISTS `tb_learning_record`;
|
||||
CREATE TABLE `tb_learning_record` (
|
||||
`id` VARCHAR(50) NOT NULL COMMENT '记录ID',
|
||||
`user_id` VARCHAR(50) NOT NULL COMMENT '用户ID',
|
||||
`resource_type` INT(4) NOT NULL COMMENT '资源类型(1资源 2课程 3章节)',
|
||||
`resource_id` VARCHAR(50) NOT NULL COMMENT '资源ID',
|
||||
`task_id` VARCHAR(50) DEFAULT NULL COMMENT '任务ID',
|
||||
`resource_type` INT(4) NOT NULL COMMENT '资源类型(1资源 2课程 3章节)',
|
||||
`resource_id` VARCHAR(50) DEFAULT NULL COMMENT '资源ID',
|
||||
`course_id` VARCHAR(50) DEFAULT NULL COMMENT '课程ID',
|
||||
`chapter_id` VARCHAR(50) DEFAULT NULL COMMENT '章节ID',
|
||||
`node_id` VARCHAR(50) DEFAULT NULL COMMENT '节点ID',
|
||||
`duration` INT(11) DEFAULT 0 COMMENT '学习时长(秒)',
|
||||
`progress` DECIMAL(5,2) DEFAULT 0.00 COMMENT '学习进度(0-100)',
|
||||
`is_complete` TINYINT(1) DEFAULT 0 COMMENT '是否完成',
|
||||
|
||||
@@ -71,9 +71,9 @@ INSERT INTO `tb_sys_menu` (id, menu_id, name, parent_id, url, component, icon, o
|
||||
('300', 'menu_study_plan', '学习计划', NULL, '/study-plan', 'study-plan/StudyPlanView', 'el-icon-reading', 3, 1, 'NavigationLayout', '1', now()),
|
||||
('301', 'menu_study_tasks', '学习任务', 'menu_study_plan', '/study-plan/tasks', 'study-plan/StudyTasksView', 'el-icon-s-order', 1, 1, 'NavigationLayout', '1', now()),
|
||||
('302', 'menu_course_center', '课程中心', 'menu_study_plan', '/study-plan/course', 'study-plan/CourseCenterView', 'el-icon-video-play', 2, 1, 'NavigationLayout', '1', now()),
|
||||
('303', 'menu_task_detail', '任务详情', 'menu_study_plan', '/study-plan/task-detail', 'study-plan/LearningTaskDetailView', 'el-icon-document', 3, 3, 'BlankLayout', '1', now()),
|
||||
('304', 'menu_course_detail', '课程详情', 'menu_study_plan', '/study-plan/course-detail', 'study-plan/CourseDetailView', 'el-icon-video-play', 4, 3, 'BlankLayout', '1', now()),
|
||||
('305', 'menu_course_study', '课程学习', 'menu_study_plan', '/study-plan/course-study', 'study-plan/CourseStudyView', 'el-icon-video-play', 5, 3, 'BlankLayout', '1', now()),
|
||||
('303', 'menu_task_detail', '任务详情', 'menu_study_plan', '/study-plan/task-detail', 'study-plan/LearningTaskDetailView', 'el-icon-document', 3, 3, 'NavigationLayout', '1', now()),
|
||||
('304', 'menu_course_detail', '课程详情', 'menu_study_plan', '/study-plan/course-detail', 'study-plan/CourseDetailView', 'el-icon-video-play', 4, 3, 'NavigationLayout', '1', now()),
|
||||
('305', 'menu_course_study', '课程学习', 'menu_study_plan', '/study-plan/course-study', 'study-plan/CourseStudyView', 'el-icon-video-play', 5, 3, 'NavigationLayout', '1', now()),
|
||||
('400', 'menu_user_dropdown', '用户下拉菜单', NULL, '', '', 'el-icon-user', 4, 0, 'NavigationLayout', '1', now()),
|
||||
-- 个人中心
|
||||
('401', 'menu_user_center', '个人中心', 'menu_user_dropdown', '/user-center', 'user-center/UserCenterView', 'el-icon-user', 4, 1, 'NavigationLayout', '1', now()),
|
||||
|
||||
@@ -54,6 +54,11 @@
|
||||
<artifactId>usercenter</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>achievement</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>file</artifactId>
|
||||
|
||||
24
schoolNewsServ/api/api-achievement/pom.xml
Normal file
24
schoolNewsServ/api/api-achievement/pom.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>api-achievement</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>api-achievement</name>
|
||||
<description>成就模块API接口</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,184 @@
|
||||
package org.xyzh.api.achievement;
|
||||
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.core.event.AchievementEvent;
|
||||
import org.xyzh.common.core.page.PageDomain;
|
||||
import org.xyzh.common.core.page.PageParam;
|
||||
import org.xyzh.common.dto.usercenter.TbAchievement;
|
||||
import org.xyzh.common.dto.usercenter.TbUserAchievement;
|
||||
import org.xyzh.common.dto.usercenter.TbUserAchievementProgress;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @description 成就服务接口
|
||||
* @filename AchievementService.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
public interface AchievementService {
|
||||
|
||||
// ==================== 成就定义管理 ====================
|
||||
|
||||
/**
|
||||
* @description 创建成就
|
||||
* @param achievement 成就信息
|
||||
* @return ResultDomain<TbAchievement> 创建结果
|
||||
*/
|
||||
ResultDomain<TbAchievement> createAchievement(TbAchievement achievement);
|
||||
|
||||
/**
|
||||
* @description 更新成就
|
||||
* @param achievement 成就信息
|
||||
* @return ResultDomain<TbAchievement> 更新结果
|
||||
*/
|
||||
ResultDomain<TbAchievement> updateAchievement(TbAchievement achievement);
|
||||
|
||||
/**
|
||||
* @description 删除成就
|
||||
* @param achievementID 成就ID
|
||||
* @return ResultDomain<Void> 删除结果
|
||||
*/
|
||||
ResultDomain<Void> deleteAchievement(String achievementID);
|
||||
|
||||
/**
|
||||
* @description 获取所有成就列表
|
||||
* @param type 成就类型(可选)
|
||||
* @param level 成就等级(可选)
|
||||
* @return ResultDomain<TbAchievement> 成就列表
|
||||
*/
|
||||
ResultDomain<TbAchievement> getAllAchievements(Integer type, Integer level);
|
||||
|
||||
/**
|
||||
* @description 分页查询成就
|
||||
* @param filter 过滤条件
|
||||
* @param pageParam 分页参数
|
||||
* @return ResultDomain<TbAchievement> 成就分页数据
|
||||
*/
|
||||
ResultDomain<TbAchievement> getAchievementPage(TbAchievement filter, PageParam pageParam);
|
||||
|
||||
/**
|
||||
* @description 获取成就详情
|
||||
* @param achievementID 成就ID
|
||||
* @return ResultDomain<TbAchievement> 成就详情
|
||||
*/
|
||||
ResultDomain<TbAchievement> getAchievementDetail(String achievementID);
|
||||
|
||||
// ==================== 用户成就管理 ====================
|
||||
|
||||
/**
|
||||
* @description 获取用户已获得的成就
|
||||
* @param userID 用户ID
|
||||
* @param type 成就类型(可选)
|
||||
* @return ResultDomain<TbUserAchievement> 用户成就列表
|
||||
*/
|
||||
ResultDomain<TbUserAchievement> getUserAchievements(String userID, Integer type);
|
||||
|
||||
/**
|
||||
* @description 获取当前用户的成就列表
|
||||
* @param type 成就类型(可选)
|
||||
* @return ResultDomain<TbUserAchievement> 用户成就列表
|
||||
*/
|
||||
ResultDomain<TbUserAchievement> getMyAchievements(Integer type);
|
||||
|
||||
/**
|
||||
* @description 检查用户是否已获得成就
|
||||
* @param userID 用户ID
|
||||
* @param achievementID 成就ID
|
||||
* @return ResultDomain<Boolean> 是否已获得
|
||||
*/
|
||||
ResultDomain<Boolean> hasAchievement(String userID, String achievementID);
|
||||
|
||||
/**
|
||||
* @description 手动授予用户成就(管理员功能)
|
||||
* @param userID 用户ID
|
||||
* @param achievementID 成就ID
|
||||
* @return ResultDomain<TbUserAchievement> 授予结果
|
||||
*/
|
||||
ResultDomain<TbUserAchievement> grantAchievement(String userID, String achievementID);
|
||||
|
||||
/**
|
||||
* @description 撤销用户成就(管理员功能)
|
||||
* @param userID 用户ID
|
||||
* @param achievementID 成就ID
|
||||
* @return ResultDomain<Void> 撤销结果
|
||||
*/
|
||||
ResultDomain<Void> revokeAchievement(String userID, String achievementID);
|
||||
|
||||
// ==================== 成就进度管理 ====================
|
||||
|
||||
/**
|
||||
* @description 获取用户成就进度
|
||||
* @param userID 用户ID
|
||||
* @param achievementID 成就ID(可选,为空则获取所有进度)
|
||||
* @return ResultDomain<TbUserAchievementProgress> 成就进度列表
|
||||
*/
|
||||
ResultDomain<TbUserAchievementProgress> getUserAchievementProgress(String userID, String achievementID);
|
||||
|
||||
/**
|
||||
* @description 获取当前用户的成就进度
|
||||
* @param achievementID 成就ID(可选)
|
||||
* @return ResultDomain<TbUserAchievementProgress> 成就进度列表
|
||||
*/
|
||||
ResultDomain<TbUserAchievementProgress> getMyAchievementProgress(String achievementID);
|
||||
|
||||
/**
|
||||
* @description 更新用户成就进度
|
||||
* @param userID 用户ID
|
||||
* @param achievementID 成就ID
|
||||
* @param incrementValue 增量值
|
||||
* @return ResultDomain<TbUserAchievementProgress> 更新后的进度
|
||||
*/
|
||||
ResultDomain<TbUserAchievementProgress> updateProgress(String userID, String achievementID, Integer incrementValue);
|
||||
|
||||
// ==================== 成就检测与触发 ====================
|
||||
|
||||
/**
|
||||
* @description 处理成就事件(核心方法)
|
||||
* @param event 成就事件
|
||||
* @return ResultDomain<List<TbUserAchievement>> 本次触发的成就列表
|
||||
*/
|
||||
ResultDomain<List<TbUserAchievement>> processAchievementEvent(AchievementEvent event);
|
||||
|
||||
/**
|
||||
* @description 检查用户是否满足成就条件
|
||||
* @param userID 用户ID
|
||||
* @param achievementID 成就ID
|
||||
* @return ResultDomain<Boolean> 是否满足条件
|
||||
*/
|
||||
ResultDomain<Boolean> checkAchievementCondition(String userID, String achievementID);
|
||||
|
||||
/**
|
||||
* @description 批量检查用户可获得的成就
|
||||
* @param userID 用户ID
|
||||
* @return ResultDomain<List<TbAchievement>> 可获得的成就列表
|
||||
*/
|
||||
ResultDomain<List<TbAchievement>> checkAvailableAchievements(String userID);
|
||||
|
||||
// ==================== 成就统计 ====================
|
||||
|
||||
/**
|
||||
* @description 获取用户成就统计
|
||||
* @param userID 用户ID
|
||||
* @return ResultDomain<Map<String, Object>> 统计信息
|
||||
*/
|
||||
ResultDomain<Map<String, Object>> getUserAchievementStatistics(String userID);
|
||||
|
||||
/**
|
||||
* @description 获取成就排行榜
|
||||
* @param limit 排行榜条数
|
||||
* @return ResultDomain<Map<String, Object>> 排行榜数据
|
||||
*/
|
||||
ResultDomain<Map<String, Object>> getAchievementRanking(Integer limit);
|
||||
|
||||
/**
|
||||
* @description 获取最近获得成就的用户
|
||||
* @param achievementID 成就ID
|
||||
* @param limit 查询条数
|
||||
* @return ResultDomain<List<TbUserAchievement>> 用户成就列表
|
||||
*/
|
||||
ResultDomain<List<TbUserAchievement>> getRecentAchievers(String achievementID, Integer limit);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>api-auth</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>api-achievement</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
@@ -45,6 +49,9 @@
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>api-ai</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>api-file</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -106,7 +106,7 @@ public interface ResourceService {
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbResource> incrementViewCount(String resourceID);
|
||||
ResultDomain<Boolean> incrementViewCount(String resourceID);
|
||||
|
||||
/**
|
||||
* @description 增加点赞次数
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.xyzh.common.core.page.PageRequest;
|
||||
import org.xyzh.common.dto.study.TbCourse;
|
||||
import org.xyzh.common.dto.study.TbCourseChapter;
|
||||
import org.xyzh.common.dto.study.TbCourseNode;
|
||||
import org.xyzh.common.dto.study.TbLearningRecord;
|
||||
import org.xyzh.common.vo.CourseVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,12 +19,12 @@ public interface LearningRecordService {
|
||||
* @description 获取用户学习记录
|
||||
* @param userID 用户ID
|
||||
* @param resourceType 资源类型(可选)
|
||||
* @param taskID 任务ID(可选)
|
||||
* @param resourceID 资源ID(可选)
|
||||
* @return ResultDomain<TbLearningRecord> 学习记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbLearningRecord> getUserLearningRecords(String userID, Integer resourceType, String taskID);
|
||||
ResultDomain<TbLearningRecord> getLearningRecord(TbLearningRecord learningRecord);
|
||||
|
||||
/**
|
||||
* @description 获取资源学习记录
|
||||
@@ -34,7 +34,7 @@ public interface LearningRecordService {
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbLearningRecord> getResourceLearningRecords(Integer resourceType, String resourceID);
|
||||
ResultDomain<TbLearningRecord> getResourceLearningRecords(TbLearningRecord learningRecord);
|
||||
|
||||
/**
|
||||
* @description 创建或更新学习记录
|
||||
@@ -43,32 +43,25 @@ public interface LearningRecordService {
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbLearningRecord> saveLearningRecord(TbLearningRecord learningRecord);
|
||||
ResultDomain<TbLearningRecord> insertLearningRecord(TbLearningRecord learningRecord);
|
||||
|
||||
/**
|
||||
* @description 更新学习进度
|
||||
* @param userID 用户ID
|
||||
* @param resourceType 资源类型
|
||||
* @param resourceID 资源ID
|
||||
* @param progress 进度
|
||||
* @param duration 学习时长(秒)
|
||||
* @param learningRecord 学习记录
|
||||
* @return ResultDomain<TbLearningRecord> 更新结果
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbLearningRecord> updateLearningProgress(String userID, Integer resourceType, String resourceID, BigDecimal progress, Integer duration);
|
||||
ResultDomain<TbLearningRecord> updateLearningRecord(TbLearningRecord learningRecord);
|
||||
|
||||
/**
|
||||
* @description 标记学习完成
|
||||
* @param userID 用户ID
|
||||
* @param resourceType 资源类型
|
||||
* @param resourceID 资源ID
|
||||
* @param taskID 任务ID(可选)
|
||||
* @param learningRecord 学习记录
|
||||
* @return ResultDomain<TbLearningRecord> 更新结果
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbLearningRecord> markLearningComplete(String userID, Integer resourceType, String resourceID, String taskID);
|
||||
ResultDomain<TbLearningRecord> markLearningComplete(TbLearningRecord learningRecord);
|
||||
|
||||
/**
|
||||
* @description 获取用户学习统计
|
||||
@@ -108,4 +101,13 @@ public interface LearningRecordService {
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbLearningRecord> getTaskLearningStatistics(String taskID);
|
||||
|
||||
/**
|
||||
* @description 获取用户课程的学习记录
|
||||
* @param learningRecord 学习记录
|
||||
* @return ResultDomain<TbLearningRecord> 学习记录
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
ResultDomain<TbLearningRecord> getCourseLearningRecord(TbLearningRecord learningRecord);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@ import org.xyzh.common.dto.study.TbLearningTask;
|
||||
import org.xyzh.common.dto.study.TbTaskUser;
|
||||
import org.xyzh.common.vo.TaskItemVO;
|
||||
import org.xyzh.common.vo.TaskVO;
|
||||
import org.xyzh.common.dto.study.TbTaskCourse;
|
||||
import org.xyzh.common.dto.study.TbTaskResource;
|
||||
import org.xyzh.common.dto.study.TbTaskItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -48,6 +47,15 @@ public interface LearningTaskService {
|
||||
*/
|
||||
ResultDomain<TaskVO> getTaskById(String taskID);
|
||||
|
||||
/**
|
||||
* @description 根据ID获取任务用户详情
|
||||
* @param taskID 任务ID
|
||||
* @return ResultDomain<TaskItemVO> 任务用户详情
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TaskVO> getTaskUser(String taskID);
|
||||
|
||||
/**
|
||||
* @description 创建学习任务
|
||||
* @param task 任务信息
|
||||
@@ -154,20 +162,20 @@ public interface LearningTaskService {
|
||||
/**
|
||||
* @description 获取任务课程列表
|
||||
* @param taskID 任务ID
|
||||
* @return ResultDomain<TbTaskCourse> 课程列表
|
||||
* @return ResultDomain<TbTaskItem> 课程列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbTaskCourse> getTaskCourses(String taskID);
|
||||
ResultDomain<TbTaskItem> getTaskCourses(String taskID);
|
||||
|
||||
/**
|
||||
* @description 添加任务课程
|
||||
* @param taskCourse 任务课程信息
|
||||
* @return ResultDomain<TbTaskCourse> 添加结果
|
||||
* @param taskItem 任务项信息
|
||||
* @return ResultDomain<TbTaskItem> 添加结果
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbTaskCourse> addTaskCourse(TbTaskCourse taskCourse);
|
||||
ResultDomain<TbTaskItem> addTaskCourse(TbTaskItem taskItem);
|
||||
|
||||
/**
|
||||
* @description 移除任务课程
|
||||
@@ -184,20 +192,20 @@ public interface LearningTaskService {
|
||||
/**
|
||||
* @description 获取任务资源列表
|
||||
* @param taskID 任务ID
|
||||
* @return ResultDomain<TbTaskResource> 资源列表
|
||||
* @return ResultDomain<TbTaskItem> 资源列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbTaskResource> getTaskResources(String taskID);
|
||||
ResultDomain<TbTaskItem> getTaskResources(String taskID);
|
||||
|
||||
/**
|
||||
* @description 添加任务资源
|
||||
* @param taskResource 任务资源信息
|
||||
* @return ResultDomain<TbTaskResource> 添加结果
|
||||
* @param taskItem 任务项信息
|
||||
* @return ResultDomain<TbTaskItem> 添加结果
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbTaskResource> addTaskResource(TbTaskResource taskResource);
|
||||
ResultDomain<TbTaskItem> addTaskResource(TbTaskItem taskItem);
|
||||
|
||||
/**
|
||||
* @description 移除任务资源
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
package org.xyzh.api.usercenter.achievement;
|
||||
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.dto.usercenter.TbAchievement;
|
||||
import org.xyzh.common.dto.usercenter.TbUserAchievement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description 用户成就服务接口
|
||||
* @filename UserAchievementService.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
public interface UserAchievementService {
|
||||
|
||||
/**
|
||||
* @description 获取所有成就列表
|
||||
* @param type 成就类型(可选)
|
||||
* @param level 成就等级(可选)
|
||||
* @return ResultDomain<TbAchievement> 成就列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbAchievement> getAllAchievements(Integer type, Integer level);
|
||||
|
||||
/**
|
||||
* @description 获取用户已获得的成就
|
||||
* @param userID 用户ID
|
||||
* @param type 成就类型(可选)
|
||||
* @return ResultDomain<TbUserAchievement> 用户成就列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbUserAchievement> getUserAchievements(String userID, Integer type);
|
||||
|
||||
/**
|
||||
* @description 检查用户是否已获得成就
|
||||
* @param userID 用户ID
|
||||
* @param achievementID 成就ID
|
||||
* @return ResultDomain<Boolean> 是否已获得
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<Boolean> hasAchievement(String userID, String achievementID);
|
||||
|
||||
/**
|
||||
* @description 授予用户成就
|
||||
* @param userID 用户ID
|
||||
* @param achievementID 成就ID
|
||||
* @return ResultDomain<TbUserAchievement> 授予结果
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbUserAchievement> grantAchievement(String userID, String achievementID);
|
||||
|
||||
/**
|
||||
* @description 获取成就详情
|
||||
* @param achievementID 成就ID
|
||||
* @return ResultDomain<TbAchievement> 成就详情
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<TbAchievement> getAchievementDetail(String achievementID);
|
||||
|
||||
/**
|
||||
* @description 检查用户是否满足成就条件
|
||||
* @param userID 用户ID
|
||||
* @param achievementID 成就ID
|
||||
* @return ResultDomain<Boolean> 是否满足条件
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<Boolean> checkAchievementCondition(String userID, String achievementID);
|
||||
}
|
||||
@@ -23,14 +23,12 @@ public interface UserCollectionService {
|
||||
|
||||
/**
|
||||
* @description 取消收藏
|
||||
* @param userID 用户ID
|
||||
* @param collectionType 收藏类型
|
||||
* @param collectionID 收藏对象ID
|
||||
* @param userCollection 收藏信息
|
||||
* @return ResultDomain<Boolean> 取消结果
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
ResultDomain<Boolean> removeCollection(String userID, Integer collectionType, String collectionID);
|
||||
ResultDomain<Boolean> removeCollection(TbUserCollection userCollection);
|
||||
|
||||
/**
|
||||
* @description 检查是否已收藏
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<module>api-auth</module>
|
||||
<module>api-system</module>
|
||||
<module>api-usercenter</module>
|
||||
<module>api-achievement</module>
|
||||
<module>api-ai</module>
|
||||
<module>api-study</module>
|
||||
<module>api-news</module>
|
||||
@@ -61,6 +62,11 @@
|
||||
<artifactId>api-usercenter</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>api-achievement</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>api-ai</artifactId>
|
||||
@@ -71,7 +77,11 @@
|
||||
<artifactId>api-news</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>api-file</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package org.xyzh.common.core.enums;
|
||||
|
||||
/**
|
||||
* @description 成就条件类型枚举
|
||||
* @filename AchievementConditionType.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
public enum AchievementConditionType {
|
||||
|
||||
/**
|
||||
* 1-学习时长(分钟)
|
||||
*/
|
||||
LEARNING_TIME(1, "学习时长"),
|
||||
|
||||
/**
|
||||
* 2-浏览资源数量
|
||||
*/
|
||||
RESOURCE_VIEW_COUNT(2, "浏览资源数量"),
|
||||
|
||||
/**
|
||||
* 3-完成课程数量
|
||||
*/
|
||||
COURSE_COMPLETE_COUNT(3, "完成课程数量"),
|
||||
|
||||
/**
|
||||
* 4-连续登录天数
|
||||
*/
|
||||
CONTINUOUS_LOGIN_DAYS(4, "连续登录天数"),
|
||||
|
||||
/**
|
||||
* 5-收藏资源数量
|
||||
*/
|
||||
RESOURCE_COLLECT_COUNT(5, "收藏资源数量"),
|
||||
|
||||
/**
|
||||
* 6-完成任务数量
|
||||
*/
|
||||
TASK_COMPLETE_COUNT(6, "完成任务数量"),
|
||||
|
||||
/**
|
||||
* 7-获得积分数量
|
||||
*/
|
||||
POINTS_EARNED(7, "获得积分数量"),
|
||||
|
||||
/**
|
||||
* 8-发表评论数量
|
||||
*/
|
||||
COMMENT_COUNT(8, "发表评论数量"),
|
||||
|
||||
/**
|
||||
* 9-完成章节数量
|
||||
*/
|
||||
CHAPTER_COMPLETE_COUNT(9, "完成章节数量"),
|
||||
|
||||
/**
|
||||
* 10-累计登录天数
|
||||
*/
|
||||
TOTAL_LOGIN_DAYS(10, "累计登录天数");
|
||||
|
||||
private final int code;
|
||||
private final String description;
|
||||
|
||||
AchievementConditionType(int code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取条件类型
|
||||
*/
|
||||
public static AchievementConditionType fromCode(int code) {
|
||||
for (AchievementConditionType type : values()) {
|
||||
if (type.code == code) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package org.xyzh.common.core.enums;
|
||||
|
||||
/**
|
||||
* @description 成就事件类型枚举
|
||||
* @filename AchievementEventType.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
public enum AchievementEventType {
|
||||
|
||||
/**
|
||||
* 学习相关事件
|
||||
*/
|
||||
LEARNING_TIME_UPDATED("learning_time_updated", "学习时长更新"),
|
||||
COURSE_COMPLETED("course_completed", "课程完成"),
|
||||
COURSE_STARTED("course_started", "开始学习课程"),
|
||||
CHAPTER_COMPLETED("chapter_completed", "章节完成"),
|
||||
|
||||
/**
|
||||
* 资源相关事件
|
||||
*/
|
||||
RESOURCE_VIEWED("resource_viewed", "浏览资源"),
|
||||
RESOURCE_COLLECTED("resource_collected", "收藏资源"),
|
||||
RESOURCE_SHARED("resource_shared", "分享资源"),
|
||||
|
||||
/**
|
||||
* 任务相关事件
|
||||
*/
|
||||
TASK_COMPLETED("task_completed", "任务完成"),
|
||||
TASK_ITEM_COMPLETED("task_item_completed", "任务项完成"),
|
||||
|
||||
/**
|
||||
* 互动相关事件
|
||||
*/
|
||||
COMMENT_POSTED("comment_posted", "发表评论"),
|
||||
LIKE_GIVEN("like_given", "点赞"),
|
||||
|
||||
/**
|
||||
* 登录相关事件
|
||||
*/
|
||||
USER_LOGIN("user_login", "用户登录"),
|
||||
CONTINUOUS_LOGIN("continuous_login", "连续登录"),
|
||||
|
||||
/**
|
||||
* 积分相关事件
|
||||
*/
|
||||
POINTS_EARNED("points_earned", "获得积分"),
|
||||
|
||||
/**
|
||||
* 测试相关事件
|
||||
*/
|
||||
TEST_PASSED("test_passed", "测试通过"),
|
||||
TEST_PERFECT_SCORE("test_perfect_score", "测试满分");
|
||||
|
||||
private final String code;
|
||||
private final String description;
|
||||
|
||||
AchievementEventType(String code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取事件类型
|
||||
*/
|
||||
public static AchievementEventType fromCode(String code) {
|
||||
for (AchievementEventType type : values()) {
|
||||
if (type.code.equals(code)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.xyzh.common.core.enums;
|
||||
|
||||
/**
|
||||
* @description 任务项类型常量
|
||||
* @filename TaskItemType.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
public enum TaskItemType {
|
||||
|
||||
/**
|
||||
* 资源类型
|
||||
*/
|
||||
RESOURCE(1),
|
||||
|
||||
/**
|
||||
* 课程类型
|
||||
*/
|
||||
COURSE(2);
|
||||
|
||||
private int value;
|
||||
|
||||
TaskItemType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package org.xyzh.common.core.event;
|
||||
|
||||
import org.xyzh.common.core.enums.AchievementEventType;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @description 成就事件数据类
|
||||
* @filename AchievementEvent.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
public class AchievementEvent {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String userID;
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
private AchievementEventType eventType;
|
||||
|
||||
/**
|
||||
* 事件值(如学习时长、资源数量等)
|
||||
*/
|
||||
private Integer eventValue;
|
||||
|
||||
/**
|
||||
* 事件时间
|
||||
*/
|
||||
private Date eventTime;
|
||||
|
||||
/**
|
||||
* 额外数据
|
||||
*/
|
||||
private Map<String, Object> extraData;
|
||||
|
||||
public AchievementEvent() {
|
||||
this.eventTime = new Date();
|
||||
this.extraData = new HashMap<>();
|
||||
}
|
||||
|
||||
public AchievementEvent(String userID, AchievementEventType eventType, Integer eventValue) {
|
||||
this.userID = userID;
|
||||
this.eventType = eventType;
|
||||
this.eventValue = eventValue;
|
||||
this.eventTime = new Date();
|
||||
this.extraData = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建器模式
|
||||
*/
|
||||
public static class Builder {
|
||||
private final AchievementEvent event;
|
||||
|
||||
public Builder(String userID, AchievementEventType eventType) {
|
||||
event = new AchievementEvent();
|
||||
event.userID = userID;
|
||||
event.eventType = eventType;
|
||||
}
|
||||
|
||||
public Builder value(Integer value) {
|
||||
event.eventValue = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder extra(String key, Object value) {
|
||||
event.extraData.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder time(Date time) {
|
||||
event.eventTime = time;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AchievementEvent build() {
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
||||
public static Builder builder(String userID, AchievementEventType eventType) {
|
||||
return new Builder(userID, eventType);
|
||||
}
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public AchievementEventType getEventType() {
|
||||
return eventType;
|
||||
}
|
||||
|
||||
public void setEventType(AchievementEventType eventType) {
|
||||
this.eventType = eventType;
|
||||
}
|
||||
|
||||
public Integer getEventValue() {
|
||||
return eventValue;
|
||||
}
|
||||
|
||||
public void setEventValue(Integer eventValue) {
|
||||
this.eventValue = eventValue;
|
||||
}
|
||||
|
||||
public Date getEventTime() {
|
||||
return eventTime;
|
||||
}
|
||||
|
||||
public void setEventTime(Date eventTime) {
|
||||
this.eventTime = eventTime;
|
||||
}
|
||||
|
||||
public Map<String, Object> getExtraData() {
|
||||
return extraData;
|
||||
}
|
||||
|
||||
public void setExtraData(Map<String, Object> extraData) {
|
||||
this.extraData = extraData;
|
||||
}
|
||||
|
||||
public Object getExtraData(String key) {
|
||||
return extraData.get(key);
|
||||
}
|
||||
|
||||
public void putExtraData(String key, Object value) {
|
||||
this.extraData.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AchievementEvent{" +
|
||||
"userID='" + userID + '\'' +
|
||||
", eventType=" + eventType +
|
||||
", eventValue=" + eventValue +
|
||||
", eventTime=" + eventTime +
|
||||
", extraData=" + extraData +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@ public class TbLearningRecord extends BaseDTO {
|
||||
* @description 用户ID
|
||||
*/
|
||||
private String userID;
|
||||
|
||||
/**
|
||||
* @description 任务ID
|
||||
*/
|
||||
private String taskID;
|
||||
|
||||
/**
|
||||
* @description 资源类型(1资源 2课程 3章节)
|
||||
@@ -29,11 +34,21 @@ public class TbLearningRecord extends BaseDTO {
|
||||
* @description 资源ID
|
||||
*/
|
||||
private String resourceID;
|
||||
|
||||
|
||||
/**
|
||||
* @description 任务ID
|
||||
* @description 课程ID
|
||||
*/
|
||||
private String taskID;
|
||||
private String courseID;
|
||||
|
||||
/**
|
||||
* @description 章节ID
|
||||
*/
|
||||
private String chapterID;
|
||||
|
||||
/**
|
||||
* @description 节点ID
|
||||
*/
|
||||
private String nodeID;
|
||||
|
||||
/**
|
||||
* @description 学习时长(秒)
|
||||
@@ -79,11 +94,6 @@ public class TbLearningRecord extends BaseDTO {
|
||||
* @description 删除时间
|
||||
*/
|
||||
private Date deleteTime;
|
||||
|
||||
/**
|
||||
* @description 是否删除
|
||||
*/
|
||||
private Boolean deleted;
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
@@ -93,6 +103,14 @@ public class TbLearningRecord extends BaseDTO {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getTaskID() {
|
||||
return taskID;
|
||||
}
|
||||
|
||||
public void setTaskID(String taskID) {
|
||||
this.taskID = taskID;
|
||||
}
|
||||
|
||||
public Integer getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
@@ -109,12 +127,30 @@ public class TbLearningRecord extends BaseDTO {
|
||||
this.resourceID = resourceID;
|
||||
}
|
||||
|
||||
public String getTaskID() {
|
||||
return taskID;
|
||||
|
||||
|
||||
public String getCourseID() {
|
||||
return courseID;
|
||||
}
|
||||
|
||||
public void setTaskID(String taskID) {
|
||||
this.taskID = taskID;
|
||||
public void setCourseID(String courseID) {
|
||||
this.courseID = courseID;
|
||||
}
|
||||
|
||||
public String getChapterID() {
|
||||
return chapterID;
|
||||
}
|
||||
|
||||
public void setChapterID(String chapterID) {
|
||||
this.chapterID = chapterID;
|
||||
}
|
||||
|
||||
public String getNodeID() {
|
||||
return nodeID;
|
||||
}
|
||||
|
||||
public void setNodeID(String nodeID) {
|
||||
this.nodeID = nodeID;
|
||||
}
|
||||
|
||||
public Integer getDuration() {
|
||||
@@ -194,9 +230,12 @@ public class TbLearningRecord extends BaseDTO {
|
||||
return "TbLearningRecord{" +
|
||||
"id=" + getID() +
|
||||
", userID='" + userID + '\'' +
|
||||
", taskID='" + taskID + '\'' +
|
||||
", resourceType=" + resourceType +
|
||||
", resourceID='" + resourceID + '\'' +
|
||||
", taskID='" + taskID + '\'' +
|
||||
", courseID='" + courseID + '\'' +
|
||||
", chapterID='" + chapterID + '\'' +
|
||||
", nodeID='" + nodeID + '\'' +
|
||||
", duration=" + duration +
|
||||
", progress=" + progress +
|
||||
", isComplete=" + isComplete +
|
||||
|
||||
@@ -4,13 +4,13 @@ import org.xyzh.common.dto.BaseDTO;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @description 任务课程关联表
|
||||
* @filename TbTaskCourse.java
|
||||
* @description 任务项关联表(统一管理资源和课程)
|
||||
* @filename TbTaskItem.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
public class TbTaskCourse extends BaseDTO {
|
||||
public class TbTaskItem extends BaseDTO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -20,9 +20,14 @@ public class TbTaskCourse extends BaseDTO {
|
||||
private String taskID;
|
||||
|
||||
/**
|
||||
* @description 课程ID
|
||||
* @description 项类型(1资源 2课程)
|
||||
*/
|
||||
private String courseID;
|
||||
private Integer itemType;
|
||||
|
||||
/**
|
||||
* @description 项ID(资源ID或课程ID)
|
||||
*/
|
||||
private String itemID;
|
||||
|
||||
/**
|
||||
* @description 是否必须完成
|
||||
@@ -43,21 +48,8 @@ public class TbTaskCourse extends BaseDTO {
|
||||
* @description 更新者
|
||||
*/
|
||||
private String updater;
|
||||
|
||||
|
||||
/**
|
||||
* @description 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* @description 删除时间
|
||||
*/
|
||||
private Date deleteTime;
|
||||
|
||||
/**
|
||||
* @description 是否删除
|
||||
*/
|
||||
private Boolean deleted;
|
||||
|
||||
public String getTaskID() {
|
||||
return taskID;
|
||||
@@ -67,12 +59,20 @@ public class TbTaskCourse extends BaseDTO {
|
||||
this.taskID = taskID;
|
||||
}
|
||||
|
||||
public String getCourseID() {
|
||||
return courseID;
|
||||
public Integer getItemType() {
|
||||
return itemType;
|
||||
}
|
||||
|
||||
public void setCourseID(String courseID) {
|
||||
this.courseID = courseID;
|
||||
public void setItemType(Integer itemType) {
|
||||
this.itemType = itemType;
|
||||
}
|
||||
|
||||
public String getItemID() {
|
||||
return itemID;
|
||||
}
|
||||
|
||||
public void setItemID(String itemID) {
|
||||
this.itemID = itemID;
|
||||
}
|
||||
|
||||
public Boolean getRequired() {
|
||||
@@ -107,31 +107,18 @@ public class TbTaskCourse extends BaseDTO {
|
||||
this.updater = updater;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Date getDeleteTime() {
|
||||
return deleteTime;
|
||||
}
|
||||
|
||||
public void setDeleteTime(Date deleteTime) {
|
||||
this.deleteTime = deleteTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TbTaskCourse{" +
|
||||
return "TbTaskItem{" +
|
||||
"id=" + getID() +
|
||||
", taskID='" + taskID + '\'' +
|
||||
", courseID='" + courseID + '\'' +
|
||||
", itemType=" + itemType +
|
||||
", itemID='" + itemID + '\'' +
|
||||
", required=" + required +
|
||||
", orderNum=" + orderNum +
|
||||
", createTime=" + getCreateTime() +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
package org.xyzh.common.dto.study;
|
||||
|
||||
import org.xyzh.common.dto.BaseDTO;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @description 任务资源关联表
|
||||
* @filename TbTaskResource.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
public class TbTaskResource extends BaseDTO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @description 任务ID
|
||||
*/
|
||||
private String taskID;
|
||||
|
||||
/**
|
||||
* @description 资源ID
|
||||
*/
|
||||
private String resourceID;
|
||||
|
||||
/**
|
||||
* @description 是否必须完成
|
||||
*/
|
||||
private Boolean required;
|
||||
|
||||
/**
|
||||
* @description 排序号
|
||||
*/
|
||||
private Integer orderNum;
|
||||
|
||||
/**
|
||||
* @description 创建者
|
||||
*/
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* @description 更新者
|
||||
*/
|
||||
private String updater;
|
||||
|
||||
/**
|
||||
* @description 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* @description 删除时间
|
||||
*/
|
||||
private Date deleteTime;
|
||||
|
||||
/**
|
||||
* @description 是否删除
|
||||
*/
|
||||
private Boolean deleted;
|
||||
|
||||
public String getTaskID() {
|
||||
return taskID;
|
||||
}
|
||||
|
||||
public void setTaskID(String taskID) {
|
||||
this.taskID = taskID;
|
||||
}
|
||||
|
||||
public String getResourceID() {
|
||||
return resourceID;
|
||||
}
|
||||
|
||||
public void setResourceID(String resourceID) {
|
||||
this.resourceID = resourceID;
|
||||
}
|
||||
|
||||
public Boolean getRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
public void setRequired(Boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public void setOrderNum(Integer orderNum) {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public String getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator(String creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public String getUpdater() {
|
||||
return updater;
|
||||
}
|
||||
|
||||
public void setUpdater(String updater) {
|
||||
this.updater = updater;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Date getDeleteTime() {
|
||||
return deleteTime;
|
||||
}
|
||||
|
||||
public void setDeleteTime(Date deleteTime) {
|
||||
this.deleteTime = deleteTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TbTaskResource{" +
|
||||
"id=" + getID() +
|
||||
", taskID='" + taskID + '\'' +
|
||||
", resourceID='" + resourceID + '\'' +
|
||||
", required=" + required +
|
||||
", orderNum=" + orderNum +
|
||||
", createTime=" + getCreateTime() +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package org.xyzh.common.dto.usercenter;
|
||||
|
||||
import org.xyzh.common.dto.BaseDTO;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @description 用户成就进度表 - 追踪用户朝向成就的进度
|
||||
* @filename TbUserAchievementProgress.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
public class TbUserAchievementProgress extends BaseDTO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @description 用户ID
|
||||
*/
|
||||
private String userID;
|
||||
|
||||
/**
|
||||
* @description 成就ID
|
||||
*/
|
||||
private String achievementID;
|
||||
|
||||
/**
|
||||
* @description 当前进度值
|
||||
*/
|
||||
private Integer currentValue;
|
||||
|
||||
/**
|
||||
* @description 目标进度值(冗余字段,方便查询)
|
||||
*/
|
||||
private Integer targetValue;
|
||||
|
||||
/**
|
||||
* @description 进度百分比 (0-100)
|
||||
*/
|
||||
private Integer progressPercentage;
|
||||
|
||||
/**
|
||||
* @description 是否已完成
|
||||
*/
|
||||
private Boolean completed;
|
||||
|
||||
/**
|
||||
* @description 最后更新时间
|
||||
*/
|
||||
private Date lastUpdateTime;
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getAchievementID() {
|
||||
return achievementID;
|
||||
}
|
||||
|
||||
public void setAchievementID(String achievementID) {
|
||||
this.achievementID = achievementID;
|
||||
}
|
||||
|
||||
public Integer getCurrentValue() {
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
public void setCurrentValue(Integer currentValue) {
|
||||
this.currentValue = currentValue;
|
||||
updateProgressPercentage();
|
||||
}
|
||||
|
||||
public Integer getTargetValue() {
|
||||
return targetValue;
|
||||
}
|
||||
|
||||
public void setTargetValue(Integer targetValue) {
|
||||
this.targetValue = targetValue;
|
||||
updateProgressPercentage();
|
||||
}
|
||||
|
||||
public Integer getProgressPercentage() {
|
||||
return progressPercentage;
|
||||
}
|
||||
|
||||
public void setProgressPercentage(Integer progressPercentage) {
|
||||
this.progressPercentage = progressPercentage;
|
||||
}
|
||||
|
||||
public Boolean getCompleted() {
|
||||
return completed;
|
||||
}
|
||||
|
||||
public void setCompleted(Boolean completed) {
|
||||
this.completed = completed;
|
||||
}
|
||||
|
||||
public Date getLastUpdateTime() {
|
||||
return lastUpdateTime;
|
||||
}
|
||||
|
||||
public void setLastUpdateTime(Date lastUpdateTime) {
|
||||
this.lastUpdateTime = lastUpdateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新进度百分比
|
||||
*/
|
||||
private void updateProgressPercentage() {
|
||||
if (currentValue != null && targetValue != null && targetValue > 0) {
|
||||
this.progressPercentage = Math.min(100, (int) ((currentValue * 100.0) / targetValue));
|
||||
this.completed = currentValue >= targetValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TbUserAchievementProgress{" +
|
||||
"id=" + getID() +
|
||||
", userID='" + userID + '\'' +
|
||||
", achievementID='" + achievementID + '\'' +
|
||||
", currentValue=" + currentValue +
|
||||
", targetValue=" + targetValue +
|
||||
", progressPercentage=" + progressPercentage +
|
||||
", completed=" + completed +
|
||||
", lastUpdateTime=" + lastUpdateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
package org.xyzh.common.vo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.xyzh.common.dto.study.TbLearningTask;
|
||||
import org.xyzh.common.dto.study.TbTaskCourse;
|
||||
import org.xyzh.common.dto.study.TbTaskResource;
|
||||
import org.xyzh.common.dto.study.TbTaskItem;
|
||||
import org.xyzh.common.dto.study.TbTaskUser;
|
||||
|
||||
public class TaskItemVO extends TbLearningTask {
|
||||
|
||||
private Integer itemType;
|
||||
private String courseID;
|
||||
private String courseName;
|
||||
private String resourceID;
|
||||
@@ -29,18 +27,31 @@ public class TaskItemVO extends TbLearningTask {
|
||||
public TaskItemVO() {
|
||||
}
|
||||
|
||||
public TaskItemVO(TbTaskCourse taskCourse) {
|
||||
this.courseID = taskCourse.getCourseID();
|
||||
this.setTaskID(taskCourse.getTaskID());
|
||||
this.orderNum = taskCourse.getOrderNum();
|
||||
this.required = taskCourse.getRequired();
|
||||
public Integer getItemType() {
|
||||
return itemType;
|
||||
}
|
||||
public TaskItemVO(TbTaskResource taskResource) {
|
||||
this.resourceID = taskResource.getResourceID();
|
||||
this.setTaskID(taskResource.getTaskID());
|
||||
this.required = taskResource.getRequired();
|
||||
this.orderNum = taskResource.getOrderNum();
|
||||
|
||||
public void setItemType(Integer itemType) {
|
||||
this.itemType = itemType;
|
||||
}
|
||||
|
||||
public TaskItemVO(TbTaskItem taskItem) {
|
||||
this.itemType = taskItem.getItemType();
|
||||
this.setTaskID(taskItem.getTaskID());
|
||||
this.orderNum = taskItem.getOrderNum();
|
||||
this.required = taskItem.getRequired();
|
||||
this.setID(taskItem.getID());
|
||||
this.setCreateTime(taskItem.getCreateTime());
|
||||
this.setCreator(taskItem.getCreator());
|
||||
|
||||
// 根据类型设置对应的ID
|
||||
if (taskItem.getItemType() != null) {
|
||||
if (taskItem.getItemType() == 2) { // 课程
|
||||
this.courseID = taskItem.getItemID();
|
||||
} else if (taskItem.getItemType() == 1) { // 资源
|
||||
this.resourceID = taskItem.getItemID();
|
||||
}
|
||||
}
|
||||
}
|
||||
public TaskItemVO(TbTaskUser taskUser) {
|
||||
this.userID = taskUser.getUserID();
|
||||
@@ -100,21 +111,30 @@ public class TaskItemVO extends TbLearningTask {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public TbTaskCourse toTaskCourse() {
|
||||
TbTaskCourse taskCourse = new TbTaskCourse();
|
||||
taskCourse.setCourseID(courseID);
|
||||
taskCourse.setTaskID(getTaskID());
|
||||
taskCourse.setCreateTime(getCreateTime());
|
||||
taskCourse.setCreator(getCreator());
|
||||
return taskCourse;
|
||||
}
|
||||
public TbTaskResource toTaskResource() {
|
||||
TbTaskResource taskResource = new TbTaskResource();
|
||||
taskResource.setResourceID(resourceID);
|
||||
taskResource.setTaskID(getTaskID());
|
||||
taskResource.setCreateTime(getCreateTime());
|
||||
taskResource.setCreator(getCreator());
|
||||
return taskResource;
|
||||
public TbTaskItem toTaskItem() {
|
||||
TbTaskItem taskItem = new TbTaskItem();
|
||||
taskItem.setID(getID());
|
||||
taskItem.setTaskID(getTaskID());
|
||||
taskItem.setItemType(itemType);
|
||||
taskItem.setRequired(required);
|
||||
taskItem.setOrderNum(orderNum);
|
||||
taskItem.setCreateTime(getCreateTime());
|
||||
taskItem.setCreator(getCreator());
|
||||
|
||||
// 根据类型设置对应的itemID
|
||||
if (courseID != null && !courseID.isEmpty()) {
|
||||
taskItem.setItemID(courseID);
|
||||
if (itemType == null) {
|
||||
taskItem.setItemType(2); // 课程
|
||||
}
|
||||
} else if (resourceID != null && !resourceID.isEmpty()) {
|
||||
taskItem.setItemID(resourceID);
|
||||
if (itemType == null) {
|
||||
taskItem.setItemType(1); // 资源
|
||||
}
|
||||
}
|
||||
|
||||
return taskItem;
|
||||
}
|
||||
public TbTaskUser toTaskUser() {
|
||||
TbTaskUser taskUser = new TbTaskUser();
|
||||
|
||||
@@ -2,8 +2,7 @@ package org.xyzh.common.vo;
|
||||
|
||||
import org.xyzh.common.dto.BaseDTO;
|
||||
import org.xyzh.common.dto.study.TbLearningTask;
|
||||
import org.xyzh.common.dto.study.TbTaskCourse;
|
||||
import org.xyzh.common.dto.study.TbTaskResource;
|
||||
import org.xyzh.common.dto.study.TbTaskItem;
|
||||
import org.xyzh.common.dto.study.TbTaskUser;
|
||||
|
||||
import java.util.List;
|
||||
@@ -77,31 +76,28 @@ public class TaskVO extends BaseDTO{
|
||||
public void setTaskStatus(Integer taskStatus) {
|
||||
this.taskStatus = taskStatus;
|
||||
}
|
||||
public List<TbTaskCourse> toTaskCourses() {
|
||||
return getTaskCourses().stream().map(TaskItemVO::toTaskCourse).collect(Collectors.toList());
|
||||
public List<TbTaskItem> toTaskCourses() {
|
||||
return getTaskCourses().stream().map(TaskItemVO::toTaskItem).collect(Collectors.toList());
|
||||
}
|
||||
public List<TbTaskResource> toTaskResources() {
|
||||
return getTaskResources().stream().map(TaskItemVO::toTaskResource).collect(Collectors.toList());
|
||||
public List<TbTaskItem> toTaskResources() {
|
||||
return getTaskResources().stream().map(TaskItemVO::toTaskItem).collect(Collectors.toList());
|
||||
}
|
||||
public List<TbTaskUser> toTaskUsers() {
|
||||
return getTaskUsers().stream().map(TaskItemVO::toTaskUser).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void setTaskCourseList(List<TbTaskCourse> taskCourses) {
|
||||
if (taskCourses == null) {
|
||||
public void setTaskItemList(List<TbTaskItem> taskItems) {
|
||||
if (taskItems == null) {
|
||||
return;
|
||||
}
|
||||
this.taskCourses = taskCourses.stream().map(item -> {
|
||||
return new TaskItemVO(item);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
public void setTaskResourceList(List<TbTaskResource> taskResources) {
|
||||
if (taskResources == null) {
|
||||
return;
|
||||
}
|
||||
this.taskResources = taskResources.stream().map(item -> {
|
||||
return new TaskItemVO(item);
|
||||
}).collect(Collectors.toList());
|
||||
this.taskCourses = taskItems.stream()
|
||||
.filter(item -> item.getItemType() == 2)
|
||||
.map(TaskItemVO::new)
|
||||
.collect(Collectors.toList());
|
||||
this.taskResources = taskItems.stream()
|
||||
.filter(item -> item.getItemType() == 1)
|
||||
.map(TaskItemVO::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
public void setTaskUserList(List<TbTaskUser> taskUsers) {
|
||||
if (taskUsers == null) {
|
||||
|
||||
@@ -124,7 +124,7 @@ public class ResourceController {
|
||||
* 增加浏览次数
|
||||
*/
|
||||
@PostMapping("/resource/{resourceID}/view")
|
||||
public ResultDomain<TbResource> incrementViewCount(@PathVariable("resourceID") String resourceID) {
|
||||
public ResultDomain<Boolean> incrementViewCount(@PathVariable("resourceID") String resourceID) {
|
||||
return resourceService.incrementViewCount(resourceID);
|
||||
}
|
||||
|
||||
|
||||
@@ -173,4 +173,13 @@ public interface ResourceMapper extends BaseMapper<TbResource> {
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int updateResourceCollectCount(@Param("resourceID") String resourceID, @Param("collectionValue") Integer collectionValue);
|
||||
|
||||
/**
|
||||
* @description 增加资源浏览次数
|
||||
* @param resourceID 资源ID
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int incrementViewCount(@Param("resourceID") String resourceID);
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ public class NCResourceServiceImpl implements ResourceService {
|
||||
if (result > 0) {
|
||||
logger.info("发布资源成功: {}", resourceID);
|
||||
// 重新查询返回完整数据
|
||||
TbResource updated = resourceMapper.selectById(resource.getID());
|
||||
TbResource updated = resourceMapper.selectByResourceId(resource.getID());
|
||||
resultDomain.success("发布资源成功", updated);
|
||||
return resultDomain;
|
||||
} else {
|
||||
@@ -437,7 +437,7 @@ public class NCResourceServiceImpl implements ResourceService {
|
||||
if (result > 0) {
|
||||
logger.info("下架资源成功: {}", resourceID);
|
||||
// 重新查询返回完整数据
|
||||
TbResource updated = resourceMapper.selectById(resource.getID());
|
||||
TbResource updated = resourceMapper.selectByResourceId(resource.getID());
|
||||
resultDomain.success("下架资源成功", updated);
|
||||
return resultDomain;
|
||||
} else {
|
||||
@@ -453,33 +453,20 @@ public class NCResourceServiceImpl implements ResourceService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultDomain<TbResource> incrementViewCount(String resourceID) {
|
||||
ResultDomain<TbResource> resultDomain = new ResultDomain<>();
|
||||
public ResultDomain<Boolean> incrementViewCount(String resourceID) {
|
||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||
try {
|
||||
// 参数验证
|
||||
// 参数验证
|
||||
if (!StringUtils.hasText(resourceID)) {
|
||||
resultDomain.fail("资源ID不能为空");
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
// 查询资源
|
||||
TbResource resource = resourceMapper.selectByResourceId(resourceID);
|
||||
if (resource == null || resource.getDeleted()) {
|
||||
resultDomain.fail("资源不存在");
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
// 增加浏览次数
|
||||
Integer currentCount = resource.getViewCount() != null ? resource.getViewCount() : 0;
|
||||
resource.setViewCount(currentCount + 1);
|
||||
resource.setUpdateTime(new Date());
|
||||
|
||||
int result = resourceMapper.updateResource(resource);
|
||||
int result = resourceMapper.incrementViewCount(resourceID);
|
||||
if (result > 0) {
|
||||
logger.info("增加资源浏览次数成功: {}", resourceID);
|
||||
// 重新查询返回完整数据
|
||||
TbResource updated = resourceMapper.selectById(resource.getID());
|
||||
resultDomain.success("增加浏览次数成功", updated);
|
||||
resultDomain.success("增加浏览次数成功", true);
|
||||
return resultDomain;
|
||||
} else {
|
||||
resultDomain.fail("增加浏览次数失败");
|
||||
@@ -563,7 +550,7 @@ public class NCResourceServiceImpl implements ResourceService {
|
||||
return resultDomain;
|
||||
}
|
||||
else if (isCollected.isSuccess() && isCollected.getData() && collectionValue == -1) {
|
||||
ResultDomain<Boolean> removeCollection = userCollectionService.removeCollection(user.getID(), collection.getCollectionType(), resourceID);
|
||||
ResultDomain<Boolean> removeCollection = userCollectionService.removeCollection(collection);
|
||||
if (removeCollection.isSuccess()) {
|
||||
resourceMapper.updateResourceCollectCount(resourceID, -1);
|
||||
resultDomain.success("已取消收藏", resource);
|
||||
|
||||
@@ -310,4 +310,12 @@
|
||||
SET collect_count = collect_count + #{collectionValue}
|
||||
WHERE resource_id = #{resourceID}
|
||||
</update>
|
||||
|
||||
<!-- incrementViewCount -->
|
||||
|
||||
<update id="incrementViewCount">
|
||||
UPDATE tb_resource
|
||||
SET view_count = view_count + 1
|
||||
WHERE resource_id = #{resourceID}
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<module>news</module>
|
||||
<module>study</module>
|
||||
<module>usercenter</module>
|
||||
<module>achievement</module>
|
||||
<module>ai</module>
|
||||
<module>file</module>
|
||||
</modules>
|
||||
@@ -102,16 +103,21 @@
|
||||
<artifactId>study</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>usercenter</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>ai</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>usercenter</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>achievement</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>ai</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
<!-- Spring相关依赖 -->
|
||||
<!-- 覆盖SpringFramework的依赖配置-->
|
||||
<dependency>
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.xyzh.common.core.page.PageRequest;
|
||||
import org.xyzh.common.dto.study.TbCourse;
|
||||
import org.xyzh.common.dto.study.TbCourseChapter;
|
||||
import org.xyzh.common.dto.study.TbCourseNode;
|
||||
import org.xyzh.common.dto.study.TbLearningRecord;
|
||||
import org.xyzh.common.vo.ChapterVO;
|
||||
import org.xyzh.common.vo.CourseVO;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@@ -7,6 +7,10 @@ import org.springframework.web.bind.annotation.*;
|
||||
import org.xyzh.api.study.record.LearningRecordService;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.dto.study.TbLearningRecord;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
|
||||
/**
|
||||
* @description 学习记录控制器
|
||||
@@ -16,7 +20,7 @@ import org.xyzh.common.dto.study.TbLearningRecord;
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/study/record")
|
||||
@RequestMapping("/study/records")
|
||||
public class LearningRecordController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(LearningRecordController.class);
|
||||
|
||||
@@ -26,68 +30,46 @@ public class LearningRecordController {
|
||||
/**
|
||||
* 获取学习记录
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public ResultDomain<TbLearningRecord> getLearningRecords(
|
||||
@RequestParam(required = false) String userID,
|
||||
@RequestParam(required = false) String resourceType,
|
||||
@RequestParam(required = false) String resourceID) {
|
||||
return null;
|
||||
// return learningRecordService.getLearningRecords(userID, courseID, taskID);
|
||||
@PostMapping("/list")
|
||||
public ResultDomain<TbLearningRecord> getLearningRecordList(@RequestBody TbLearningRecord learningRecord) {
|
||||
return learningRecordService.getLearningRecord(learningRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建学习记录
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
public ResultDomain<TbLearningRecord> createLearningRecord(@RequestBody TbLearningRecord record) {
|
||||
return null;
|
||||
// return learningRecordService.createLearningRecord(record);
|
||||
@PostMapping("/record")
|
||||
public ResultDomain<TbLearningRecord> insertLearningRecord(@RequestBody TbLearningRecord record) {
|
||||
return learningRecordService.insertLearningRecord(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新学习记录
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
@PutMapping("/record")
|
||||
public ResultDomain<TbLearningRecord> updateLearningRecord(@RequestBody TbLearningRecord record) {
|
||||
return null;
|
||||
// return learningRecordService.updateLearningRecord(record);
|
||||
return learningRecordService.updateLearningRecord(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除学习记录
|
||||
*/
|
||||
@DeleteMapping("/{recordID}")
|
||||
public ResultDomain<Boolean> deleteLearningRecord(@PathVariable("recordID") String recordID) {
|
||||
return null;
|
||||
// return learningRecordService.deleteLearningRecord(recordID);
|
||||
@DeleteMapping("/record")
|
||||
public ResultDomain<Boolean> deleteLearningRecord(@RequestBody TbLearningRecord learningRecord) {
|
||||
return learningRecordService.deleteLearningRecord(learningRecord.getID());
|
||||
}
|
||||
|
||||
@PutMapping("/complete")
|
||||
public ResultDomain<TbLearningRecord> markLearningComplete(@RequestBody TbLearningRecord learningRecord) {
|
||||
return learningRecordService.markLearningComplete(learningRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取学习记录
|
||||
* 查询用户课程的学习记录
|
||||
*/
|
||||
@GetMapping("/{recordID}")
|
||||
public ResultDomain<TbLearningRecord> getRecordById(@PathVariable("recordID") String recordID) {
|
||||
return null;
|
||||
// return learningRecordService.getRecordById(recordID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新学习进度
|
||||
*/
|
||||
@PutMapping("/{recordID}/progress")
|
||||
public ResultDomain<TbLearningRecord> updateLearningProgress(
|
||||
@PathVariable("recordID") String recordID,
|
||||
@RequestParam Integer progress) {
|
||||
return null;
|
||||
// return learningRecordService.updateLearningProgress(recordID, progress);
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成学习
|
||||
*/
|
||||
@PostMapping("/{recordID}/complete")
|
||||
public ResultDomain<TbLearningRecord> completeLearning(@PathVariable("recordID") String recordID) {
|
||||
return null;
|
||||
// return learningRecordService.completeLearning(recordID);
|
||||
@PostMapping("/course/records")
|
||||
public ResultDomain<TbLearningRecord> getCourseLearningRecord(@RequestBody TbLearningRecord learningRecord) {
|
||||
|
||||
return learningRecordService.getCourseLearningRecord(learningRecord);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ import org.xyzh.common.dto.study.TbLearningTask;
|
||||
import org.xyzh.common.dto.study.TbTaskUser;
|
||||
import org.xyzh.common.vo.TaskItemVO;
|
||||
import org.xyzh.common.vo.TaskVO;
|
||||
import org.xyzh.common.dto.study.TbTaskCourse;
|
||||
import org.xyzh.common.dto.study.TbTaskResource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -65,6 +63,11 @@ public class LearningTaskController {
|
||||
return learningTaskService.getTaskById(taskID);
|
||||
}
|
||||
|
||||
@GetMapping("/{taskID}/user")
|
||||
public ResultDomain<TaskVO> getTaskUser(@PathVariable("taskID") String taskID) {
|
||||
return learningTaskService.getTaskUser(taskID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建任务
|
||||
*/
|
||||
@@ -157,4 +160,6 @@ public class LearningTaskController {
|
||||
return learningTaskService.getUserProgress(userID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public interface LearningRecordMapper extends BaseMapper<TbLearningRecord> {
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbLearningRecord selectByUserIdAndCourseId(@Param("userId") String userId, @Param("courseId") String courseId);
|
||||
List<TbLearningRecord> selectByUserIdAndCourseId(@Param("userId") String userId, @Param("courseId") String courseId);
|
||||
|
||||
/**
|
||||
* @description 根据状态查询学习记录列表
|
||||
@@ -107,7 +107,7 @@ public interface LearningRecordMapper extends BaseMapper<TbLearningRecord> {
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deleteLearningRecord(TbLearningRecord learningRecord);
|
||||
int deleteLearningRecord(@Param("recordId") String recordId);
|
||||
|
||||
/**
|
||||
* @description 批量插入学习记录
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
package org.xyzh.study.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.xyzh.common.core.page.PageParam;
|
||||
import org.xyzh.common.dto.study.TbTaskCourse;
|
||||
import org.xyzh.common.vo.TaskItemVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description TaskCourseMapper.java文件描述 任务课程关联数据访问层
|
||||
* @filename TaskCourseMapper.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
@Mapper
|
||||
public interface TaskCourseMapper extends BaseMapper<TbTaskCourse> {
|
||||
|
||||
/**
|
||||
* @description 查询任务课程关联列表
|
||||
* @param filter 过滤条件
|
||||
* @return List<TbTaskCourse> 任务课程关联列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbTaskCourse> selectTaskCourses(TbTaskCourse filter);
|
||||
|
||||
/**
|
||||
* @description 根据关联ID查询关联信息
|
||||
* @param relationId 关联ID
|
||||
* @return TbTaskCourse 关联信息
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbTaskCourse selectByRelationId(@Param("relationId") String relationId);
|
||||
|
||||
/**
|
||||
* @description 根据任务ID查询课程关联列表
|
||||
* @param taskId 任务ID
|
||||
* @return List<TbTaskCourse> 课程关联列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbTaskCourse> selectByTaskId(@Param("taskId") String taskId);
|
||||
|
||||
List<TaskItemVO> selectTaskItemByTaskId(@Param("taskId") String taskId);
|
||||
|
||||
/**
|
||||
* @description 根据课程ID查询任务关联列表
|
||||
* @param courseId 课程ID
|
||||
* @return List<TbTaskCourse> 任务关联列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbTaskCourse> selectByCourseId(@Param("courseId") String courseId);
|
||||
|
||||
/**
|
||||
* @description 根据任务ID和课程ID查询关联信息
|
||||
* @param taskId 任务ID
|
||||
* @param courseId 课程ID
|
||||
* @return TbTaskCourse 关联信息
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbTaskCourse selectByTaskIdAndCourseId(@Param("taskId") String taskId, @Param("courseId") String courseId);
|
||||
|
||||
/**
|
||||
* @description 检查任务课程关联是否存在
|
||||
* @param taskId 任务ID
|
||||
* @param courseId 课程ID
|
||||
* @param excludeId 排除的关联ID(用于更新时排除自身)
|
||||
* @return int 存在的数量
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int countByTaskIdAndCourseId(@Param("taskId") String taskId, @Param("courseId") String courseId, @Param("excludeId") String excludeId);
|
||||
|
||||
/**
|
||||
* @description 插入任务课程关联
|
||||
* @param taskCourse 任务课程关联
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int insertTaskCourse(TbTaskCourse taskCourse);
|
||||
|
||||
/**
|
||||
* @description 更新任务课程关联
|
||||
* @param taskCourse 任务课程关联
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int updateTaskCourse(TbTaskCourse taskCourse);
|
||||
|
||||
/**
|
||||
* @description 删除任务课程关联
|
||||
* @param taskCourse 任务课程关联
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deleteTaskCourse(TbTaskCourse taskCourse);
|
||||
|
||||
/**
|
||||
* @description 批量插入任务课程关联
|
||||
* @param taskCourseList 任务课程关联列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchInsertTaskCourses(@Param("taskCourseList") List<TbTaskCourse> taskCourseList);
|
||||
|
||||
/**
|
||||
* @description 批量删除任务课程关联
|
||||
* @param ids 关联ID列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchDeleteTaskCourses(@Param("ids") List<String> ids);
|
||||
|
||||
/**
|
||||
* @description 根据任务ID批量删除课程关联
|
||||
* @param taskId 任务ID
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deleteByTaskId(@Param("taskId") String taskId);
|
||||
|
||||
/**
|
||||
* @description 根据课程ID批量删除任务关联
|
||||
* @param courseId 课程ID
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deleteByCourseId(@Param("courseId") String courseId);
|
||||
|
||||
/**
|
||||
* @description 分页查询任务课程关联
|
||||
* @param filter 过滤条件
|
||||
* @param pageParam 分页参数
|
||||
* @return List<TbTaskCourse> 任务课程关联列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbTaskCourse> selectTaskCoursesPage(@Param("filter") TbTaskCourse filter, @Param("pageParam") PageParam pageParam);
|
||||
|
||||
/**
|
||||
* @description 统计任务课程关联总数
|
||||
* @param filter 过滤条件
|
||||
* @return long 总数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
long countTaskCourses(@Param("filter") TbTaskCourse filter);
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package org.xyzh.study.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.xyzh.common.core.page.PageParam;
|
||||
import org.xyzh.common.dto.study.TbTaskItem;
|
||||
import org.xyzh.common.vo.TaskItemVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description TaskItemMapper.java文件描述 任务项关联数据访问层
|
||||
* @filename TaskItemMapper.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
@Mapper
|
||||
public interface TaskItemMapper extends BaseMapper<TbTaskItem> {
|
||||
|
||||
/**
|
||||
* @description 查询任务项关联列表
|
||||
* @param filter 过滤条件
|
||||
* @return List<TbTaskItem> 任务项关联列表
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
List<TbTaskItem> selectTaskItems(TbTaskItem filter);
|
||||
|
||||
/**
|
||||
* @description 根据关联ID查询关联信息
|
||||
* @param relationId 关联ID
|
||||
* @return TbTaskItem 关联信息
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
TbTaskItem selectByRelationId(@Param("relationId") String relationId);
|
||||
|
||||
/**
|
||||
* @description 根据任务ID查询项关联列表
|
||||
* @param taskId 任务ID
|
||||
* @return List<TbTaskItem> 项关联列表
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
List<TbTaskItem> selectByTaskId(@Param("taskId") String taskId);
|
||||
|
||||
/**
|
||||
* @description 根据任务ID和类型查询项关联列表
|
||||
* @param taskId 任务ID
|
||||
* @param itemType 项类型(1资源 2课程)
|
||||
* @return List<TbTaskItem> 项关联列表
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
List<TbTaskItem> selectByTaskIdAndType(@Param("taskId") String taskId, @Param("itemType") Integer itemType);
|
||||
|
||||
/**
|
||||
* @description 根据任务ID查询任务项VO列表
|
||||
* @param taskId 任务ID
|
||||
* @return List<TaskItemVO> 任务项VO列表
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
List<TaskItemVO> selectTaskItemVOByTaskId(@Param("taskId") String taskId);
|
||||
|
||||
/**
|
||||
* @description 根据任务ID和用户ID查询任务项视图对象列表(包含该用户的学习状态)
|
||||
* @param taskId 任务ID
|
||||
* @param userId 用户ID
|
||||
* @return List<TaskItemVO> 任务项视图对象列表
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
List<TaskItemVO> selectTaskItemVOByTaskIdAndUserId(@Param("taskId") String taskId, @Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 根据项ID查询任务关联列表
|
||||
* @param itemId 项ID
|
||||
* @param itemType 项类型(1资源 2课程)
|
||||
* @return List<TbTaskItem> 任务关联列表
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
List<TbTaskItem> selectByItemId(@Param("itemId") String itemId, @Param("itemType") Integer itemType);
|
||||
|
||||
/**
|
||||
* @description 根据任务ID和项ID查询关联信息
|
||||
* @param taskId 任务ID
|
||||
* @param itemId 项ID
|
||||
* @param itemType 项类型
|
||||
* @return TbTaskItem 关联信息
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
TbTaskItem selectByTaskIdAndItemId(@Param("taskId") String taskId, @Param("itemId") String itemId, @Param("itemType") Integer itemType);
|
||||
|
||||
/**
|
||||
* @description 检查任务项关联是否存在
|
||||
* @param taskId 任务ID
|
||||
* @param itemId 项ID
|
||||
* @param itemType 项类型
|
||||
* @param excludeId 排除的关联ID(用于更新时排除自身)
|
||||
* @return int 存在的数量
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
int countByTaskIdAndItemId(@Param("taskId") String taskId, @Param("itemId") String itemId, @Param("itemType") Integer itemType, @Param("excludeId") String excludeId);
|
||||
|
||||
/**
|
||||
* @description 插入任务项关联
|
||||
* @param taskItem 任务项关联
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
int insertTaskItem(TbTaskItem taskItem);
|
||||
|
||||
/**
|
||||
* @description 更新任务项关联
|
||||
* @param taskItem 任务项关联
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
int updateTaskItem(TbTaskItem taskItem);
|
||||
|
||||
/**
|
||||
* @description 删除任务项关联
|
||||
* @param taskItem 任务项关联
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
int deleteTaskItem(TbTaskItem taskItem);
|
||||
|
||||
/**
|
||||
* @description 批量插入任务项关联
|
||||
* @param taskItemList 任务项关联列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
int batchInsertTaskItems(@Param("taskItemList") List<TbTaskItem> taskItemList);
|
||||
|
||||
/**
|
||||
* @description 批量删除任务项关联
|
||||
* @param ids 关联ID列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
int batchDeleteTaskItems(@Param("ids") List<String> ids);
|
||||
|
||||
/**
|
||||
* @description 根据任务ID批量删除项关联
|
||||
* @param taskId 任务ID
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
int deleteByTaskId(@Param("taskId") String taskId);
|
||||
|
||||
/**
|
||||
* @description 根据项ID批量删除任务关联
|
||||
* @param itemId 项ID
|
||||
* @param itemType 项类型
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
int deleteByItemId(@Param("itemId") String itemId, @Param("itemType") Integer itemType);
|
||||
|
||||
/**
|
||||
* @description 分页查询任务项关联
|
||||
* @param filter 过滤条件
|
||||
* @param pageParam 分页参数
|
||||
* @return List<TbTaskItem> 任务项关联列表
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
List<TbTaskItem> selectTaskItemsPage(@Param("filter") TbTaskItem filter, @Param("pageParam") PageParam pageParam);
|
||||
|
||||
/**
|
||||
* @description 统计任务项关联总数
|
||||
* @param filter 过滤条件
|
||||
* @return long 总数
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
long countTaskItems(@Param("filter") TbTaskItem filter);
|
||||
}
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
package org.xyzh.study.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.xyzh.common.core.page.PageParam;
|
||||
import org.xyzh.common.dto.study.TbTaskResource;
|
||||
import org.xyzh.common.vo.TaskItemVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description TaskResourceMapper.java文件描述 任务资源关联数据访问层
|
||||
* @filename TaskResourceMapper.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
@Mapper
|
||||
public interface TaskResourceMapper extends BaseMapper<TbTaskResource> {
|
||||
|
||||
/**
|
||||
* @description 查询任务资源关联列表
|
||||
* @param filter 过滤条件
|
||||
* @return List<TbTaskResource> 任务资源关联列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbTaskResource> selectTaskResources(TbTaskResource filter);
|
||||
|
||||
/**
|
||||
* @description 根据关联ID查询关联信息
|
||||
* @param relationId 关联ID
|
||||
* @return TbTaskResource 关联信息
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbTaskResource selectByRelationId(@Param("relationId") String relationId);
|
||||
|
||||
/**
|
||||
* @description 根据任务ID查询资源关联列表
|
||||
* @param taskId 任务ID
|
||||
* @return List<TbTaskResource> 资源关联列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbTaskResource> selectByTaskId(@Param("taskId") String taskId);
|
||||
|
||||
/**
|
||||
* @description 根据任务ID查询任务资源关联列表
|
||||
* @param taskId 任务ID
|
||||
* @return List<TaskItemVO> 任务资源关联列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TaskItemVO> selectTaskItemByTaskId(@Param("taskId") String taskId);
|
||||
|
||||
/**
|
||||
* @description 根据资源ID查询任务关联列表
|
||||
* @param resourceId 资源ID
|
||||
* @return List<TbTaskResource> 任务关联列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbTaskResource> selectByResourceId(@Param("resourceId") String resourceId);
|
||||
|
||||
/**
|
||||
* @description 根据任务ID和资源ID查询关联信息
|
||||
* @param taskId 任务ID
|
||||
* @param resourceId 资源ID
|
||||
* @return TbTaskResource 关联信息
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbTaskResource selectByTaskIdAndResourceId(@Param("taskId") String taskId, @Param("resourceId") String resourceId);
|
||||
|
||||
/**
|
||||
* @description 检查任务资源关联是否存在
|
||||
* @param taskId 任务ID
|
||||
* @param resourceId 资源ID
|
||||
* @param excludeId 排除的关联ID(用于更新时排除自身)
|
||||
* @return int 存在的数量
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int countByTaskIdAndResourceId(@Param("taskId") String taskId, @Param("resourceId") String resourceId, @Param("excludeId") String excludeId);
|
||||
|
||||
/**
|
||||
* @description 插入任务资源关联
|
||||
* @param taskResource 任务资源关联
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int insertTaskResource(TbTaskResource taskResource);
|
||||
|
||||
/**
|
||||
* @description 更新任务资源关联
|
||||
* @param taskResource 任务资源关联
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int updateTaskResource(TbTaskResource taskResource);
|
||||
|
||||
/**
|
||||
* @description 删除任务资源关联
|
||||
* @param taskResource 任务资源关联
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deleteTaskResource(TbTaskResource taskResource);
|
||||
|
||||
/**
|
||||
* @description 批量插入任务资源关联
|
||||
* @param taskResourceList 任务资源关联列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchInsertTaskResources(@Param("taskResourceList") List<TbTaskResource> taskResourceList);
|
||||
|
||||
/**
|
||||
* @description 批量删除任务资源关联
|
||||
* @param ids 关联ID列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchDeleteTaskResources(@Param("ids") List<String> ids);
|
||||
|
||||
/**
|
||||
* @description 根据任务ID批量删除资源关联
|
||||
* @param taskId 任务ID
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deleteByTaskId(@Param("taskId") String taskId);
|
||||
|
||||
/**
|
||||
* @description 根据资源ID批量删除任务关联
|
||||
* @param resourceId 资源ID
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deleteByResourceId(@Param("resourceId") String resourceId);
|
||||
|
||||
/**
|
||||
* @description 分页查询任务资源关联
|
||||
* @param filter 过滤条件
|
||||
* @param pageParam 分页参数
|
||||
* @return List<TbTaskResource> 任务资源关联列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbTaskResource> selectTaskResourcesPage(@Param("filter") TbTaskResource filter, @Param("pageParam") PageParam pageParam);
|
||||
|
||||
/**
|
||||
* @description 统计任务资源关联总数
|
||||
* @param filter 过滤条件
|
||||
* @return long 总数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
long countTaskResources(@Param("filter") TbTaskResource filter);
|
||||
}
|
||||
@@ -47,6 +47,8 @@ public interface TaskUserMapper extends BaseMapper<TbTaskUser> {
|
||||
List<TbTaskUser> selectByTaskId(@Param("taskId") String taskId);
|
||||
|
||||
List<TaskItemVO> selectTaskItemByTaskId(@Param("taskId") String taskId);
|
||||
|
||||
List<TaskItemVO> selectUserTaskItem(@Param("taskId") String taskId, @Param("userId") String userId);
|
||||
/**
|
||||
* @description 根据用户ID查询任务关联列表
|
||||
* @param userId 用户ID
|
||||
@@ -105,6 +107,15 @@ public interface TaskUserMapper extends BaseMapper<TbTaskUser> {
|
||||
*/
|
||||
int insertTaskUser(TbTaskUser taskUser);
|
||||
|
||||
/**
|
||||
* @description 更新任务用户关联
|
||||
* @param taskUser 任务用户关联
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
int updateTaskUser(TbTaskUser taskUser);
|
||||
|
||||
/**
|
||||
* @description 删除任务用户关联
|
||||
* @param taskUser 任务用户关联
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.xyzh.common.dto.study.TbCourse;
|
||||
import org.xyzh.common.dto.study.TbCourseChapter;
|
||||
import org.xyzh.common.dto.study.TbCourseNode;
|
||||
import org.xyzh.common.dto.study.TbCourseTag;
|
||||
import org.xyzh.common.dto.study.TbLearningRecord;
|
||||
import org.xyzh.common.dto.user.TbSysUser;
|
||||
import org.xyzh.common.utils.IDUtils;
|
||||
import org.xyzh.common.vo.ChapterVO;
|
||||
@@ -107,6 +108,7 @@ public class SCCourseServiceImpl implements SCCourseService {
|
||||
}).collect(Collectors.toList());
|
||||
courseVO.setCourseChapters(chapterVOs);
|
||||
}
|
||||
|
||||
resultDomain.success("获取课程详情成功", courseVO);
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,25 @@
|
||||
package org.xyzh.study.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.core.enums.TaskItemType;
|
||||
import org.xyzh.common.dto.study.TbLearningRecord;
|
||||
import org.xyzh.common.dto.study.TbTaskItem;
|
||||
import org.xyzh.common.dto.study.TbTaskUser;
|
||||
import org.xyzh.common.dto.user.TbSysUser;
|
||||
import org.xyzh.common.vo.TaskItemVO;
|
||||
import org.xyzh.api.study.record.LearningRecordService;
|
||||
import org.xyzh.study.mapper.LearningRecordMapper;
|
||||
import org.xyzh.study.mapper.TaskItemMapper;
|
||||
import org.xyzh.study.mapper.TaskUserMapper;
|
||||
import org.xyzh.system.utils.LoginUtil;
|
||||
|
||||
/**
|
||||
* @description 学习记录服务实现类
|
||||
@@ -26,62 +36,244 @@ public class SCLearningRecordServiceImpl implements LearningRecordService {
|
||||
@Autowired
|
||||
private LearningRecordMapper learningRecordMapper;
|
||||
|
||||
@Autowired
|
||||
private TaskItemMapper taskItemMapper;
|
||||
|
||||
@Autowired
|
||||
private TaskUserMapper taskUserMapper;
|
||||
|
||||
@Override
|
||||
public ResultDomain<Boolean> deleteLearningRecord(String recordID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public ResultDomain<TbLearningRecord> insertLearningRecord(TbLearningRecord learningRecord) {
|
||||
ResultDomain<TbLearningRecord> resultDomain = new ResultDomain<>();
|
||||
TbSysUser user = LoginUtil.getCurrentUser();
|
||||
if (user == null) {
|
||||
resultDomain.fail("请先登录");
|
||||
return resultDomain;
|
||||
}
|
||||
learningRecord.setUserID(user.getID());
|
||||
learningRecord.setCreateTime(new Date());
|
||||
if (learningRecord.getResourceType() == null) {
|
||||
resultDomain.fail("资源类型不能为空");
|
||||
return resultDomain;
|
||||
}
|
||||
if (learningRecord.getResourceType() == 1 && learningRecord.getResourceID() == null) {
|
||||
resultDomain.fail("资源ID不能为空");
|
||||
return resultDomain;
|
||||
}
|
||||
if (learningRecord.getResourceType() == 2 && (learningRecord.getCourseID() == null || learningRecord.getChapterID() == null || learningRecord.getNodeID() == null)) {
|
||||
resultDomain.fail("课程信息不能为空");
|
||||
return resultDomain;
|
||||
}
|
||||
List<TbLearningRecord> records = learningRecordMapper.selectLearningRecords(learningRecord);
|
||||
if (records.size() > 0) {
|
||||
resultDomain.fail("学习记录已存在");
|
||||
return resultDomain;
|
||||
}
|
||||
List<TaskItemVO> allTaskItems = taskItemMapper.selectTaskItemVOByTaskIdAndUserId(learningRecord.getTaskID(), user.getID());
|
||||
if (allTaskItems == null || allTaskItems.isEmpty()) {
|
||||
TbTaskUser taskUser = new TbTaskUser();
|
||||
taskUser.setTaskID(learningRecord.getTaskID());
|
||||
taskUser.setUserID(user.getID());
|
||||
taskUser.setProgress(new BigDecimal(0));
|
||||
taskUser.setUpdater(user.getID());
|
||||
|
||||
// 全部完成
|
||||
taskUser.setStatus(1);
|
||||
taskUser.setUpdateTime(new Date());
|
||||
taskUserMapper.updateTaskUser(taskUser);
|
||||
}
|
||||
|
||||
int result = learningRecordMapper.insertLearningRecord(learningRecord);
|
||||
if (result > 0) {
|
||||
resultDomain.success("创建学习记录成功", learningRecord);
|
||||
return resultDomain;
|
||||
} else {
|
||||
resultDomain.fail("创建学习记录失败");
|
||||
return resultDomain;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbLearningRecord> getResourceLearningRecords(Integer resourceType, String resourceID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public ResultDomain<TbLearningRecord> updateLearningRecord(TbLearningRecord learningRecord) {
|
||||
ResultDomain<TbLearningRecord> resultDomain = new ResultDomain<>();
|
||||
TbSysUser user = LoginUtil.getCurrentUser();
|
||||
if (user == null) {
|
||||
resultDomain.fail("请先登录");
|
||||
return resultDomain;
|
||||
}
|
||||
learningRecord.setUpdater(user.getID());
|
||||
|
||||
int result = learningRecordMapper.updateLearningRecord(learningRecord);
|
||||
if (result > 0) {
|
||||
resultDomain.success("更新学习记录成功", learningRecord);
|
||||
return resultDomain;
|
||||
} else {
|
||||
resultDomain.fail("更新学习记录失败");
|
||||
return resultDomain;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<Boolean> deleteLearningRecord(String recordID) {
|
||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||
int result = learningRecordMapper.deleteLearningRecord(recordID);
|
||||
if (result > 0) {
|
||||
resultDomain.success("删除学习记录成功", true);
|
||||
return resultDomain;
|
||||
} else {
|
||||
resultDomain.fail("删除学习记录失败");
|
||||
return resultDomain;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbLearningRecord> getLearningRecord(TbLearningRecord learningRecord) {
|
||||
ResultDomain<TbLearningRecord> resultDomain = new ResultDomain<>();
|
||||
List<TbLearningRecord> records = learningRecordMapper.selectLearningRecords(learningRecord);
|
||||
resultDomain.success("获取学习记录成功", records);
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbLearningRecord> getCourseLearningRecord(TbLearningRecord learningRecord) {
|
||||
ResultDomain<TbLearningRecord> resultDomain = new ResultDomain<>();
|
||||
|
||||
if (learningRecord.getCourseID() == null) {
|
||||
resultDomain.fail("课程ID不能为空");
|
||||
return resultDomain;
|
||||
}
|
||||
learningRecord.setResourceType(2);
|
||||
List<TbLearningRecord> records = learningRecordMapper.selectLearningRecords(learningRecord);
|
||||
resultDomain.success("获取学习记录成功", records);
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbLearningRecord> getResourceLearningRecords(TbLearningRecord learningRecord) {
|
||||
ResultDomain<TbLearningRecord> resultDomain = new ResultDomain<>();
|
||||
TbSysUser user = LoginUtil.getCurrentUser();
|
||||
if (user == null) {
|
||||
resultDomain.fail("请先登录");
|
||||
return resultDomain;
|
||||
}
|
||||
learningRecord.setUserID(user.getID());
|
||||
if (learningRecord.getResourceID() == null) {
|
||||
resultDomain.fail("资源ID不能为空");
|
||||
return resultDomain;
|
||||
}
|
||||
learningRecord.setResourceType(1);
|
||||
List<TbLearningRecord> records = learningRecordMapper.selectLearningRecords(learningRecord);
|
||||
resultDomain.success("获取学习记录成功", records);
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbLearningRecord> getTaskLearningStatistics(String taskID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbLearningRecord> getUserLearningProgress(String userID, Integer resourceType,
|
||||
String resourceID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbLearningRecord> getUserLearningRecords(String userID, Integer resourceType, String taskID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
String resourceID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbLearningRecord> getUserLearningStatistics(String userID, Integer resourceType) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbLearningRecord> markLearningComplete(String userID, Integer resourceType, String resourceID,
|
||||
String taskID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbLearningRecord> saveLearningRecord(TbLearningRecord learningRecord) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public ResultDomain<TbLearningRecord> markLearningComplete(TbLearningRecord learningRecord) {
|
||||
ResultDomain<TbLearningRecord> resultDomain = new ResultDomain<>();
|
||||
TbSysUser user = LoginUtil.getCurrentUser();
|
||||
if (user == null) {
|
||||
resultDomain.fail("请先登录");
|
||||
return resultDomain;
|
||||
}
|
||||
learningRecord.setUpdater(user.getID());
|
||||
learningRecord.setCompleteTime(new Date());
|
||||
learningRecord.setIsComplete(true);
|
||||
int result = learningRecordMapper.updateLearningRecord(learningRecord);
|
||||
if (result > 0) {
|
||||
// 检查是否完成了该任务的所有任务项
|
||||
String taskId = learningRecord.getTaskID();
|
||||
String userId = user.getID();
|
||||
if (taskId != null && !taskId.isEmpty()) {
|
||||
checkAndUpdateTaskCompletion(taskId, userId);
|
||||
}
|
||||
|
||||
resultDomain.success("标记学习完成成功", learningRecord);
|
||||
return resultDomain;
|
||||
} else {
|
||||
resultDomain.fail("标记学习完成失败");
|
||||
return resultDomain;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbLearningRecord> updateLearningProgress(String userID, Integer resourceType, String resourceID,
|
||||
BigDecimal progress, Integer duration) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
/**
|
||||
* @description 检查并更新任务完成状态
|
||||
* @param taskId 任务ID
|
||||
* @param userId 用户ID
|
||||
* @author yslg
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
private void checkAndUpdateTaskCompletion(String taskId, String userId) {
|
||||
try {
|
||||
// 获取该任务下所有任务项(包含该用户的学习状态)
|
||||
List<TaskItemVO> allTaskItems = taskItemMapper.selectTaskItemVOByTaskIdAndUserId(taskId, userId);
|
||||
if (allTaskItems == null || allTaskItems.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否所有必须的任务项都已完成(status = 2)
|
||||
boolean allCompleted = true;
|
||||
int totalRequired = 0;
|
||||
int completedRequired = 0;
|
||||
|
||||
for (TaskItemVO item : allTaskItems) {
|
||||
if (item.getRequired() != null && item.getRequired()) {
|
||||
totalRequired++;
|
||||
if (item.getStatus() != null && item.getStatus() == 2) {
|
||||
completedRequired++;
|
||||
} else {
|
||||
allCompleted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!allCompleted) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算总进度
|
||||
BigDecimal progressPercent = BigDecimal.valueOf(100);
|
||||
|
||||
// 更新 task_user 状态
|
||||
TbTaskUser taskUser = new TbTaskUser();
|
||||
taskUser.setTaskID(taskId);
|
||||
taskUser.setUserID(userId);
|
||||
taskUser.setProgress(progressPercent);
|
||||
taskUser.setUpdater(userId);
|
||||
|
||||
// 全部完成
|
||||
taskUser.setStatus(2);
|
||||
taskUser.setCompleteTime(new Date());
|
||||
taskUserMapper.updateTaskUser(taskUser);
|
||||
logger.info("更新任务用户状态成功 - taskId: {}, userId: {}, status: {}, progress: {}",
|
||||
taskId, userId, taskUser.getStatus(), progressPercent);
|
||||
} catch (Exception e) {
|
||||
logger.error("检查并更新任务完成状态失败 - taskId: {}, userId: {}", taskId, userId, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -20,16 +20,15 @@ import org.xyzh.common.dto.user.TbSysUser;
|
||||
import org.xyzh.common.utils.IDUtils;
|
||||
import org.xyzh.common.dto.study.TbLearningTask;
|
||||
import org.xyzh.common.dto.study.TbTaskUser;
|
||||
import org.xyzh.common.dto.study.TbTaskCourse;
|
||||
import org.xyzh.common.dto.study.TbTaskResource;
|
||||
import org.xyzh.common.dto.study.TbTaskItem;
|
||||
import org.xyzh.common.vo.TaskItemVO;
|
||||
import org.xyzh.common.vo.TaskVO;
|
||||
import org.xyzh.study.mapper.LearningTaskMapper;
|
||||
import org.xyzh.study.mapper.TaskUserMapper;
|
||||
import org.xyzh.system.utils.LoginUtil;
|
||||
import org.xyzh.study.mapper.TaskCourseMapper;
|
||||
import org.xyzh.study.mapper.TaskResourceMapper;
|
||||
import org.xyzh.study.mapper.TaskItemMapper;
|
||||
import org.xyzh.api.study.task.LearningTaskService;
|
||||
import org.xyzh.common.core.enums.TaskItemType;
|
||||
|
||||
/**
|
||||
* @description 学习任务服务实现类
|
||||
@@ -50,19 +49,16 @@ public class SCLearningTaskServiceImpl implements LearningTaskService {
|
||||
private TaskUserMapper taskUserMapper;
|
||||
|
||||
@Autowired
|
||||
private TaskCourseMapper taskCourseMapper;
|
||||
|
||||
@Autowired
|
||||
private TaskResourceMapper taskResourceMapper;
|
||||
private TaskItemMapper taskItemMapper;
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbTaskCourse> addTaskCourse(TbTaskCourse taskCourse) {
|
||||
public ResultDomain<TbTaskItem> addTaskCourse(TbTaskItem taskItem) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbTaskResource> addTaskResource(TbTaskResource taskResource) {
|
||||
public ResultDomain<TbTaskItem> addTaskResource(TbTaskItem taskItem) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@@ -148,22 +144,35 @@ public class SCLearningTaskServiceImpl implements LearningTaskService {
|
||||
learningTask.setTaskID(taskID);
|
||||
learningTask.setCreateTime(now);
|
||||
learningTaskMapper.insertLearningTask(learningTask);
|
||||
// 绑定课程
|
||||
List<TbTaskCourse> taskCourses = taskVO.toTaskCourses();
|
||||
|
||||
// 绑定任务项(课程和资源)
|
||||
List<TbTaskItem> taskItems = new ArrayList<>();
|
||||
|
||||
// 转换课程为任务项
|
||||
List<TbTaskItem> taskCourses = taskVO.toTaskCourses();
|
||||
taskCourses.forEach(item -> {
|
||||
item.setTaskID(taskID);
|
||||
item.setItemType(TaskItemType.COURSE.getValue());
|
||||
item.setCreator(currentUser.getID());
|
||||
item.setCreateTime(now);
|
||||
});
|
||||
taskCourseMapper.batchInsertTaskCourses(taskCourses);
|
||||
// 绑定资源
|
||||
List<TbTaskResource> taskResources = taskVO.toTaskResources();
|
||||
taskItems.addAll(taskCourses);
|
||||
|
||||
// 转换资源为任务项
|
||||
List<TbTaskItem> taskResources = taskVO.toTaskResources();
|
||||
taskResources.forEach(item -> {
|
||||
item.setTaskID(taskID);
|
||||
item.setItemType(TaskItemType.RESOURCE.getValue());
|
||||
item.setCreator(currentUser.getID());
|
||||
item.setCreateTime(now);
|
||||
});
|
||||
taskResourceMapper.batchInsertTaskResources(taskResources);
|
||||
taskItems.addAll(taskResources);
|
||||
|
||||
// 批量插入任务项
|
||||
if (!taskItems.isEmpty()) {
|
||||
taskItemMapper.batchInsertTaskItems(taskItems);
|
||||
}
|
||||
|
||||
// 绑定用户
|
||||
List<TbTaskUser> taskUsers = taskVO.toTaskUsers();
|
||||
taskUsers.forEach(item -> {
|
||||
@@ -202,19 +211,35 @@ public class SCLearningTaskServiceImpl implements LearningTaskService {
|
||||
task.setUpdateTime(now);
|
||||
learningTaskMapper.updateLearningTask(task);
|
||||
|
||||
// 2. 处理任务课程关联
|
||||
// 2. 处理任务项关联(课程和资源)
|
||||
List<TaskItemVO> newCourseItems = taskVO.getTaskCourses();
|
||||
List<TaskItemVO> newResourceItems = taskVO.getTaskResources();
|
||||
if (newCourseItems == null) {
|
||||
newCourseItems = new ArrayList<>();
|
||||
}
|
||||
if (newResourceItems == null) {
|
||||
newResourceItems = new ArrayList<>();
|
||||
}
|
||||
|
||||
// 获取现有的课程关联
|
||||
List<TbTaskCourse> existingCourses = taskCourseMapper.selectByTaskId(taskID);
|
||||
Map<String, TbTaskCourse> existingCourseMap = existingCourses.stream()
|
||||
.collect(Collectors.toMap(TbTaskCourse::getCourseID, course -> course));
|
||||
// 获取现有的所有任务项
|
||||
List<TbTaskItem> existingItems = taskItemMapper.selectByTaskId(taskID);
|
||||
|
||||
// 分离课程和资源
|
||||
List<TbTaskItem> existingCourses = existingItems.stream()
|
||||
.filter(item -> item.getItemType().equals(TaskItemType.COURSE.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
List<TbTaskItem> existingResources = existingItems.stream()
|
||||
.filter(item -> item.getItemType().equals(TaskItemType.RESOURCE.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Map<String, TbTaskItem> existingCourseMap = existingCourses.stream()
|
||||
.collect(Collectors.toMap(TbTaskItem::getItemID, item -> item));
|
||||
Map<String, TbTaskItem> existingResourceMap = existingResources.stream()
|
||||
.collect(Collectors.toMap(TbTaskItem::getItemID, item -> item));
|
||||
|
||||
Set<String> newCourseIDs = new HashSet<>();
|
||||
List<TbTaskCourse> coursesToInsert = new ArrayList<>();
|
||||
Set<String> newResourceIDs = new HashSet<>();
|
||||
List<TbTaskItem> itemsToInsert = new ArrayList<>();
|
||||
|
||||
// 处理新的课程关联
|
||||
for (TaskItemVO item : newCourseItems) {
|
||||
@@ -222,85 +247,62 @@ public class SCLearningTaskServiceImpl implements LearningTaskService {
|
||||
if (courseID == null || courseID.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newCourseIDs.add(courseID);
|
||||
|
||||
// 如果不存在,则新增
|
||||
if (!existingCourseMap.containsKey(courseID)) {
|
||||
TbTaskCourse taskCourse = new TbTaskCourse();
|
||||
taskCourse.setID(IDUtils.generateID());
|
||||
taskCourse.setTaskID(taskID);
|
||||
taskCourse.setCourseID(courseID);
|
||||
taskCourse.setCreator(user.getID());
|
||||
taskCourse.setCreateTime(now);
|
||||
coursesToInsert.add(taskCourse);
|
||||
TbTaskItem taskItem = new TbTaskItem();
|
||||
taskItem.setID(IDUtils.generateID());
|
||||
taskItem.setTaskID(taskID);
|
||||
taskItem.setItemType(TaskItemType.COURSE.getValue());
|
||||
taskItem.setItemID(courseID);
|
||||
taskItem.setRequired(item.getRequired());
|
||||
taskItem.setOrderNum(item.getOrderNum());
|
||||
taskItem.setCreator(user.getID());
|
||||
taskItem.setCreateTime(now);
|
||||
itemsToInsert.add(taskItem);
|
||||
}
|
||||
}
|
||||
|
||||
// 找出要删除的课程关联
|
||||
List<String> courseIDsToDelete = existingCourseMap.values().stream()
|
||||
.filter(course -> !newCourseIDs.contains(course.getCourseID()))
|
||||
.map(TbTaskCourse::getID)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!courseIDsToDelete.isEmpty()) {
|
||||
taskCourseMapper.batchDeleteTaskCourses(courseIDsToDelete);
|
||||
}
|
||||
|
||||
if (!coursesToInsert.isEmpty()) {
|
||||
taskCourseMapper.batchInsertTaskCourses(coursesToInsert);
|
||||
}
|
||||
|
||||
// 3. 处理任务资源关联
|
||||
List<TaskItemVO> newResourceItems = taskVO.getTaskResources();
|
||||
if (newResourceItems == null) {
|
||||
newResourceItems = new ArrayList<>();
|
||||
}
|
||||
|
||||
// 获取现有的资源关联
|
||||
List<TbTaskResource> existingResources = taskResourceMapper.selectByTaskId(taskID);
|
||||
Map<String, TbTaskResource> existingResourceMap = existingResources.stream()
|
||||
.collect(Collectors.toMap(TbTaskResource::getResourceID, resource -> resource));
|
||||
|
||||
Set<String> newResourceIDs = new HashSet<>();
|
||||
List<TbTaskResource> resourcesToInsert = new ArrayList<>();
|
||||
|
||||
// 处理新的资源关联
|
||||
for (TaskItemVO item : newResourceItems) {
|
||||
String resourceID = item.getResourceID();
|
||||
if (resourceID == null || resourceID.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newResourceIDs.add(resourceID);
|
||||
|
||||
// 如果不存在,则新增
|
||||
if (!existingResourceMap.containsKey(resourceID)) {
|
||||
TbTaskResource taskResource = new TbTaskResource();
|
||||
taskResource.setID(IDUtils.generateID());
|
||||
taskResource.setTaskID(taskID);
|
||||
taskResource.setResourceID(resourceID);
|
||||
taskResource.setCreator(user.getID());
|
||||
taskResource.setCreateTime(now);
|
||||
resourcesToInsert.add(taskResource);
|
||||
TbTaskItem taskItem = new TbTaskItem();
|
||||
taskItem.setID(IDUtils.generateID());
|
||||
taskItem.setTaskID(taskID);
|
||||
taskItem.setItemType(TaskItemType.RESOURCE.getValue());
|
||||
taskItem.setItemID(resourceID);
|
||||
taskItem.setRequired(item.getRequired());
|
||||
taskItem.setOrderNum(item.getOrderNum());
|
||||
taskItem.setCreator(user.getID());
|
||||
taskItem.setCreateTime(now);
|
||||
itemsToInsert.add(taskItem);
|
||||
}
|
||||
}
|
||||
|
||||
// 找出要删除的资源关联
|
||||
List<String> resourceIDsToDelete = existingResourceMap.values().stream()
|
||||
.filter(resource -> !newResourceIDs.contains(resource.getResourceID()))
|
||||
.map(TbTaskResource::getID)
|
||||
.collect(Collectors.toList());
|
||||
// 找出要删除的任务项
|
||||
List<String> itemIDsToDelete = new ArrayList<>();
|
||||
existingCourseMap.values().stream()
|
||||
.filter(item -> !newCourseIDs.contains(item.getItemID()))
|
||||
.forEach(item -> itemIDsToDelete.add(item.getID()));
|
||||
existingResourceMap.values().stream()
|
||||
.filter(item -> !newResourceIDs.contains(item.getItemID()))
|
||||
.forEach(item -> itemIDsToDelete.add(item.getID()));
|
||||
|
||||
if (!resourceIDsToDelete.isEmpty()) {
|
||||
taskResourceMapper.batchDeleteTaskResources(resourceIDsToDelete);
|
||||
if (!itemIDsToDelete.isEmpty()) {
|
||||
taskItemMapper.batchDeleteTaskItems(itemIDsToDelete);
|
||||
}
|
||||
|
||||
if (!resourcesToInsert.isEmpty()) {
|
||||
taskResourceMapper.batchInsertTaskResources(resourcesToInsert);
|
||||
if (!itemsToInsert.isEmpty()) {
|
||||
taskItemMapper.batchInsertTaskItems(itemsToInsert);
|
||||
}
|
||||
|
||||
// 4. 处理任务用户关联
|
||||
// 3. 处理任务用户关联
|
||||
List<TaskItemVO> newUserItems = taskVO.getTaskUsers();
|
||||
if (newUserItems == null) {
|
||||
newUserItems = new ArrayList<>();
|
||||
@@ -368,33 +370,143 @@ public class SCLearningTaskServiceImpl implements LearningTaskService {
|
||||
resultDomain.fail("任务不存在");
|
||||
return resultDomain;
|
||||
}
|
||||
List<TaskItemVO> taskCourses = taskCourseMapper.selectTaskItemByTaskId(taskID);
|
||||
List<TaskItemVO> taskResources = taskResourceMapper.selectTaskItemByTaskId(taskID);
|
||||
|
||||
// 获取所有任务项
|
||||
List<TaskItemVO> allTaskItems = taskItemMapper.selectTaskItemVOByTaskId(taskID);
|
||||
|
||||
// 一次循环完成分离和统计
|
||||
List<TaskItemVO> taskCourses = new ArrayList<>();
|
||||
List<TaskItemVO> taskResources = new ArrayList<>();
|
||||
int completedTaskNum = 0;
|
||||
int learningTaskNum = 0;
|
||||
int notStartTaskNum = 0;
|
||||
|
||||
for (TaskItemVO item : allTaskItems) {
|
||||
// 分离课程和资源
|
||||
if (item.getItemType() != null) {
|
||||
if (item.getItemType().equals(TaskItemType.COURSE.getValue())) {
|
||||
taskCourses.add(item);
|
||||
} else if (item.getItemType().equals(TaskItemType.RESOURCE.getValue())) {
|
||||
taskResources.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
// 统计状态
|
||||
Integer status = item.getStatus();
|
||||
if (status != null) {
|
||||
if (status == 2) {
|
||||
completedTaskNum++;
|
||||
} else if (status == 1) {
|
||||
learningTaskNum++;
|
||||
} else if (status == 0) {
|
||||
notStartTaskNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
taskVO.setCompletedTaskNum(completedTaskNum);
|
||||
taskVO.setLearningTaskNum(learningTaskNum);
|
||||
taskVO.setNotStartTaskNum(notStartTaskNum);
|
||||
|
||||
List<TaskItemVO> taskUsers = taskUserMapper.selectTaskItemByTaskId(taskID);
|
||||
taskVO.setLearningTask(task);
|
||||
taskVO.setTaskCourses(taskCourses);
|
||||
taskVO.setTaskResources(taskResources);
|
||||
taskVO.setTaskUsers(taskUsers);
|
||||
|
||||
taskVO.setTotalTaskNum(allTaskItems.size());
|
||||
|
||||
|
||||
|
||||
resultDomain.success("获取任务详情成功", taskVO);
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbTaskCourse> getTaskCourses(String taskID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public ResultDomain<TaskVO> getTaskUser(String taskID) {
|
||||
ResultDomain<TaskVO> resultDomain = new ResultDomain<>();
|
||||
TaskVO taskVO = new TaskVO();
|
||||
TbLearningTask task = learningTaskMapper.selectByTaskId(taskID);
|
||||
if (task == null) {
|
||||
resultDomain.fail("任务不存在");
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
// 获取所有任务项
|
||||
List<TaskItemVO> allTaskItems = taskItemMapper.selectTaskItemVOByTaskId(taskID);
|
||||
|
||||
// 一次循环完成分离和统计
|
||||
List<TaskItemVO> taskCourses = new ArrayList<>();
|
||||
List<TaskItemVO> taskResources = new ArrayList<>();
|
||||
int completedTaskNum = 0;
|
||||
int learningTaskNum = 0;
|
||||
int notStartTaskNum = 0;
|
||||
|
||||
for (TaskItemVO item : allTaskItems) {
|
||||
// 分离课程和资源
|
||||
if (item.getItemType() != null) {
|
||||
if (item.getItemType().equals(TaskItemType.COURSE.getValue())) {
|
||||
taskCourses.add(item);
|
||||
} else if (item.getItemType().equals(TaskItemType.RESOURCE.getValue())) {
|
||||
taskResources.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
// 统计状态
|
||||
Integer status = item.getStatus();
|
||||
if (status != null) {
|
||||
if (status == 2) {
|
||||
completedTaskNum++;
|
||||
} else if (status == 1) {
|
||||
learningTaskNum++;
|
||||
} else if (status == 0) {
|
||||
notStartTaskNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
taskVO.setCompletedTaskNum(completedTaskNum);
|
||||
taskVO.setLearningTaskNum(learningTaskNum);
|
||||
taskVO.setNotStartTaskNum(notStartTaskNum);
|
||||
|
||||
List<TaskItemVO> taskUsers = taskUserMapper.selectUserTaskItem(taskID, LoginUtil.getCurrentUser().getID());
|
||||
taskVO.setLearningTask(task);
|
||||
taskVO.setTaskCourses(taskCourses);
|
||||
taskVO.setTaskResources(taskResources);
|
||||
taskVO.setTaskUsers(taskUsers);
|
||||
|
||||
taskVO.setTotalTaskNum(allTaskItems.size());
|
||||
|
||||
|
||||
|
||||
resultDomain.success("获取任务详情成功", taskVO);
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbTaskItem> getTaskCourses(String taskID) {
|
||||
ResultDomain<TbTaskItem> resultDomain = new ResultDomain<>();
|
||||
List<TbTaskItem> taskCourses = taskItemMapper.selectByTaskIdAndType(taskID, TaskItemType.COURSE.getValue());
|
||||
resultDomain.success("获取任务课程列表成功", taskCourses);
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbLearningTask> getTaskList(TbLearningTask filter) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
ResultDomain<TbLearningTask> resultDomain = new ResultDomain<>();
|
||||
List<TbLearningTask> taskList = learningTaskMapper.selectLearningTasks(filter);
|
||||
resultDomain.success("获取任务列表成功", taskList);
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbTaskResource> getTaskResources(String taskID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public ResultDomain<TbTaskItem> getTaskResources(String taskID) {
|
||||
ResultDomain<TbTaskItem> resultDomain = new ResultDomain<>();
|
||||
List<TbTaskItem> taskResources = taskItemMapper.selectByTaskIdAndType(taskID, TaskItemType.RESOURCE.getValue());
|
||||
resultDomain.success("获取任务资源列表成功", taskResources);
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -407,14 +519,28 @@ public class SCLearningTaskServiceImpl implements LearningTaskService {
|
||||
|
||||
@Override
|
||||
public ResultDomain<Boolean> removeTaskCourse(String taskID, String courseID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||
TbTaskItem taskItem = taskItemMapper.selectByTaskIdAndItemId(taskID, courseID, TaskItemType.COURSE.getValue());
|
||||
if (taskItem != null) {
|
||||
taskItemMapper.deleteTaskItem(taskItem);
|
||||
resultDomain.success("移除任务课程成功", true);
|
||||
} else {
|
||||
resultDomain.fail("任务课程不存在");
|
||||
}
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<Boolean> removeTaskResource(String taskID, String resourceID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||
TbTaskItem taskItem = taskItemMapper.selectByTaskIdAndItemId(taskID, resourceID, TaskItemType.RESOURCE.getValue());
|
||||
if (taskItem != null) {
|
||||
taskItemMapper.deleteTaskItem(taskItem);
|
||||
resultDomain.success("移除任务资源成功", true);
|
||||
} else {
|
||||
resultDomain.fail("任务资源不存在");
|
||||
}
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,9 +6,12 @@
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.study.TbLearningRecord">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="user_id" property="userID" jdbcType="VARCHAR"/>
|
||||
<result column="task_id" property="taskID" jdbcType="VARCHAR"/>
|
||||
<result column="resource_type" property="resourceType" jdbcType="INTEGER"/>
|
||||
<result column="resource_id" property="resourceID" jdbcType="VARCHAR"/>
|
||||
<result column="task_id" property="taskID" jdbcType="VARCHAR"/>
|
||||
<result column="course_id" property="courseID" jdbcType="VARCHAR"/>
|
||||
<result column="chapter_id" property="chapterID" jdbcType="VARCHAR"/>
|
||||
<result column="node_id" property="nodeID" jdbcType="VARCHAR"/>
|
||||
<result column="duration" property="duration" jdbcType="INTEGER"/>
|
||||
<result column="progress" property="progress" jdbcType="DECIMAL"/>
|
||||
<result column="is_complete" property="isComplete" jdbcType="BOOLEAN"/>
|
||||
@@ -20,7 +23,7 @@
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, resource_type, resource_id, task_id, duration, progress,
|
||||
id, user_id, task_id, resource_type, resource_id, course_id, chapter_id, node_id, duration, progress,
|
||||
is_complete, complete_time, last_learn_time, create_time, update_time
|
||||
</sql>
|
||||
|
||||
@@ -30,14 +33,23 @@
|
||||
<if test="userID != null and userID != ''">
|
||||
AND user_id = #{userID}
|
||||
</if>
|
||||
<if test="taskID != null and taskID != ''">
|
||||
AND task_id = #{taskID}
|
||||
</if>
|
||||
<if test="resourceType != null">
|
||||
AND resource_type = #{resourceType}
|
||||
</if>
|
||||
<if test="resourceID != null and resourceID != ''">
|
||||
AND resource_id = #{resourceID}
|
||||
</if>
|
||||
<if test="taskID != null and taskID != ''">
|
||||
AND task_id = #{taskID}
|
||||
<if test="courseID != null and courseID != ''">
|
||||
AND course_id = #{courseID}
|
||||
</if>
|
||||
<if test="chapterID != null and chapterID != ''">
|
||||
AND chapter_id = #{chapterID}
|
||||
</if>
|
||||
<if test="nodeID != null and nodeID != ''">
|
||||
AND node_id = #{nodeID}
|
||||
</if>
|
||||
<if test="isComplete != null">
|
||||
AND is_complete = #{isComplete}
|
||||
@@ -85,7 +97,7 @@
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_learning_record
|
||||
WHERE user_id = #{userId} AND resource_id = #{courseId}
|
||||
WHERE user_id = #{userId} AND course_id = #{courseId} AND resource_type = 2
|
||||
</select>
|
||||
|
||||
<!-- 根据状态查询学习记录列表 -->
|
||||
@@ -113,11 +125,11 @@
|
||||
<!-- 插入学习记录 -->
|
||||
<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
|
||||
id, user_id, task_id, resource_type, resource_id, course_id, chapter_id, node_id, duration, progress,
|
||||
is_complete, complete_time, last_learn_time, create_time
|
||||
) VALUES (
|
||||
#{id}, #{userID}, #{resourceType}, #{resourceID}, #{taskID}, #{duration}, #{progress},
|
||||
#{isComplete}, #{completeTime}, #{lastLearnTime}, #{createTime}, #{updateTime}
|
||||
#{id}, #{userID}, #{taskID}, #{resourceType}, #{resourceID}, #{courseID}, #{chapterID}, #{nodeID}, #{duration}, #{progress},
|
||||
#{isComplete}, #{completeTime}, #{lastLearnTime}, #{createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
@@ -125,18 +137,6 @@
|
||||
<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>
|
||||
@@ -152,6 +152,9 @@
|
||||
<if test="lastLearnTime != null">
|
||||
last_learn_time = #{lastLearnTime},
|
||||
</if>
|
||||
<if test="updater != null">
|
||||
updater = #{updater},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
|
||||
@@ -226,7 +226,7 @@
|
||||
|
||||
<select id="selectUserLearningTasksPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
tlt.id, tlt.task_id, tlt.name, tlt.description, tlt.start_time, tlt.end_time, tlt.status,
|
||||
tlt.id, tlt.task_id, tlt.name, tlt.description, tlt.start_time, tlt.end_time, ttu.status,
|
||||
tlt.creator, tlt.updater, tlt.create_time, tlt.update_time
|
||||
FROM tb_task_user ttu
|
||||
INNER JOIN tb_learning_task tlt ON ttu.task_id = tlt.task_id
|
||||
|
||||
@@ -1,209 +0,0 @@
|
||||
<?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.TaskCourseMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.study.TbTaskCourse">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="task_id" property="taskID" jdbcType="VARCHAR"/>
|
||||
<result column="course_id" property="courseID" jdbcType="VARCHAR"/>
|
||||
<result column="required" property="required" jdbcType="BOOLEAN"/>
|
||||
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
|
||||
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="TaskItemResultMap" type="org.xyzh.common.vo.TaskItemVO">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="task_id" property="taskID" jdbcType="VARCHAR"/>
|
||||
<result column="course_id" property="courseID" jdbcType="VARCHAR"/>
|
||||
<result column="course_name" property="courseName" jdbcType="VARCHAR"/>
|
||||
<result column="resource_id" property="resourceID" jdbcType="VARCHAR"/>
|
||||
<result column="resource_name" property="resourceName" jdbcType="VARCHAR"/>
|
||||
<result column="user_id" property="userID" jdbcType="VARCHAR"/>
|
||||
<result column="user_name" property="userName" jdbcType="VARCHAR"/>
|
||||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
<result column="progress" property="progress" jdbcType="DECIMAL"/>
|
||||
<result column="complete_time" property="completeTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="required" property="required" jdbcType="BOOLEAN"/>
|
||||
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
|
||||
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, task_id, course_id, required, order_num, creator, create_time
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<where>
|
||||
<if test="taskID != null and taskID != ''">
|
||||
AND task_id = #{taskID}
|
||||
</if>
|
||||
<if test="courseID != null and courseID != ''">
|
||||
AND course_id = #{courseID}
|
||||
</if>
|
||||
<if test="required != null">
|
||||
AND required = #{required}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- selectTaskCourses -->
|
||||
<select id="selectTaskCourses" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_task_course
|
||||
<include refid="Where_Clause"/>
|
||||
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>
|
||||
|
||||
<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="selectTaskItemByTaskId" resultMap="TaskItemResultMap">
|
||||
SELECT
|
||||
ttc.*,
|
||||
tc.name as course_name
|
||||
FROM tb_task_course ttc
|
||||
INNER JOIN tb_course tc ON ttc.course_id = tc.course_id
|
||||
WHERE ttc.task_id = #{taskId} and ttc.deleted = 0 and tc.deleted = 0
|
||||
ORDER BY ttc.order_num ASC, ttc.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.offset}
|
||||
</select>
|
||||
|
||||
<!-- 统计任务课程关联总数 -->
|
||||
<select id="countTaskCourses" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_task_course
|
||||
<include refid="Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,398 @@
|
||||
<?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.TaskItemMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.study.TbTaskItem">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="task_id" property="taskID" jdbcType="VARCHAR"/>
|
||||
<result column="item_type" property="itemType" jdbcType="INTEGER"/>
|
||||
<result column="item_id" property="itemID" jdbcType="VARCHAR"/>
|
||||
<result column="required" property="required" jdbcType="BOOLEAN"/>
|
||||
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
|
||||
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="updater" property="updater" jdbcType="VARCHAR"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="delete_time" property="deleteTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="TaskItemResultMap" type="org.xyzh.common.vo.TaskItemVO">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="task_id" property="taskID" jdbcType="VARCHAR"/>
|
||||
<result column="item_type" property="itemType" jdbcType="INTEGER"/>
|
||||
<result column="course_id" property="courseID" jdbcType="VARCHAR"/>
|
||||
<result column="course_name" property="courseName" jdbcType="VARCHAR"/>
|
||||
<result column="resource_id" property="resourceID" jdbcType="VARCHAR"/>
|
||||
<result column="resource_name" property="resourceName" jdbcType="VARCHAR"/>
|
||||
<result column="user_id" property="userID" jdbcType="VARCHAR"/>
|
||||
<result column="user_name" property="userName" jdbcType="VARCHAR"/>
|
||||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
<result column="progress" property="progress" jdbcType="DECIMAL"/>
|
||||
<result column="complete_time" property="completeTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="required" property="required" jdbcType="BOOLEAN"/>
|
||||
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
|
||||
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, task_id, item_type, item_id, required, order_num, creator, create_time,
|
||||
updater, update_time, delete_time, deleted
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="taskID != null and taskID != ''">
|
||||
AND task_id = #{taskID}
|
||||
</if>
|
||||
<if test="itemType != null">
|
||||
AND item_type = #{itemType}
|
||||
</if>
|
||||
<if test="itemID != null and itemID != ''">
|
||||
AND item_id = #{itemID}
|
||||
</if>
|
||||
<if test="required != null">
|
||||
AND required = #{required}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- selectTaskItems -->
|
||||
<select id="selectTaskItems" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_task_item
|
||||
<include refid="Where_Clause"/>
|
||||
ORDER BY order_num ASC, create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据关联ID查询关联信息 -->
|
||||
<select id="selectByRelationId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_task_item
|
||||
WHERE id = #{relationId} AND deleted = 0
|
||||
</select>
|
||||
|
||||
<!-- 根据任务ID查询项关联列表 -->
|
||||
<select id="selectByTaskId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_task_item
|
||||
WHERE task_id = #{taskId} AND deleted = 0
|
||||
ORDER BY order_num ASC, create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据任务ID和类型查询项关联列表 -->
|
||||
<select id="selectByTaskIdAndType" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_task_item
|
||||
WHERE task_id = #{taskId} AND item_type = #{itemType} AND deleted = 0
|
||||
ORDER BY order_num ASC, create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据任务ID查询任务项VO列表(带学习状态) -->
|
||||
<select id="selectTaskItemVOByTaskId" resultMap="TaskItemResultMap">
|
||||
SELECT
|
||||
tti.*,
|
||||
CASE
|
||||
WHEN tti.item_type = 1 THEN tr.title
|
||||
WHEN tti.item_type = 2 THEN tc.name
|
||||
END as item_name,
|
||||
CASE
|
||||
WHEN tti.item_type = 1 THEN tti.item_id
|
||||
ELSE NULL
|
||||
END as resource_id,
|
||||
CASE
|
||||
WHEN tti.item_type = 1 THEN tr.title
|
||||
ELSE NULL
|
||||
END as resource_name,
|
||||
CASE
|
||||
WHEN tti.item_type = 2 THEN tti.item_id
|
||||
ELSE NULL
|
||||
END as course_id,
|
||||
CASE
|
||||
WHEN tti.item_type = 2 THEN tc.name
|
||||
ELSE NULL
|
||||
END as course_name,
|
||||
-- 学习状态:0未开始 1进行中 2已完成
|
||||
CASE
|
||||
-- 资源类型:直接从学习记录查询
|
||||
WHEN tti.item_type = 1 THEN
|
||||
CASE
|
||||
WHEN lr_resource.is_complete = 1 THEN 2
|
||||
WHEN lr_resource.id IS NOT NULL THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
-- 课程类型:判断所有节点是否完成
|
||||
WHEN tti.item_type = 2 THEN
|
||||
CASE
|
||||
WHEN course_stats.total_nodes = 0 THEN 0
|
||||
WHEN course_stats.completed_nodes = course_stats.total_nodes THEN 2
|
||||
WHEN course_stats.completed_nodes > 0 THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
ELSE 0
|
||||
END as status,
|
||||
-- 学习进度
|
||||
CASE
|
||||
WHEN tti.item_type = 1 THEN COALESCE(lr_resource.progress, 0)
|
||||
WHEN tti.item_type = 2 THEN
|
||||
CASE
|
||||
WHEN course_stats.total_nodes = 0 THEN 0
|
||||
ELSE ROUND((course_stats.completed_nodes * 100.0 / course_stats.total_nodes), 2)
|
||||
END
|
||||
ELSE 0
|
||||
END as progress
|
||||
FROM tb_task_item tti
|
||||
LEFT JOIN tb_resource tr ON tti.item_type = 1 AND tti.item_id = tr.resource_id AND tr.deleted = 0
|
||||
LEFT JOIN tb_course tc ON tti.item_type = 2 AND tti.item_id = tc.course_id AND tc.deleted = 0
|
||||
-- 资源学习记录
|
||||
LEFT JOIN tb_learning_record lr_resource ON tti.item_type = 1
|
||||
AND lr_resource.resource_type = 1
|
||||
AND lr_resource.resource_id = tti.item_id
|
||||
AND lr_resource.task_id = tti.task_id
|
||||
AND lr_resource.deleted = 0
|
||||
-- 课程学习统计(统计课程下所有节点的完成情况)
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
tti.item_id as course_id,
|
||||
COUNT(DISTINCT tcn.node_id) as total_nodes,
|
||||
COUNT(DISTINCT CASE WHEN lr.is_complete = 1 THEN lr.node_id END) as completed_nodes
|
||||
FROM tb_task_item tti
|
||||
INNER JOIN tb_course_chapter tcc ON tti.item_type = 2 AND tti.item_id = tcc.course_id AND tcc.deleted = 0
|
||||
INNER JOIN tb_course_node tcn ON tcc.chapter_id = tcn.chapter_id AND tcn.deleted = 0
|
||||
LEFT JOIN tb_learning_record lr ON lr.resource_type = 2
|
||||
AND tti.item_id = lr.course_id
|
||||
AND lr.node_id = tcn.node_id
|
||||
AND lr.deleted = 0
|
||||
WHERE tti.task_id = #{taskId} AND tti.deleted = 0
|
||||
GROUP BY tti.item_id
|
||||
) course_stats ON tti.item_type = 2 AND course_stats.course_id = tti.item_id
|
||||
WHERE tti.task_id = #{taskId} AND tti.deleted = 0
|
||||
ORDER BY tti.order_num ASC, tti.create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据任务ID和用户ID查询任务项视图对象列表(包含该用户的学习状态) -->
|
||||
<select id="selectTaskItemVOByTaskIdAndUserId" resultMap="TaskItemResultMap">
|
||||
SELECT
|
||||
tti.*,
|
||||
CASE
|
||||
WHEN tti.item_type = 1 THEN tr.title
|
||||
WHEN tti.item_type = 2 THEN tc.name
|
||||
END as item_name,
|
||||
CASE
|
||||
WHEN tti.item_type = 1 THEN tti.item_id
|
||||
ELSE NULL
|
||||
END as resource_id,
|
||||
CASE
|
||||
WHEN tti.item_type = 1 THEN tr.title
|
||||
ELSE NULL
|
||||
END as resource_name,
|
||||
CASE
|
||||
WHEN tti.item_type = 2 THEN tti.item_id
|
||||
ELSE NULL
|
||||
END as course_id,
|
||||
CASE
|
||||
WHEN tti.item_type = 2 THEN tc.name
|
||||
ELSE NULL
|
||||
END as course_name,
|
||||
-- 学习状态:0未开始 1进行中 2已完成
|
||||
CASE
|
||||
-- 资源类型:直接从学习记录查询
|
||||
WHEN tti.item_type = 1 THEN
|
||||
CASE
|
||||
WHEN lr_resource.is_complete = 1 THEN 2
|
||||
WHEN lr_resource.id IS NOT NULL THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
-- 课程类型:判断所有节点是否完成
|
||||
WHEN tti.item_type = 2 THEN
|
||||
CASE
|
||||
WHEN course_stats.total_nodes = 0 THEN 0
|
||||
WHEN course_stats.completed_nodes = course_stats.total_nodes THEN 2
|
||||
WHEN course_stats.completed_nodes > 0 THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
ELSE 0
|
||||
END as status,
|
||||
-- 学习进度
|
||||
CASE
|
||||
WHEN tti.item_type = 1 THEN COALESCE(lr_resource.progress, 0)
|
||||
WHEN tti.item_type = 2 THEN
|
||||
CASE
|
||||
WHEN course_stats.total_nodes = 0 THEN 0
|
||||
ELSE ROUND((course_stats.completed_nodes * 100.0 / course_stats.total_nodes), 2)
|
||||
END
|
||||
ELSE 0
|
||||
END as progress
|
||||
FROM tb_task_item tti
|
||||
LEFT JOIN tb_resource tr ON tti.item_type = 1 AND tti.item_id = tr.resource_id AND tr.deleted = 0
|
||||
LEFT JOIN tb_course tc ON tti.item_type = 2 AND tti.item_id = tc.course_id AND tc.deleted = 0
|
||||
-- 资源学习记录(限定用户)
|
||||
LEFT JOIN tb_learning_record lr_resource ON tti.item_type = 1
|
||||
AND lr_resource.resource_type = 1
|
||||
AND lr_resource.resource_id = tti.item_id
|
||||
AND lr_resource.task_id = tti.task_id
|
||||
AND lr_resource.user_id = #{userId}
|
||||
AND lr_resource.deleted = 0
|
||||
-- 课程学习统计(统计课程下所有节点的完成情况,限定用户)
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
tti.item_id as course_id,
|
||||
COUNT(DISTINCT tcn.node_id) as total_nodes,
|
||||
COUNT(DISTINCT CASE WHEN lr.is_complete = 1 THEN lr.node_id END) as completed_nodes
|
||||
FROM tb_task_item tti
|
||||
INNER JOIN tb_course_chapter tcc ON tti.item_type = 2 AND tti.item_id = tcc.course_id AND tcc.deleted = 0
|
||||
INNER JOIN tb_course_node tcn ON tcc.chapter_id = tcn.chapter_id AND tcn.deleted = 0
|
||||
LEFT JOIN tb_learning_record lr ON lr.resource_type = 2
|
||||
AND tti.item_id = lr.course_id
|
||||
AND lr.node_id = tcn.node_id
|
||||
AND lr.user_id = #{userId}
|
||||
AND lr.deleted = 0
|
||||
WHERE tti.task_id = #{taskId} AND tti.deleted = 0
|
||||
GROUP BY tti.item_id
|
||||
) course_stats ON tti.item_type = 2 AND course_stats.course_id = tti.item_id
|
||||
WHERE tti.task_id = #{taskId} AND tti.deleted = 0
|
||||
ORDER BY tti.order_num ASC, tti.create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据项ID查询任务关联列表 -->
|
||||
<select id="selectByItemId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_task_item
|
||||
WHERE item_id = #{itemId} AND item_type = #{itemType} AND deleted = 0
|
||||
ORDER BY order_num ASC, create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据任务ID和项ID查询关联信息 -->
|
||||
<select id="selectByTaskIdAndItemId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_task_item
|
||||
WHERE task_id = #{taskId} AND item_id = #{itemId} AND item_type = #{itemType} AND deleted = 0
|
||||
</select>
|
||||
|
||||
<!-- 检查任务项关联是否存在 -->
|
||||
<select id="countByTaskIdAndItemId" resultType="int">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_task_item
|
||||
WHERE task_id = #{taskId} AND item_id = #{itemId} AND item_type = #{itemType} AND deleted = 0
|
||||
<if test="excludeId != null and excludeId != ''">
|
||||
AND id != #{excludeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 插入任务项关联 -->
|
||||
<insert id="insertTaskItem" parameterType="org.xyzh.common.dto.study.TbTaskItem">
|
||||
INSERT INTO tb_task_item (
|
||||
id, task_id, item_type, item_id, required, order_num, creator, create_time
|
||||
) VALUES (
|
||||
#{id}, #{taskID}, #{itemType}, #{itemID}, #{required}, #{orderNum}, #{creator}, #{createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 更新任务项关联 -->
|
||||
<update id="updateTaskItem" parameterType="org.xyzh.common.dto.study.TbTaskItem">
|
||||
UPDATE tb_task_item
|
||||
<set>
|
||||
<if test="taskID != null and taskID != ''">
|
||||
task_id = #{taskID},
|
||||
</if>
|
||||
<if test="itemType != null">
|
||||
item_type = #{itemType},
|
||||
</if>
|
||||
<if test="itemID != null and itemID != ''">
|
||||
item_id = #{itemID},
|
||||
</if>
|
||||
<if test="required != null">
|
||||
required = #{required},
|
||||
</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>
|
||||
|
||||
<!-- 删除任务项关联(软删除) -->
|
||||
<update id="deleteTaskItem" parameterType="org.xyzh.common.dto.study.TbTaskItem">
|
||||
UPDATE tb_task_item
|
||||
SET deleted = 1, delete_time = NOW()
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 批量插入任务项关联 -->
|
||||
<insert id="batchInsertTaskItems" parameterType="java.util.List">
|
||||
INSERT INTO tb_task_item (
|
||||
id, task_id, item_type, item_id, required, order_num, creator, create_time
|
||||
) VALUES
|
||||
<foreach collection="taskItemList" item="item" separator=",">
|
||||
(
|
||||
#{item.id}, #{item.taskID}, #{item.itemType}, #{item.itemID}, #{item.required},
|
||||
#{item.orderNum}, #{item.creator}, #{item.createTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量删除任务项关联(软删除) -->
|
||||
<update id="batchDeleteTaskItems">
|
||||
UPDATE tb_task_item
|
||||
SET deleted = 1, delete_time = NOW()
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 根据任务ID批量删除项关联(软删除) -->
|
||||
<update id="deleteByTaskId">
|
||||
UPDATE tb_task_item
|
||||
SET deleted = 1, delete_time = NOW()
|
||||
WHERE task_id = #{taskId}
|
||||
</update>
|
||||
|
||||
<!-- 根据项ID批量删除任务关联(软删除) -->
|
||||
<update id="deleteByItemId">
|
||||
UPDATE tb_task_item
|
||||
SET deleted = 1, delete_time = NOW()
|
||||
WHERE item_id = #{itemId} AND item_type = #{itemType}
|
||||
</update>
|
||||
|
||||
<!-- 分页查询任务项关联 -->
|
||||
<select id="selectTaskItemsPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_task_item
|
||||
<include refid="Where_Clause" />
|
||||
ORDER BY order_num ASC, create_time ASC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
||||
</select>
|
||||
|
||||
<!-- 统计任务项关联总数 -->
|
||||
<select id="countTaskItems" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_task_item
|
||||
<include refid="Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,208 +0,0 @@
|
||||
<?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.TaskResourceMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.study.TbTaskResource">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="task_id" property="taskID" jdbcType="VARCHAR"/>
|
||||
<result column="resource_id" property="resourceID" jdbcType="VARCHAR"/>
|
||||
<result column="required" property="required" jdbcType="BOOLEAN"/>
|
||||
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
|
||||
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="TaskItemResultMap" type="org.xyzh.common.vo.TaskItemVO">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="task_id" property="taskID" jdbcType="VARCHAR"/>
|
||||
<result column="course_id" property="courseID" jdbcType="VARCHAR"/>
|
||||
<result column="course_name" property="courseName" jdbcType="VARCHAR"/>
|
||||
<result column="resource_id" property="resourceID" jdbcType="VARCHAR"/>
|
||||
<result column="resource_name" property="resourceName" jdbcType="VARCHAR"/>
|
||||
<result column="user_id" property="userID" jdbcType="VARCHAR"/>
|
||||
<result column="user_name" property="userName" jdbcType="VARCHAR"/>
|
||||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
<result column="progress" property="progress" jdbcType="DECIMAL"/>
|
||||
<result column="complete_time" property="completeTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="required" property="required" jdbcType="BOOLEAN"/>
|
||||
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
|
||||
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, task_id, resource_id, required, order_num, creator, create_time
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<where>
|
||||
<if test="taskID != null and taskID != ''">
|
||||
AND task_id = #{taskID}
|
||||
</if>
|
||||
<if test="resourceID != null and resourceID != ''">
|
||||
AND resource_id = #{resourceID}
|
||||
</if>
|
||||
<if test="required != null">
|
||||
AND required = #{required}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- selectTaskResources -->
|
||||
<select id="selectTaskResources" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_task_resource
|
||||
<include refid="Where_Clause"/>
|
||||
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>
|
||||
|
||||
<select id="selectTaskItemByTaskId" resultMap="TaskItemResultMap">
|
||||
SELECT
|
||||
ttr.*,
|
||||
tr.title as resource_name
|
||||
FROM tb_task_resource ttr
|
||||
INNER JOIN tb_resource tr ON ttr.resource_id = tr.resource_id
|
||||
WHERE ttr.task_id = #{taskId} and ttr.deleted = 0 and tr.deleted = 0
|
||||
ORDER BY ttr.order_num ASC, ttr.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.offset}
|
||||
</select>
|
||||
|
||||
<!-- 统计任务资源关联总数 -->
|
||||
<select id="countTaskResources" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_task_resource
|
||||
<include refid="Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -94,6 +94,16 @@
|
||||
ORDER BY ttu.create_time ASC
|
||||
</select>
|
||||
|
||||
<select id="selectUserTaskItem" resultMap="TaskItemResultMap">
|
||||
SELECT
|
||||
ttu.*,
|
||||
tu.username
|
||||
FROM tb_task_user ttu
|
||||
INNER JOIN tb_sys_user tu ON ttu.user_id = tu.id
|
||||
WHERE ttu.task_id = #{taskId} and ttu.user_id = #{userId} and ttu.deleted = 0 and tu.deleted = 0
|
||||
ORDER BY ttu.create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID查询任务关联列表 -->
|
||||
<select id="selectByUserId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
@@ -142,14 +152,33 @@
|
||||
<!-- 插入任务用户关联 -->
|
||||
<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
|
||||
id, task_id, user_id, dept_id,creator, create_time
|
||||
) VALUES (
|
||||
#{id}, #{taskID}, #{userID}, #{deptID}, #{status}, #{progress}, #{completeTime},
|
||||
#{creator}, #{createTime}
|
||||
#{id}, #{taskID}, #{userID}, #{deptID}, #{creator}, #{createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 更新任务用户关联 -->
|
||||
<update id="updateTaskUser" parameterType="org.xyzh.common.dto.study.TbTaskUser">
|
||||
UPDATE tb_task_user
|
||||
<set>
|
||||
<if test="status != null">
|
||||
status = #{status},
|
||||
</if>
|
||||
<if test="progress != null">
|
||||
progress = #{progress},
|
||||
</if>
|
||||
<if test="completeTime != null">
|
||||
complete_time = #{completeTime},
|
||||
</if>
|
||||
<if test="updater != null">
|
||||
updater = #{updater},
|
||||
</if>
|
||||
update_time = NOW()
|
||||
</set>
|
||||
WHERE task_id = #{taskID} AND user_id = #{userID} AND deleted = 0
|
||||
</update>
|
||||
|
||||
<!-- 删除任务用户关联 -->
|
||||
<delete id="deleteTaskUser" parameterType="org.xyzh.common.dto.study.TbTaskUser">
|
||||
DELETE FROM tb_task_user
|
||||
|
||||
@@ -38,6 +38,11 @@
|
||||
<artifactId>common-all</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>system</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
package org.xyzh.usercenter.controller;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.xyzh.api.usercenter.achievement.UserAchievementService;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.dto.usercenter.TbAchievement;
|
||||
import org.xyzh.common.dto.usercenter.TbUserAchievement;
|
||||
|
||||
/**
|
||||
* @description 用户成就控制器
|
||||
* @filename UserAchievementController.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/usercenter/achievement")
|
||||
public class UserAchievementController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserAchievementController.class);
|
||||
|
||||
@Autowired
|
||||
private UserAchievementService userAchievementService;
|
||||
|
||||
/**
|
||||
* 获取所有成就列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public ResultDomain<TbAchievement> getAllAchievements(
|
||||
@RequestParam(required = false) Integer type,
|
||||
@RequestParam(required = false) Integer level) {
|
||||
return userAchievementService.getAllAchievements(type, level);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户已获得的成就
|
||||
*/
|
||||
@GetMapping("/user/{userID}")
|
||||
public ResultDomain<TbUserAchievement> getUserAchievements(
|
||||
@PathVariable String userID,
|
||||
@RequestParam(required = false) Integer type) {
|
||||
return userAchievementService.getUserAchievements(userID, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户是否已获得成就
|
||||
*/
|
||||
@GetMapping("/check/{userID}/{achievementID}")
|
||||
public ResultDomain<Boolean> hasAchievement(
|
||||
@PathVariable String userID,
|
||||
@PathVariable String achievementID) {
|
||||
return userAchievementService.hasAchievement(userID, achievementID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 授予用户成就
|
||||
*/
|
||||
@PostMapping("/grant")
|
||||
public ResultDomain<TbUserAchievement> grantAchievement(
|
||||
@RequestParam String userID,
|
||||
@RequestParam String achievementID) {
|
||||
return userAchievementService.grantAchievement(userID, achievementID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成就详情
|
||||
*/
|
||||
@GetMapping("/detail/{achievementID}")
|
||||
public ResultDomain<TbAchievement> getAchievementDetail(@PathVariable String achievementID) {
|
||||
return userAchievementService.getAchievementDetail(achievementID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户是否满足成就条件
|
||||
*/
|
||||
@GetMapping("/condition/{userID}/{achievementID}")
|
||||
public ResultDomain<Boolean> checkAchievementCondition(
|
||||
@PathVariable String userID,
|
||||
@PathVariable String achievementID) {
|
||||
return userAchievementService.checkAchievementCondition(userID, achievementID);
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.xyzh.api.usercenter.collection.UserCollectionService;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.dto.user.TbSysUser;
|
||||
import org.xyzh.common.dto.usercenter.TbUserCollection;
|
||||
|
||||
import org.xyzh.common.dto.user.TbSysUser;
|
||||
import org.xyzh.system.utils.LoginUtil;
|
||||
/**
|
||||
* @description 用户收藏控制器
|
||||
* @filename UserCollectionController.java
|
||||
@@ -16,7 +18,7 @@ import org.xyzh.common.dto.usercenter.TbUserCollection;
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/usercenter/collection")
|
||||
@RequestMapping("/usercenter/collections")
|
||||
public class UserCollectionController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserCollectionController.class);
|
||||
|
||||
@@ -37,7 +39,7 @@ public class UserCollectionController {
|
||||
/**
|
||||
* 添加收藏
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@PostMapping("/collect")
|
||||
public ResultDomain<TbUserCollection> addCollection(@RequestBody TbUserCollection userCollection) {
|
||||
return userCollectionService.addCollection(userCollection);
|
||||
}
|
||||
@@ -45,12 +47,9 @@ public class UserCollectionController {
|
||||
/**
|
||||
* 取消收藏
|
||||
*/
|
||||
@DeleteMapping("/remove")
|
||||
public ResultDomain<Boolean> removeCollection(
|
||||
@RequestParam String userID,
|
||||
@RequestParam String resourceID,
|
||||
@RequestParam Integer resourceType) {
|
||||
return userCollectionService.removeCollection(userID, resourceType, resourceID);
|
||||
@DeleteMapping("/collect")
|
||||
public ResultDomain<Boolean> removeCollection(@RequestBody TbUserCollection userCollection) {
|
||||
return userCollectionService.removeCollection(userCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,10 +57,15 @@ public class UserCollectionController {
|
||||
*/
|
||||
@GetMapping("/check")
|
||||
public ResultDomain<Boolean> isCollected(
|
||||
@RequestParam String userID,
|
||||
@RequestParam String resourceID,
|
||||
@RequestParam Integer resourceType) {
|
||||
return userCollectionService.isCollected(userID, resourceType, resourceID);
|
||||
@RequestParam(value = "collectionID", required = false) String collectionID,
|
||||
@RequestParam(value = "collectionType", required = false) Integer collectionType) {
|
||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||
TbSysUser user = LoginUtil.getCurrentUser();
|
||||
if (user == null) {
|
||||
resultDomain.fail("请先登录");
|
||||
return resultDomain;
|
||||
}
|
||||
return userCollectionService.isCollected(user.getID(), collectionType, collectionID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
package org.xyzh.usercenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.xyzh.common.core.page.PageParam;
|
||||
import org.xyzh.common.dto.usercenter.TbAchievement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description AchievementMapper.java文件描述 成就数据访问层
|
||||
* @filename AchievementMapper.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
@Mapper
|
||||
public interface AchievementMapper extends BaseMapper<TbAchievement> {
|
||||
|
||||
/**
|
||||
* @description 查询成就列表
|
||||
* @param filter 过滤条件
|
||||
* @return List<TbAchievement> 成就列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbAchievement> selectAchievements(TbAchievement filter);
|
||||
|
||||
/**
|
||||
* @description 根据成就ID查询成就信息
|
||||
* @param achievementId 成就ID
|
||||
* @return TbAchievement 成就信息
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbAchievement selectByAchievementId(@Param("achievementId") String achievementId);
|
||||
|
||||
/**
|
||||
* @description 根据类型查询成就列表
|
||||
* @param type 成就类型
|
||||
* @return List<TbAchievement> 成就列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbAchievement> selectByType(@Param("type") Integer type);
|
||||
|
||||
/**
|
||||
* @description 根据类型和等级查询成就列表
|
||||
* @param type 成就类型
|
||||
* @param level 成就等级
|
||||
* @return List<TbAchievement> 成就列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbAchievement> selectByTypeAndLevel(@Param("type") Integer type, @Param("level") Integer level);
|
||||
|
||||
/**
|
||||
* @description 查询成就排行榜
|
||||
* @param limit 限制数量
|
||||
* @return List<TbAchievement> 成就排行榜
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbAchievement> selectAchievementRanking(@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* @description 检查成就名称是否存在
|
||||
* @param name 成就名称
|
||||
* @param excludeId 排除的成就ID(用于更新时排除自身)
|
||||
* @return int 存在的数量
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int countByName(@Param("name") String name, @Param("excludeId") String excludeId);
|
||||
|
||||
/**
|
||||
* @description 插入成就
|
||||
* @param achievement 成就
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int insertAchievement(TbAchievement achievement);
|
||||
|
||||
/**
|
||||
* @description 更新成就
|
||||
* @param achievement 成就
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int updateAchievement(TbAchievement achievement);
|
||||
|
||||
/**
|
||||
* @description 删除成就
|
||||
* @param achievement 成就
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deleteAchievement(TbAchievement achievement);
|
||||
|
||||
/**
|
||||
* @description 批量插入成就
|
||||
* @param achievementList 成就列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchInsertAchievements(@Param("achievementList") List<TbAchievement> achievementList);
|
||||
|
||||
/**
|
||||
* @description 批量删除成就
|
||||
* @param ids 成就ID列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchDeleteAchievements(@Param("ids") List<String> ids);
|
||||
|
||||
/**
|
||||
* @description 分页查询成就
|
||||
* @param filter 过滤条件
|
||||
* @param pageParam 分页参数
|
||||
* @return List<TbAchievement> 成就列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbAchievement> selectAchievementsPage(@Param("filter") TbAchievement filter, @Param("pageParam") PageParam pageParam);
|
||||
|
||||
/**
|
||||
* @description 统计成就总数
|
||||
* @param filter 过滤条件
|
||||
* @return long 总数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
long countAchievements(@Param("filter") TbAchievement filter);
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
package org.xyzh.usercenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.xyzh.common.core.page.PageParam;
|
||||
import org.xyzh.common.dto.usercenter.TbUserAchievement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description UserAchievementMapper.java文件描述 用户成就数据访问层
|
||||
* @filename UserAchievementMapper.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserAchievementMapper extends BaseMapper<TbUserAchievement> {
|
||||
|
||||
/**
|
||||
* @description 查询用户成就列表
|
||||
* @param filter 过滤条件
|
||||
* @return List<TbUserAchievement> 用户成就列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserAchievement> selectUserAchievements(TbUserAchievement filter);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID查询成就记录
|
||||
* @param userId 用户ID
|
||||
* @return List<TbUserAchievement> 成就记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserAchievement> selectByUserId(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID和成就ID查询成就记录
|
||||
* @param userId 用户ID
|
||||
* @param achievementId 成就ID
|
||||
* @return List<TbUserAchievement> 成就记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserAchievement> selectByUserIdAndAchievementId(@Param("userId") String userId, @Param("achievementId") String achievementId);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID查询成就记录(包含用户基本信息)
|
||||
* @param userId 用户ID
|
||||
* @return List<TbUserAchievement> 成就记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserAchievement> selectUserAchievementsWithUser(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 查询用户成就统计
|
||||
* @param userId 用户ID
|
||||
* @return TbUserAchievement 成就统计信息
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbUserAchievement selectAchievementStatistics(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 插入用户成就
|
||||
* @param userAchievement 用户成就
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int insertUserAchievement(TbUserAchievement userAchievement);
|
||||
|
||||
/**
|
||||
* @description 更新用户成就
|
||||
* @param userAchievement 用户成就
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int updateUserAchievement(TbUserAchievement userAchievement);
|
||||
|
||||
/**
|
||||
* @description 删除用户成就
|
||||
* @param userAchievement 用户成就
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deleteUserAchievement(TbUserAchievement userAchievement);
|
||||
|
||||
/**
|
||||
* @description 批量插入用户成就
|
||||
* @param userAchievementList 用户成就列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchInsertUserAchievements(@Param("userAchievementList") List<TbUserAchievement> userAchievementList);
|
||||
|
||||
/**
|
||||
* @description 批量删除用户成就
|
||||
* @param ids 成就ID列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchDeleteUserAchievements(@Param("ids") List<String> ids);
|
||||
|
||||
/**
|
||||
* @description 分页查询用户成就
|
||||
* @param filter 过滤条件
|
||||
* @param pageParam 分页参数
|
||||
* @return List<TbUserAchievement> 用户成就列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserAchievement> selectUserAchievementsPage(@Param("filter") TbUserAchievement filter, @Param("pageParam") PageParam pageParam);
|
||||
|
||||
/**
|
||||
* @description 统计用户成就总数
|
||||
* @param filter 过滤条件
|
||||
* @return long 总数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
long countUserAchievements(@Param("filter") TbUserAchievement filter);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package org.xyzh.usercenter.service;
|
||||
|
||||
import org.xyzh.api.usercenter.achievement.UserAchievementService;
|
||||
|
||||
/**
|
||||
* @description 用户成就服务接口
|
||||
* @filename UCUserAchievementService.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
public interface UCUserAchievementService extends UserAchievementService {
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package org.xyzh.usercenter.service.impl;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.dto.usercenter.TbAchievement;
|
||||
import org.xyzh.common.dto.usercenter.TbUserAchievement;
|
||||
import org.xyzh.usercenter.mapper.AchievementMapper;
|
||||
import org.xyzh.usercenter.mapper.UserAchievementMapper;
|
||||
import org.xyzh.usercenter.service.UCUserAchievementService;
|
||||
|
||||
/**
|
||||
* @description 用户成就服务实现类
|
||||
* @filename UCUserAchievementServiceImpl.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
@Service
|
||||
public class UCUserAchievementServiceImpl implements UCUserAchievementService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UCUserAchievementServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private AchievementMapper achievementMapper;
|
||||
|
||||
@Autowired
|
||||
private UserAchievementMapper userAchievementMapper;
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbAchievement> getAllAchievements(Integer type, Integer level) {
|
||||
// TODO: 实现获取所有成就列表
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbUserAchievement> getUserAchievements(String userID, Integer type) {
|
||||
// TODO: 实现获取用户已获得的成就
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<Boolean> hasAchievement(String userID, String achievementID) {
|
||||
// TODO: 实现检查用户是否已获得成就
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbUserAchievement> grantAchievement(String userID, String achievementID) {
|
||||
// TODO: 实现授予用户成就
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbAchievement> getAchievementDetail(String achievementID) {
|
||||
// TODO: 实现获取成就详情
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<Boolean> checkAchievementCondition(String userID, String achievementID) {
|
||||
// TODO: 实现检查用户是否满足成就条件
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.xyzh.usercenter.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -7,7 +8,9 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.dto.user.TbSysUser;
|
||||
import org.xyzh.common.dto.usercenter.TbUserCollection;
|
||||
import org.xyzh.system.utils.LoginUtil;
|
||||
import org.xyzh.usercenter.mapper.UserCollectionMapper;
|
||||
import org.xyzh.usercenter.service.UCUserCollectionService;
|
||||
|
||||
@@ -28,6 +31,14 @@ public class UCUserCollectionServiceImpl implements UCUserCollectionService {
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbUserCollection> addCollection(TbUserCollection userCollection) {
|
||||
TbSysUser user = LoginUtil.getCurrentUser();
|
||||
if (user == null) {
|
||||
ResultDomain<TbUserCollection> resultDomain = new ResultDomain<>();
|
||||
resultDomain.fail("请先登录");
|
||||
return resultDomain;
|
||||
}
|
||||
userCollection.setUserID(user.getID());
|
||||
userCollection.setCreateTime(new Date());
|
||||
int result = userCollectionMapper.insertUserCollection(userCollection);
|
||||
if (result > 0) {
|
||||
ResultDomain<TbUserCollection> resultDomain = new ResultDomain<>();
|
||||
@@ -82,12 +93,8 @@ public class UCUserCollectionServiceImpl implements UCUserCollectionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<Boolean> removeCollection(String userID, Integer collectionType, String collectionID) {
|
||||
TbUserCollection filter = new TbUserCollection();
|
||||
filter.setUserID(userID);
|
||||
filter.setCollectionType(collectionType);
|
||||
filter.setCollectionID(collectionID);
|
||||
int result = userCollectionMapper.deleteUserCollection(filter);
|
||||
public ResultDomain<Boolean> removeCollection(TbUserCollection userCollection) {
|
||||
int result = userCollectionMapper.deleteUserCollection(userCollection);
|
||||
if (result > 0) {
|
||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||
resultDomain.success("删除收藏成功", true);
|
||||
|
||||
@@ -1,463 +0,0 @@
|
||||
<?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.usercenter.mapper.AchievementMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
<id column="id" property="id" />
|
||||
<result column="achievement_id" property="achievementId" />
|
||||
<result column="name" property="name" />
|
||||
<result column="description" property="description" />
|
||||
<result column="icon" property="icon" />
|
||||
<result column="type" property="type" />
|
||||
<result column="level" property="level" />
|
||||
<result column="condition_type" property="conditionType" />
|
||||
<result column="condition_value" property="conditionValue" />
|
||||
<result column="points" property="points" />
|
||||
<result column="order_num" property="orderNum" />
|
||||
<result column="creator" property="creator" />
|
||||
<result column="updater" property="updater" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="delete_time" property="deleteTime" />
|
||||
<result column="deleted" property="deleted" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 字段列表 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, achievement_id, name, description, icon, type, level, condition_type,
|
||||
condition_value, points, order_num, creator, updater, create_time, update_time,
|
||||
delete_time, deleted
|
||||
</sql>
|
||||
|
||||
<!-- 查询条件 -->
|
||||
<sql id="Base_Where_Clause">
|
||||
<where>
|
||||
<if test="filter != null">
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.achievementId != null and filter.achievementId != ''">
|
||||
AND achievement_id = #{filter.achievementId}
|
||||
</if>
|
||||
<if test="filter.name != null and filter.name != ''">
|
||||
AND name LIKE CONCAT('%', #{filter.name}, '%')
|
||||
</if>
|
||||
<if test="filter.type != null">
|
||||
AND type = #{filter.type}
|
||||
</if>
|
||||
<if test="filter.level != null">
|
||||
AND level = #{filter.level}
|
||||
</if>
|
||||
<if test="filter.conditionType != null">
|
||||
AND condition_type = #{filter.conditionType}
|
||||
</if>
|
||||
<if test="filter.points != null">
|
||||
AND points = #{filter.points}
|
||||
</if>
|
||||
<if test="filter.creator != null and filter.creator != ''">
|
||||
AND creator = #{filter.creator}
|
||||
</if>
|
||||
<if test="filter.deleted != null">
|
||||
AND deleted = #{filter.deleted}
|
||||
</if>
|
||||
<if test="filter.createTime != null">
|
||||
AND create_time = #{filter.createTime}
|
||||
</if>
|
||||
<if test="filter.updateTime != null">
|
||||
AND update_time = #{filter.updateTime}
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 根据ID查询单条记录 -->
|
||||
<select id="selectByIdCustom" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询单条记录 -->
|
||||
<select id="selectOne" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询列表 -->
|
||||
<select id="selectList" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据条件分页查询 -->
|
||||
<select id="selectPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询记录(支持排序) -->
|
||||
<select id="selectListWithOrder" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
<if test="orderDirection != null and orderDirection != ''">
|
||||
${orderDirection}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据条件分页查询(支持排序) -->
|
||||
<select id="selectPageWithOrder" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
<if test="orderDirection != null and orderDirection != ''">
|
||||
${orderDirection}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 插入单条记录 -->
|
||||
<insert id="insertOneCustom" parameterType="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
INSERT INTO tb_achievement (
|
||||
id, achievement_id, name, description, icon, type, level, condition_type,
|
||||
condition_value, points, order_num, creator, updater, create_time, update_time,
|
||||
delete_time, deleted
|
||||
) VALUES (
|
||||
#{entity.id}, #{entity.achievementId}, #{entity.name}, #{entity.description}, #{entity.icon},
|
||||
#{entity.type}, #{entity.level}, #{entity.conditionType}, #{entity.conditionValue},
|
||||
#{entity.points}, #{entity.orderNum}, #{entity.creator}, #{entity.updater},
|
||||
#{entity.createTime}, #{entity.updateTime}, #{entity.deleteTime}, #{entity.deleted}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 批量插入记录 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO tb_achievement (
|
||||
id, achievement_id, name, description, icon, type, level, condition_type,
|
||||
condition_value, points, order_num, creator, updater, create_time, update_time,
|
||||
delete_time, deleted
|
||||
) VALUES
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(
|
||||
#{entity.id}, #{entity.achievementId}, #{entity.name}, #{entity.description}, #{entity.icon},
|
||||
#{entity.type}, #{entity.level}, #{entity.conditionType}, #{entity.conditionValue},
|
||||
#{entity.points}, #{entity.orderNum}, #{entity.creator}, #{entity.updater},
|
||||
#{entity.createTime}, #{entity.updateTime}, #{entity.deleteTime}, #{entity.deleted}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 根据ID更新记录 -->
|
||||
<update id="updateByIdCustom" parameterType="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
UPDATE tb_achievement
|
||||
<set>
|
||||
<if test="entity.achievementId != null and entity.achievementId != ''">
|
||||
achievement_id = #{entity.achievementId},
|
||||
</if>
|
||||
<if test="entity.name != null and entity.name != ''">
|
||||
name = #{entity.name},
|
||||
</if>
|
||||
<if test="entity.description != null and entity.description != ''">
|
||||
description = #{entity.description},
|
||||
</if>
|
||||
<if test="entity.icon != null and entity.icon != ''">
|
||||
icon = #{entity.icon},
|
||||
</if>
|
||||
<if test="entity.type != null">
|
||||
type = #{entity.type},
|
||||
</if>
|
||||
<if test="entity.level != null">
|
||||
level = #{entity.level},
|
||||
</if>
|
||||
<if test="entity.conditionType != null">
|
||||
condition_type = #{entity.conditionType},
|
||||
</if>
|
||||
<if test="entity.conditionValue != null">
|
||||
condition_value = #{entity.conditionValue},
|
||||
</if>
|
||||
<if test="entity.points != null">
|
||||
points = #{entity.points},
|
||||
</if>
|
||||
<if test="entity.orderNum != null">
|
||||
order_num = #{entity.orderNum},
|
||||
</if>
|
||||
<if test="entity.creator != null and entity.creator != ''">
|
||||
creator = #{entity.creator},
|
||||
</if>
|
||||
<if test="entity.updater != null and entity.updater != ''">
|
||||
updater = #{entity.updater},
|
||||
</if>
|
||||
<if test="entity.updateTime != null">
|
||||
update_time = #{entity.updateTime},
|
||||
</if>
|
||||
<if test="entity.deleteTime != null">
|
||||
delete_time = #{entity.deleteTime},
|
||||
</if>
|
||||
<if test="entity.deleted != null">
|
||||
deleted = #{entity.deleted},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{entity.id}
|
||||
</update>
|
||||
|
||||
<!-- 根据条件更新记录 -->
|
||||
<update id="updateByFilter" parameterType="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
UPDATE tb_achievement
|
||||
<set>
|
||||
<if test="entity.achievementId != null and entity.achievementId != ''">
|
||||
achievement_id = #{entity.achievementId},
|
||||
</if>
|
||||
<if test="entity.name != null and entity.name != ''">
|
||||
name = #{entity.name},
|
||||
</if>
|
||||
<if test="entity.description != null and entity.description != ''">
|
||||
description = #{entity.description},
|
||||
</if>
|
||||
<if test="entity.icon != null and entity.icon != ''">
|
||||
icon = #{entity.icon},
|
||||
</if>
|
||||
<if test="entity.type != null">
|
||||
type = #{entity.type},
|
||||
</if>
|
||||
<if test="entity.level != null">
|
||||
level = #{entity.level},
|
||||
</if>
|
||||
<if test="entity.conditionType != null">
|
||||
condition_type = #{entity.conditionType},
|
||||
</if>
|
||||
<if test="entity.conditionValue != null">
|
||||
condition_value = #{entity.conditionValue},
|
||||
</if>
|
||||
<if test="entity.points != null">
|
||||
points = #{entity.points},
|
||||
</if>
|
||||
<if test="entity.orderNum != null">
|
||||
order_num = #{entity.orderNum},
|
||||
</if>
|
||||
<if test="entity.creator != null and entity.creator != ''">
|
||||
creator = #{entity.creator},
|
||||
</if>
|
||||
<if test="entity.updater != null and entity.updater != ''">
|
||||
updater = #{entity.updater},
|
||||
</if>
|
||||
<if test="entity.updateTime != null">
|
||||
update_time = #{entity.updateTime},
|
||||
</if>
|
||||
<if test="entity.deleteTime != null">
|
||||
delete_time = #{entity.deleteTime},
|
||||
</if>
|
||||
<if test="entity.deleted != null">
|
||||
deleted = #{entity.deleted},
|
||||
</if>
|
||||
</set>
|
||||
<include refid="Base_Where_Clause" />
|
||||
</update>
|
||||
|
||||
<!-- 删除方法使用MyBatis-Plus的BaseMapper提供的方法 -->
|
||||
<!-- deleteById(Serializable id) - 根据ID删除 -->
|
||||
<!-- deleteBatchIds(Collection<? extends Serializable> idList) - 批量删除 -->
|
||||
<!-- deleteByMap(Map<String, Object> columnMap) - 根据Map删除 -->
|
||||
<!-- delete(Wrapper<T> queryWrapper) - 根据条件删除 -->
|
||||
|
||||
<!-- 根据条件统计记录数 -->
|
||||
<select id="countByFilter" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 检查记录是否存在 -->
|
||||
<select id="existsByFilter" resultType="boolean">
|
||||
SELECT COUNT(1) > 0
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 查询成就列表 -->
|
||||
<select id="selectAchievements" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据成就ID查询成就信息 -->
|
||||
<select id="selectByAchievementId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
WHERE achievement_id = #{achievementId}
|
||||
</select>
|
||||
|
||||
<!-- 根据类型查询成就列表 -->
|
||||
<select id="selectByType" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
WHERE type = #{type}
|
||||
ORDER BY order_num ASC, create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据类型和等级查询成就列表 -->
|
||||
<select id="selectByTypeAndLevel" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
WHERE type = #{type} AND level = #{level}
|
||||
ORDER BY order_num ASC, create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 查询成就排行榜 -->
|
||||
<select id="selectAchievementRanking" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
WHERE deleted = 0
|
||||
ORDER BY points DESC, level DESC, order_num ASC
|
||||
<if test="limit != null and limit > 0">
|
||||
LIMIT #{limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 检查成就名称是否存在 -->
|
||||
<select id="countByName" resultType="int">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_achievement
|
||||
WHERE name = #{name} AND deleted = 0
|
||||
<if test="excludeId != null and excludeId != ''">
|
||||
AND id != #{excludeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 插入成就 -->
|
||||
<insert id="insertAchievement" parameterType="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
INSERT INTO tb_achievement (
|
||||
id, achievement_id, name, description, icon, type, level, condition_type,
|
||||
condition_value, points, order_num, creator, updater, create_time, update_time,
|
||||
delete_time, deleted
|
||||
) VALUES (
|
||||
#{id}, #{achievementId}, #{name}, #{description}, #{icon}, #{type}, #{level},
|
||||
#{conditionType}, #{conditionValue}, #{points}, #{orderNum}, #{creator}, #{updater},
|
||||
#{createTime}, #{updateTime}, #{deleteTime}, #{deleted}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 更新成就 -->
|
||||
<update id="updateAchievement" parameterType="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
UPDATE tb_achievement
|
||||
<set>
|
||||
<if test="achievementId != null and achievementId != ''">
|
||||
achievement_id = #{achievementId},
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="description != null and description != ''">
|
||||
description = #{description},
|
||||
</if>
|
||||
<if test="icon != null and icon != ''">
|
||||
icon = #{icon},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
type = #{type},
|
||||
</if>
|
||||
<if test="level != null">
|
||||
level = #{level},
|
||||
</if>
|
||||
<if test="conditionType != null">
|
||||
condition_type = #{conditionType},
|
||||
</if>
|
||||
<if test="conditionValue != null">
|
||||
condition_value = #{conditionValue},
|
||||
</if>
|
||||
<if test="points != null">
|
||||
points = #{points},
|
||||
</if>
|
||||
<if test="orderNum != null">
|
||||
order_num = #{orderNum},
|
||||
</if>
|
||||
<if test="creator != null and creator != ''">
|
||||
creator = #{creator},
|
||||
</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="deleteAchievement" parameterType="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
DELETE FROM tb_achievement
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<!-- 批量插入成就 -->
|
||||
<insert id="batchInsertAchievements" parameterType="java.util.List">
|
||||
INSERT INTO tb_achievement (
|
||||
id, achievement_id, name, description, icon, type, level, condition_type,
|
||||
condition_value, points, order_num, creator, updater, create_time, update_time,
|
||||
delete_time, deleted
|
||||
) VALUES
|
||||
<foreach collection="achievementList" item="item" separator=",">
|
||||
(
|
||||
#{item.id}, #{item.achievementId}, #{item.name}, #{item.description}, #{item.icon},
|
||||
#{item.type}, #{item.level}, #{item.conditionType}, #{item.conditionValue},
|
||||
#{item.points}, #{item.orderNum}, #{item.creator}, #{item.updater},
|
||||
#{item.createTime}, #{item.updateTime}, #{item.deleteTime}, #{item.deleted}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量删除成就 -->
|
||||
<delete id="batchDeleteAchievements">
|
||||
DELETE FROM tb_achievement
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 分页查询成就 -->
|
||||
<select id="selectAchievementsPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
ORDER BY order_num ASC, create_time DESC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
||||
</select>
|
||||
|
||||
<!-- 统计成就总数 -->
|
||||
<select id="countAchievements" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,291 +0,0 @@
|
||||
<?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.usercenter.mapper.UserAchievementMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
<id column="id" property="id" />
|
||||
<result column="user_id" property="userId" />
|
||||
<result column="achievement_id" property="achievementId" />
|
||||
<result column="obtain_time" property="obtainTime" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 字段列表 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, achievement_id, obtain_time
|
||||
</sql>
|
||||
|
||||
<!-- 查询条件 -->
|
||||
<sql id="Base_Where_Clause">
|
||||
<where>
|
||||
<if test="filter != null">
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.userId != null and filter.userId != ''">
|
||||
AND user_id = #{filter.userId}
|
||||
</if>
|
||||
<if test="filter.achievementId != null and filter.achievementId != ''">
|
||||
AND achievement_id = #{filter.achievementId}
|
||||
</if>
|
||||
<if test="filter.obtainTime != null">
|
||||
AND obtain_time = #{filter.obtainTime}
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 根据ID查询单条记录 -->
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询单条记录 -->
|
||||
<select id="selectOne" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询列表 -->
|
||||
<select id="selectList" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据条件分页查询 -->
|
||||
<select id="selectPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询记录(支持排序) -->
|
||||
<select id="selectListWithOrder" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
<if test="orderDirection != null and orderDirection != ''">
|
||||
${orderDirection}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据条件分页查询(支持排序) -->
|
||||
<select id="selectPageWithOrder" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
<if test="orderDirection != null and orderDirection != ''">
|
||||
${orderDirection}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 插入单条记录 -->
|
||||
<insert id="insertOne" parameterType="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
INSERT INTO tb_user_achievement (
|
||||
id, user_id, achievement_id, obtain_time
|
||||
) VALUES (
|
||||
#{entity.id}, #{entity.userId}, #{entity.achievementId}, #{entity.obtainTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 批量插入记录 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO tb_user_achievement (
|
||||
id, user_id, achievement_id, obtain_time
|
||||
) VALUES
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(
|
||||
#{entity.id}, #{entity.userId}, #{entity.achievementId}, #{entity.obtainTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 根据ID更新记录 -->
|
||||
<update id="updateById" parameterType="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
UPDATE tb_user_achievement
|
||||
<set>
|
||||
<if test="entity.userId != null and entity.userId != ''">
|
||||
user_id = #{entity.userId},
|
||||
</if>
|
||||
<if test="entity.achievementId != null and entity.achievementId != ''">
|
||||
achievement_id = #{entity.achievementId},
|
||||
</if>
|
||||
<if test="entity.obtainTime != null">
|
||||
obtain_time = #{entity.obtainTime},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{entity.id}
|
||||
</update>
|
||||
|
||||
<!-- 根据条件更新记录 -->
|
||||
<update id="updateByFilter" parameterType="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
UPDATE tb_user_achievement
|
||||
<set>
|
||||
<if test="entity.userId != null and entity.userId != ''">
|
||||
user_id = #{entity.userId},
|
||||
</if>
|
||||
<if test="entity.achievementId != null and entity.achievementId != ''">
|
||||
achievement_id = #{entity.achievementId},
|
||||
</if>
|
||||
<if test="entity.obtainTime != null">
|
||||
obtain_time = #{entity.obtainTime},
|
||||
</if>
|
||||
</set>
|
||||
<include refid="Base_Where_Clause" />
|
||||
</update>
|
||||
|
||||
<!-- 删除方法使用MyBatis-Plus的BaseMapper提供的方法 -->
|
||||
<!-- deleteById(Serializable id) - 根据ID删除 -->
|
||||
<!-- deleteBatchIds(Collection<? extends Serializable> idList) - 批量删除 -->
|
||||
<!-- deleteByMap(Map<String, Object> columnMap) - 根据Map删除 -->
|
||||
<!-- delete(Wrapper<T> queryWrapper) - 根据条件删除 -->
|
||||
|
||||
<!-- 根据条件统计记录数 -->
|
||||
<select id="countByFilter" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 检查记录是否存在 -->
|
||||
<select id="existsByFilter" resultType="boolean">
|
||||
SELECT COUNT(1) > 0
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 查询用户成就列表 -->
|
||||
<select id="selectUserAchievements" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID查询成就记录 -->
|
||||
<select id="selectByUserId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
WHERE user_id = #{userId}
|
||||
ORDER BY obtain_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID和成就ID查询成就记录 -->
|
||||
<select id="selectByUserIdAndAchievementId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
WHERE user_id = #{userId} AND achievement_id = #{achievementId}
|
||||
ORDER BY obtain_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID查询成就记录(包含用户基本信息) -->
|
||||
<select id="selectUserAchievementsWithUser" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
ua.id, ua.user_id, ua.achievement_id, ua.obtain_time
|
||||
FROM tb_user_achievement ua
|
||||
LEFT JOIN tb_sys_user u ON ua.user_id = u.id
|
||||
WHERE ua.user_id = #{userId}
|
||||
ORDER BY ua.obtain_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 查询用户成就统计 -->
|
||||
<select id="selectAchievementStatistics" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
user_id,
|
||||
COUNT(*) as achievement_id,
|
||||
MAX(obtain_time) as obtain_time
|
||||
FROM tb_user_achievement
|
||||
WHERE user_id = #{userId}
|
||||
GROUP BY user_id
|
||||
</select>
|
||||
|
||||
<!-- 插入用户成就 -->
|
||||
<insert id="insertUserAchievement" parameterType="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
INSERT INTO tb_user_achievement (
|
||||
id, user_id, achievement_id, obtain_time
|
||||
) VALUES (
|
||||
#{id}, #{userId}, #{achievementId}, #{obtainTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 更新用户成就 -->
|
||||
<update id="updateUserAchievement" parameterType="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
UPDATE tb_user_achievement
|
||||
<set>
|
||||
<if test="userId != null and userId != ''">
|
||||
user_id = #{userId},
|
||||
</if>
|
||||
<if test="achievementId != null and achievementId != ''">
|
||||
achievement_id = #{achievementId},
|
||||
</if>
|
||||
<if test="obtainTime != null">
|
||||
obtain_time = #{obtainTime},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 删除用户成就 -->
|
||||
<delete id="deleteUserAchievement" parameterType="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
DELETE FROM tb_user_achievement
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<!-- 批量插入用户成就 -->
|
||||
<insert id="batchInsertUserAchievements" parameterType="java.util.List">
|
||||
INSERT INTO tb_user_achievement (
|
||||
id, user_id, achievement_id, obtain_time
|
||||
) VALUES
|
||||
<foreach collection="userAchievementList" item="item" separator=",">
|
||||
(
|
||||
#{item.id}, #{item.userId}, #{item.achievementId}, #{item.obtainTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量删除用户成就 -->
|
||||
<delete id="batchDeleteUserAchievements">
|
||||
DELETE FROM tb_user_achievement
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 分页查询用户成就 -->
|
||||
<select id="selectUserAchievementsPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
ORDER BY obtain_time DESC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
||||
</select>
|
||||
|
||||
<!-- 统计用户成就总数 -->
|
||||
<select id="countUserAchievements" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user