serv-学习管理
This commit is contained in:
@@ -29,10 +29,14 @@ CREATE TABLE `tb_course` (
|
|||||||
-- 课程章节表
|
-- 课程章节表
|
||||||
DROP TABLE IF EXISTS `tb_course_chapter`;
|
DROP TABLE IF EXISTS `tb_course_chapter`;
|
||||||
CREATE TABLE `tb_course_chapter` (
|
CREATE TABLE `tb_course_chapter` (
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '章节ID',
|
`id` VARCHAR(50) NOT NULL COMMENT 'ID',
|
||||||
|
`chapter_id` VARCHAR(50) NOT NULL COMMENT '章节唯一标识',
|
||||||
`course_id` VARCHAR(50) NOT NULL COMMENT '课程ID',
|
`course_id` VARCHAR(50) NOT NULL COMMENT '课程ID',
|
||||||
|
`parent_id` VARCHAR(50) DEFAULT NULL COMMENT '父章节ID',
|
||||||
`name` VARCHAR(255) NOT NULL COMMENT '章节名称',
|
`name` VARCHAR(255) NOT NULL COMMENT '章节名称',
|
||||||
`content` LONGTEXT COMMENT '章节内容',
|
`content` LONGTEXT COMMENT '章节内容',
|
||||||
|
`chapter_type` INT(4) DEFAULT 0 COMMENT '章节类型(1视频 2文档 3音频)',
|
||||||
|
`resource_id` VARCHAR(50) DEFAULT NULL COMMENT '资源ID',
|
||||||
`video_url` VARCHAR(500) DEFAULT NULL COMMENT '视频URL',
|
`video_url` VARCHAR(500) DEFAULT NULL COMMENT '视频URL',
|
||||||
`duration` INT(11) DEFAULT 0 COMMENT '章节时长(分钟)',
|
`duration` INT(11) DEFAULT 0 COMMENT '章节时长(分钟)',
|
||||||
`order_num` INT(4) DEFAULT 0 COMMENT '排序号',
|
`order_num` INT(4) DEFAULT 0 COMMENT '排序号',
|
||||||
@@ -44,6 +48,7 @@ CREATE TABLE `tb_course_chapter` (
|
|||||||
`deleted` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
|
`deleted` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `idx_course` (`course_id`),
|
KEY `idx_course` (`course_id`),
|
||||||
|
KEY `idx_parent` (`parent_id`),
|
||||||
KEY `idx_order` (`order_num`)
|
KEY `idx_order` (`order_num`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='课程章节表';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='课程章节表';
|
||||||
|
|
||||||
@@ -61,3 +66,28 @@ CREATE TABLE `tb_course_tag` (
|
|||||||
KEY `idx_tag` (`tag_id`)
|
KEY `idx_tag` (`tag_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='课程标签关联表';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='课程标签关联表';
|
||||||
|
|
||||||
|
-- 学习节点表
|
||||||
|
DROP TABLE IF EXISTS `tb_course_node`;
|
||||||
|
CREATE TABLE `tb_course_node` (
|
||||||
|
`id` VARCHAR(50) NOT NULL COMMENT '节点ID',
|
||||||
|
`chapter_id` VARCHAR(50) NOT NULL COMMENT '章节ID',
|
||||||
|
`node_id` VARCHAR(50) NOT NULL COMMENT '节点唯一标识',
|
||||||
|
`name` VARCHAR(255) NOT NULL COMMENT '节点名称',
|
||||||
|
`content` LONGTEXT COMMENT '节点内容',
|
||||||
|
`node_type` INT(4) DEFAULT 1 COMMENT '节点类型(0文章资源 1富文本 2其他上传文件)',
|
||||||
|
`resource_id` VARCHAR(50) DEFAULT NULL COMMENT '资源ID',
|
||||||
|
`video_url` VARCHAR(500) DEFAULT NULL COMMENT '视频URL',
|
||||||
|
`duration` INT(11) DEFAULT 0 COMMENT '节点时长(分钟)',
|
||||||
|
`order_num` INT(4) DEFAULT 0 COMMENT '排序号',
|
||||||
|
`is_required` TINYINT(1) DEFAULT 1 COMMENT '是否必修(1必修 0选修)',
|
||||||
|
`creator` VARCHAR(50) DEFAULT NULL COMMENT '创建者',
|
||||||
|
`updater` VARCHAR(50) DEFAULT NULL COMMENT '更新者',
|
||||||
|
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP 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`),
|
||||||
|
KEY `idx_chapter` (`chapter_id`),
|
||||||
|
KEY `idx_order` (`order_num`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='学习节点表';
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ INSERT INTO `tb_sys_menu` (id, menu_id, name, parent_id, url, component, icon, o
|
|||||||
('5001', 'menu_admin_study', '学习管理', 'menu_admin_study_manage', '/admin/manage/study/study', 'admin/manage/study/StudyManagementView', 'el-icon-reading', 1, 1, 'NavigationLayout', '1', now()),
|
('5001', 'menu_admin_study', '学习管理', 'menu_admin_study_manage', '/admin/manage/study/study', 'admin/manage/study/StudyManagementView', 'el-icon-reading', 1, 1, 'NavigationLayout', '1', now()),
|
||||||
('5002', 'menu_admin_task_publish', '任务发布', 'menu_admin_study_manage', '/admin/manage/study/task-publish', 'admin/manage/study/TaskPublishView', 'el-icon-s-order', 2, 1, 'NavigationLayout', '1', now()),
|
('5002', 'menu_admin_task_publish', '任务发布', 'menu_admin_study_manage', '/admin/manage/study/task-publish', 'admin/manage/study/TaskPublishView', 'el-icon-s-order', 2, 1, 'NavigationLayout', '1', now()),
|
||||||
('5003', 'menu_admin_study_records', '学习记录', 'menu_admin_study_manage', '/admin/manage/study/study-records', 'admin/manage/study/StudyRecordsView', 'el-icon-document', 3, 1, 'NavigationLayout', '1', now()),
|
('5003', 'menu_admin_study_records', '学习记录', 'menu_admin_study_manage', '/admin/manage/study/study-records', 'admin/manage/study/StudyRecordsView', 'el-icon-document', 3, 1, 'NavigationLayout', '1', now()),
|
||||||
|
('5004', 'menu_admin_course_manage', '课程管理', 'menu_admin_study_manage', '/admin/manage/study/course', 'admin/manage/study/CourseManagementView', 'el-icon-video-play', 4, 1, 'NavigationLayout', '1', now()),
|
||||||
-- 智能体管理
|
-- 智能体管理
|
||||||
('6000', 'menu_admin_ai_manage', '智能体管理', NULL, '', '', 'el-icon-cpu', 6, 1, '', '1', now()),
|
('6000', 'menu_admin_ai_manage', '智能体管理', NULL, '', '', 'el-icon-cpu', 6, 1, '', '1', now()),
|
||||||
('6001', 'menu_admin_ai', 'AI管理', 'menu_admin_ai_manage', '/admin/manage/ai/ai', 'admin/manage/ai/AIManagementView', 'el-icon-cpu', 1, 1, 'NavigationLayout', '1', now()),
|
('6001', 'menu_admin_ai', 'AI管理', 'menu_admin_ai_manage', '/admin/manage/ai/ai', 'admin/manage/ai/AIManagementView', 'el-icon-cpu', 1, 1, 'NavigationLayout', '1', now()),
|
||||||
@@ -178,12 +178,13 @@ INSERT INTO `tb_sys_menu_permission` (id, permission_id, menu_id, creator, creat
|
|||||||
('219', 'perm_study_manage', 'menu_admin_study', '1', now()),
|
('219', 'perm_study_manage', 'menu_admin_study', '1', now()),
|
||||||
('220', 'perm_study_manage', 'menu_admin_task_publish', '1', now()),
|
('220', 'perm_study_manage', 'menu_admin_task_publish', '1', now()),
|
||||||
('221', 'perm_study_manage', 'menu_admin_study_records', '1', now()),
|
('221', 'perm_study_manage', 'menu_admin_study_records', '1', now()),
|
||||||
('222', 'perm_ai_manage', 'menu_admin_ai_manage', '1', now()),
|
('222', 'perm_study_manage', 'menu_admin_course_manage', '1', now()),
|
||||||
('223', 'perm_ai_manage', 'menu_admin_ai', '1', now()),
|
('223', 'perm_ai_manage', 'menu_admin_ai_manage', '1', now()),
|
||||||
('224', 'perm_ai_manage', 'menu_admin_ai_config', '1', now()),
|
('224', 'perm_ai_manage', 'menu_admin_ai', '1', now()),
|
||||||
('225', 'perm_ai_manage', 'menu_admin_knowledge', '1', now()),
|
('225', 'perm_ai_manage', 'menu_admin_ai_config', '1', now()),
|
||||||
('226', 'perm_system_manage', 'menu_admin_logs_manage', '1', now()),
|
('226', 'perm_ai_manage', 'menu_admin_knowledge', '1', now()),
|
||||||
('227', 'perm_system_manage', 'menu_admin_system_logs', '1', now()),
|
('227', 'perm_system_manage', 'menu_admin_logs_manage', '1', now()),
|
||||||
('228', 'perm_system_manage', 'menu_admin_login_logs', '1', now()),
|
('228', 'perm_system_manage', 'menu_admin_system_logs', '1', now()),
|
||||||
('229', 'perm_system_manage', 'menu_admin_operation_logs', '1', now()),
|
('229', 'perm_system_manage', 'menu_admin_login_logs', '1', now()),
|
||||||
('230', 'perm_system_manage', 'menu_admin_system_config', '1', now());
|
('230', 'perm_system_manage', 'menu_admin_operation_logs', '1', now()),
|
||||||
|
('231', 'perm_system_manage', 'menu_admin_system_config', '1', now());
|
||||||
|
|||||||
2
schoolNewsServ/.gitignore
vendored
2
schoolNewsServ/.gitignore
vendored
@@ -9,7 +9,7 @@ HELP.md
|
|||||||
!**/src/test/**/target/
|
!**/src/test/**/target/
|
||||||
!**/uploads/**
|
!**/uploads/**
|
||||||
admin/uploads/**
|
admin/uploads/**
|
||||||
|
uploads
|
||||||
### Logs ###
|
### Logs ###
|
||||||
**/logs/
|
**/logs/
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
@@ -77,6 +77,13 @@ school-news:
|
|||||||
- "/file/download/**"
|
- "/file/download/**"
|
||||||
|
|
||||||
|
|
||||||
|
# 文件存储配置
|
||||||
|
file:
|
||||||
|
storage:
|
||||||
|
storages:
|
||||||
|
- type: local
|
||||||
|
enabled: true
|
||||||
|
base-path: ../uploads
|
||||||
|
|
||||||
# MyBatis Plus配置
|
# MyBatis Plus配置
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.xyzh.api.news.resource;
|
|||||||
import org.xyzh.common.core.domain.ResultDomain;
|
import org.xyzh.common.core.domain.ResultDomain;
|
||||||
import org.xyzh.common.core.page.PageParam;
|
import org.xyzh.common.core.page.PageParam;
|
||||||
import org.xyzh.common.dto.resource.TbResource;
|
import org.xyzh.common.dto.resource.TbResource;
|
||||||
|
import org.xyzh.common.dto.usercenter.TbUserCollection;
|
||||||
import org.xyzh.common.vo.ResourceVO;
|
import org.xyzh.common.vo.ResourceVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -117,13 +118,13 @@ public interface ResourceService {
|
|||||||
ResultDomain<TbResource> incrementLikeCount(String resourceID);
|
ResultDomain<TbResource> incrementLikeCount(String resourceID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 增加收藏次数
|
* @description 收藏次数加减
|
||||||
* @param resourceID 资源ID
|
* @param resourceID 资源ID
|
||||||
* @return ResultDomain<TbResource> 更新结果
|
* @return ResultDomain<TbResource> 更新结果
|
||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-15
|
* @since 2025-10-15
|
||||||
*/
|
*/
|
||||||
ResultDomain<TbResource> incrementCollectCount(String resourceID);
|
ResultDomain<TbResource> resourceCollect(TbUserCollection collection);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 设置资源推荐
|
* @description 设置资源推荐
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package org.xyzh.api.study.course;
|
package org.xyzh.api.study.course;
|
||||||
|
|
||||||
import org.xyzh.common.core.domain.ResultDomain;
|
import org.xyzh.common.core.domain.ResultDomain;
|
||||||
|
import org.xyzh.common.core.page.PageParam;
|
||||||
|
import org.xyzh.common.core.page.PageRequest;
|
||||||
import org.xyzh.common.dto.study.TbCourse;
|
import org.xyzh.common.dto.study.TbCourse;
|
||||||
import org.xyzh.common.dto.study.TbCourseChapter;
|
import org.xyzh.common.dto.study.TbCourseChapter;
|
||||||
|
import org.xyzh.common.vo.CourseVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -24,6 +27,15 @@ public interface CourseService {
|
|||||||
*/
|
*/
|
||||||
ResultDomain<TbCourse> getCourseList(TbCourse filter);
|
ResultDomain<TbCourse> getCourseList(TbCourse filter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 分页获取课程列表
|
||||||
|
* @param filter 过滤条件
|
||||||
|
* @return ResultDomain<TbCourse> 课程列表
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-15
|
||||||
|
*/
|
||||||
|
ResultDomain<TbCourse> getCoursePage(PageRequest<TbCourse> pageRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 根据ID获取课程详情
|
* @description 根据ID获取课程详情
|
||||||
* @param courseID 课程ID
|
* @param courseID 课程ID
|
||||||
@@ -31,7 +43,7 @@ public interface CourseService {
|
|||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-15
|
* @since 2025-10-15
|
||||||
*/
|
*/
|
||||||
ResultDomain<TbCourse> getCourseById(String courseID);
|
ResultDomain<CourseVO> getCourseById(String courseID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 创建课程
|
* @description 创建课程
|
||||||
@@ -40,7 +52,7 @@ public interface CourseService {
|
|||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-15
|
* @since 2025-10-15
|
||||||
*/
|
*/
|
||||||
ResultDomain<TbCourse> createCourse(TbCourse course);
|
ResultDomain<CourseVO> createCourse(CourseVO courseVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 更新课程
|
* @description 更新课程
|
||||||
|
|||||||
@@ -12,12 +12,19 @@ import org.xyzh.common.dto.BaseDTO;
|
|||||||
public class TbCourseChapter extends BaseDTO {
|
public class TbCourseChapter extends BaseDTO {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String chapterID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 课程ID
|
* @description 课程ID
|
||||||
*/
|
*/
|
||||||
private String courseID;
|
private String courseID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 父章节ID
|
||||||
|
*/
|
||||||
|
private String parentID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 章节名称
|
* @description 章节名称
|
||||||
*/
|
*/
|
||||||
@@ -32,7 +39,17 @@ public class TbCourseChapter extends BaseDTO {
|
|||||||
* @description 视频URL
|
* @description 视频URL
|
||||||
*/
|
*/
|
||||||
private String videoUrl;
|
private String videoUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 章节类型(1视频 2文档 3音频)
|
||||||
|
*/
|
||||||
|
private Integer chapterType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 资源ID
|
||||||
|
*/
|
||||||
|
private String resourceID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 章节时长(分钟)
|
* @description 章节时长(分钟)
|
||||||
*/
|
*/
|
||||||
@@ -53,6 +70,14 @@ public class TbCourseChapter extends BaseDTO {
|
|||||||
*/
|
*/
|
||||||
private String updater;
|
private String updater;
|
||||||
|
|
||||||
|
public String getChapterID() {
|
||||||
|
return chapterID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChapterID(String chapterID) {
|
||||||
|
this.chapterID = chapterID;
|
||||||
|
}
|
||||||
|
|
||||||
public String getCourseID() {
|
public String getCourseID() {
|
||||||
return courseID;
|
return courseID;
|
||||||
}
|
}
|
||||||
@@ -61,6 +86,14 @@ public class TbCourseChapter extends BaseDTO {
|
|||||||
this.courseID = courseID;
|
this.courseID = courseID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParentID() {
|
||||||
|
return parentID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentID(String parentID) {
|
||||||
|
this.parentID = parentID;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -85,6 +118,22 @@ public class TbCourseChapter extends BaseDTO {
|
|||||||
this.videoUrl = videoUrl;
|
this.videoUrl = videoUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getChapterType() {
|
||||||
|
return chapterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChapterType(Integer chapterType) {
|
||||||
|
this.chapterType = chapterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResourceID() {
|
||||||
|
return resourceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResourceID(String resourceID) {
|
||||||
|
this.resourceID = resourceID;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getDuration() {
|
public Integer getDuration() {
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
@@ -121,9 +170,14 @@ public class TbCourseChapter extends BaseDTO {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "TbCourseChapter{" +
|
return "TbCourseChapter{" +
|
||||||
"id=" + getID() +
|
"id=" + getID() +
|
||||||
|
", chapterID='" + chapterID + '\'' +
|
||||||
", courseID='" + courseID + '\'' +
|
", courseID='" + courseID + '\'' +
|
||||||
|
", parentID='" + parentID + '\'' +
|
||||||
", name='" + name + '\'' +
|
", name='" + name + '\'' +
|
||||||
|
", content='" + content + '\'' +
|
||||||
", videoUrl='" + videoUrl + '\'' +
|
", videoUrl='" + videoUrl + '\'' +
|
||||||
|
", chapterType=" + chapterType +
|
||||||
|
", resourceID='" + resourceID + '\'' +
|
||||||
", duration=" + duration +
|
", duration=" + duration +
|
||||||
", orderNum=" + orderNum +
|
", orderNum=" + orderNum +
|
||||||
'}';
|
'}';
|
||||||
|
|||||||
@@ -0,0 +1,186 @@
|
|||||||
|
package org.xyzh.common.dto.study;
|
||||||
|
|
||||||
|
import org.xyzh.common.dto.BaseDTO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 学习节点表
|
||||||
|
* @filename TbCourseNode.java
|
||||||
|
* @author yslg
|
||||||
|
* @copyright xyzh
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
public class TbCourseNode extends BaseDTO {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String nodeID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 章节ID
|
||||||
|
*/
|
||||||
|
private String chapterID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 节点名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 节点内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 节点类型(1视频 2文档 3音频 4图片 5链接)
|
||||||
|
*/
|
||||||
|
private Integer nodeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 资源ID
|
||||||
|
*/
|
||||||
|
private String resourceID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 视频URL
|
||||||
|
*/
|
||||||
|
private String videoUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 节点时长(分钟)
|
||||||
|
*/
|
||||||
|
private Integer duration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 排序号
|
||||||
|
*/
|
||||||
|
private Integer orderNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 是否必修(1必修 0选修)
|
||||||
|
*/
|
||||||
|
private Integer isRequired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 创建者
|
||||||
|
*/
|
||||||
|
private String creator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 更新者
|
||||||
|
*/
|
||||||
|
private String updater;
|
||||||
|
|
||||||
|
public String getNodeID() {
|
||||||
|
return nodeID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeID(String nodeID) {
|
||||||
|
this.nodeID = nodeID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChapterID() {
|
||||||
|
return chapterID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChapterID(String chapterID) {
|
||||||
|
this.chapterID = chapterID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNodeType() {
|
||||||
|
return nodeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeType(Integer nodeType) {
|
||||||
|
this.nodeType = nodeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResourceID() {
|
||||||
|
return resourceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResourceID(String resourceID) {
|
||||||
|
this.resourceID = resourceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVideoUrl() {
|
||||||
|
return videoUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoUrl(String videoUrl) {
|
||||||
|
this.videoUrl = videoUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDuration() {
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDuration(Integer duration) {
|
||||||
|
this.duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOrderNum() {
|
||||||
|
return orderNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderNum(Integer orderNum) {
|
||||||
|
this.orderNum = orderNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIsRequired() {
|
||||||
|
return isRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsRequired(Integer isRequired) {
|
||||||
|
this.isRequired = isRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "TbCourseNode{" +
|
||||||
|
"id=" + getID() +
|
||||||
|
", nodeID='" + nodeID + '\'' +
|
||||||
|
", chapterID='" + chapterID + '\'' +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", content='" + content + '\'' +
|
||||||
|
", nodeType=" + nodeType +
|
||||||
|
", resourceID='" + resourceID + '\'' +
|
||||||
|
", videoUrl='" + videoUrl + '\'' +
|
||||||
|
", duration=" + duration +
|
||||||
|
", orderNum=" + orderNum +
|
||||||
|
", isRequired=" + isRequired +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -28,6 +28,11 @@ public class TbUserCollection extends BaseDTO {
|
|||||||
*/
|
*/
|
||||||
private String collectionID;
|
private String collectionID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 收藏值
|
||||||
|
*/
|
||||||
|
private Integer collectionValue;
|
||||||
|
|
||||||
public String getUserID() {
|
public String getUserID() {
|
||||||
return userID;
|
return userID;
|
||||||
}
|
}
|
||||||
@@ -52,6 +57,14 @@ public class TbUserCollection extends BaseDTO {
|
|||||||
this.collectionID = collectionID;
|
this.collectionID = collectionID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getCollectionValue() {
|
||||||
|
return collectionValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCollectionValue(Integer collectionValue) {
|
||||||
|
this.collectionValue = collectionValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "TbUserCollection{" +
|
return "TbUserCollection{" +
|
||||||
@@ -60,6 +73,7 @@ public class TbUserCollection extends BaseDTO {
|
|||||||
", collectionType=" + collectionType +
|
", collectionType=" + collectionType +
|
||||||
", collectionID='" + collectionID + '\'' +
|
", collectionID='" + collectionID + '\'' +
|
||||||
", createTime=" + getCreateTime() +
|
", createTime=" + getCreateTime() +
|
||||||
|
", collectionValue=" + collectionValue +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package org.xyzh.common.vo;
|
||||||
|
|
||||||
|
import org.xyzh.common.dto.BaseDTO;
|
||||||
|
import org.xyzh.common.dto.study.TbCourseNode;
|
||||||
|
import org.xyzh.common.dto.study.TbCourseChapter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ChapterVO extends BaseDTO{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private TbCourseChapter chapter;
|
||||||
|
private List<TbCourseNode> nodes;
|
||||||
|
|
||||||
|
public TbCourseChapter getChapter() {
|
||||||
|
return chapter;
|
||||||
|
}
|
||||||
|
public void setChapter(TbCourseChapter chapter) {
|
||||||
|
this.chapter = chapter;
|
||||||
|
}
|
||||||
|
public List<TbCourseNode> getNodes() {
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
public void setNodes(List<TbCourseNode> nodes) {
|
||||||
|
this.nodes = nodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNode(TbCourseNode node) {
|
||||||
|
if (nodes == null) {
|
||||||
|
nodes = new ArrayList<>();
|
||||||
|
}
|
||||||
|
nodes.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package org.xyzh.common.vo;
|
||||||
|
|
||||||
|
import org.xyzh.common.dto.BaseDTO;
|
||||||
|
import org.xyzh.common.dto.study.TbCourse;
|
||||||
|
import org.xyzh.common.dto.study.TbCourseTag;
|
||||||
|
import org.xyzh.common.vo.ChapterVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CourseVO extends BaseDTO{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private TbCourse course;
|
||||||
|
private List<ChapterVO> courseChapters;
|
||||||
|
private List<TbCourseTag> courseTags;
|
||||||
|
|
||||||
|
|
||||||
|
public TbCourse getCourse() {
|
||||||
|
return course;
|
||||||
|
}
|
||||||
|
public void setCourse(TbCourse course) {
|
||||||
|
this.course = course;
|
||||||
|
}
|
||||||
|
public List<ChapterVO> getCourseChapters() {
|
||||||
|
return courseChapters;
|
||||||
|
}
|
||||||
|
public void setCourseChapters(List<ChapterVO> courseChapters) {
|
||||||
|
this.courseChapters = courseChapters;
|
||||||
|
}
|
||||||
|
public List<TbCourseTag> getCourseTags() {
|
||||||
|
return courseTags;
|
||||||
|
}
|
||||||
|
public void setCourseTags(List<TbCourseTag> courseTags) {
|
||||||
|
this.courseTags = courseTags;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -24,6 +24,11 @@
|
|||||||
<artifactId>api-news</artifactId>
|
<artifactId>api-news</artifactId>
|
||||||
<version>${school-news.version}</version>
|
<version>${school-news.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.xyzh</groupId>
|
||||||
|
<artifactId>api-usercenter</artifactId>
|
||||||
|
<version>${school-news.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.xyzh</groupId>
|
<groupId>org.xyzh</groupId>
|
||||||
<artifactId>system</artifactId>
|
<artifactId>system</artifactId>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.xyzh.news.controller;
|
package org.xyzh.news.controller;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -13,6 +14,7 @@ import org.xyzh.common.core.page.PageParam;
|
|||||||
import org.xyzh.common.core.page.PageRequest;
|
import org.xyzh.common.core.page.PageRequest;
|
||||||
import org.xyzh.common.dto.resource.TbResource;
|
import org.xyzh.common.dto.resource.TbResource;
|
||||||
import org.xyzh.common.dto.user.TbSysUser;
|
import org.xyzh.common.dto.user.TbSysUser;
|
||||||
|
import org.xyzh.common.dto.usercenter.TbUserCollection;
|
||||||
import org.xyzh.common.utils.TimeUtils;
|
import org.xyzh.common.utils.TimeUtils;
|
||||||
import org.xyzh.common.vo.ResourceVO;
|
import org.xyzh.common.vo.ResourceVO;
|
||||||
import org.xyzh.system.utils.LoginUtil;
|
import org.xyzh.system.utils.LoginUtil;
|
||||||
@@ -137,9 +139,9 @@ public class ResourceController {
|
|||||||
/**
|
/**
|
||||||
* 增加收藏次数
|
* 增加收藏次数
|
||||||
*/
|
*/
|
||||||
@PostMapping("/resource/{resourceID}/collect")
|
@PostMapping("/resource/collect")
|
||||||
public ResultDomain<TbResource> incrementCollectCount(@PathVariable("resourceID") String resourceID) {
|
public ResultDomain<TbResource> resourceCollect(@RequestBody TbUserCollection collection) {
|
||||||
return resourceService.incrementCollectCount(resourceID);
|
return resourceService.resourceCollect(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -163,4 +163,14 @@ public interface ResourceMapper extends BaseMapper<TbResource> {
|
|||||||
* @since 2025-10-15
|
* @since 2025-10-15
|
||||||
*/
|
*/
|
||||||
long countResources(TbResource filter);
|
long countResources(TbResource filter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 更新资源收藏次数
|
||||||
|
* @param resourceID 资源ID
|
||||||
|
* @param collectionValue 收藏次数
|
||||||
|
* @return int 影响行数
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-15
|
||||||
|
*/
|
||||||
|
int updateResourceCollectCount(@Param("resourceID") String resourceID, @Param("collectionValue") Integer collectionValue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.xyzh.common.dto.resource.TbResource;
|
|||||||
import org.xyzh.common.dto.resource.TbResourceTag;
|
import org.xyzh.common.dto.resource.TbResourceTag;
|
||||||
import org.xyzh.common.dto.resource.TbTag;
|
import org.xyzh.common.dto.resource.TbTag;
|
||||||
import org.xyzh.common.dto.user.TbSysUser;
|
import org.xyzh.common.dto.user.TbSysUser;
|
||||||
|
import org.xyzh.common.dto.usercenter.TbUserCollection;
|
||||||
import org.xyzh.common.utils.IDUtils;
|
import org.xyzh.common.utils.IDUtils;
|
||||||
import org.xyzh.common.vo.ResourceVO;
|
import org.xyzh.common.vo.ResourceVO;
|
||||||
import org.xyzh.common.vo.TagVO;
|
import org.xyzh.common.vo.TagVO;
|
||||||
@@ -20,6 +21,7 @@ import org.xyzh.news.mapper.ResourceMapper;
|
|||||||
import org.xyzh.news.mapper.ResourceTagMapper;
|
import org.xyzh.news.mapper.ResourceTagMapper;
|
||||||
import org.xyzh.system.utils.LoginUtil;
|
import org.xyzh.system.utils.LoginUtil;
|
||||||
import org.xyzh.api.news.resource.ResourceService;
|
import org.xyzh.api.news.resource.ResourceService;
|
||||||
|
import org.xyzh.api.usercenter.collection.UserCollectionService;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -44,6 +46,9 @@ public class NCResourceServiceImpl implements ResourceService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ResourceTagMapper resourceTagMapper;
|
private ResourceTagMapper resourceTagMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserCollectionService userCollectionService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<TbResource> getResourceList(TbResource filter) {
|
public ResultDomain<TbResource> getResourceList(TbResource filter) {
|
||||||
ResultDomain<TbResource> resultDomain = new ResultDomain<>();
|
ResultDomain<TbResource> resultDomain = new ResultDomain<>();
|
||||||
@@ -530,36 +535,57 @@ public class NCResourceServiceImpl implements ResourceService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ResultDomain<TbResource> incrementCollectCount(String resourceID) {
|
public ResultDomain<TbResource> resourceCollect(TbUserCollection collection) {
|
||||||
|
String resourceID = collection.getCollectionID();
|
||||||
|
Integer collectionValue = collection.getCollectionValue();
|
||||||
ResultDomain<TbResource> resultDomain = new ResultDomain<>();
|
ResultDomain<TbResource> resultDomain = new ResultDomain<>();
|
||||||
|
TbSysUser user = LoginUtil.getCurrentUser();
|
||||||
|
if (user == null) {
|
||||||
|
resultDomain.fail("请先登录");
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
|
collection.setUserID(user.getID());
|
||||||
try {
|
try {
|
||||||
// 参数验证
|
// 参数验证
|
||||||
if (!StringUtils.hasText(resourceID)) {
|
if (!StringUtils.hasText(resourceID)) {
|
||||||
resultDomain.fail("资源ID不能为空");
|
resultDomain.fail("资源ID不能为空");
|
||||||
return resultDomain;
|
return resultDomain;
|
||||||
}
|
}
|
||||||
|
if (collectionValue != 1 && collectionValue != -1) {
|
||||||
// 查询资源
|
resultDomain.fail("收藏值错误");
|
||||||
TbResource resource = resourceMapper.selectByResourceId(resourceID);
|
|
||||||
if (resource == null || resource.getDeleted()) {
|
|
||||||
resultDomain.fail("资源不存在");
|
|
||||||
return resultDomain;
|
return resultDomain;
|
||||||
}
|
}
|
||||||
|
ResultDomain<Boolean> isCollected = userCollectionService.isCollected(user.getID(), collection.getCollectionType(), resourceID);
|
||||||
// 增加收藏次数
|
TbResource resource = new TbResource();
|
||||||
Integer currentCount = resource.getCollectCount() != null ? resource.getCollectCount() : 0;
|
resource.setResourceID(resourceID);
|
||||||
resource.setCollectCount(currentCount + 1);
|
if (isCollected.isSuccess() && isCollected.getData() && collectionValue == 1) {
|
||||||
resource.setUpdateTime(new Date());
|
resultDomain.success("已收藏", resource);
|
||||||
|
|
||||||
int result = resourceMapper.updateResource(resource);
|
|
||||||
if (result > 0) {
|
|
||||||
logger.info("增加资源收藏次数成功: {}", resourceID);
|
|
||||||
// 重新查询返回完整数据
|
|
||||||
TbResource updated = resourceMapper.selectById(resource.getID());
|
|
||||||
resultDomain.success("增加收藏次数成功", updated);
|
|
||||||
return resultDomain;
|
return resultDomain;
|
||||||
} else {
|
}
|
||||||
resultDomain.fail("增加收藏次数失败");
|
else if (isCollected.isSuccess() && isCollected.getData() && collectionValue == -1) {
|
||||||
|
ResultDomain<Boolean> removeCollection = userCollectionService.removeCollection(user.getID(), collection.getCollectionType(), resourceID);
|
||||||
|
if (removeCollection.isSuccess()) {
|
||||||
|
resourceMapper.updateResourceCollectCount(resourceID, -1);
|
||||||
|
resultDomain.success("已取消收藏", resource);
|
||||||
|
return resultDomain;
|
||||||
|
} else {
|
||||||
|
resultDomain.fail("取消收藏失败");
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
|
}else if (isCollected.isSuccess() && !isCollected.getData() && collectionValue == 1) {
|
||||||
|
collection.setID(IDUtils.generateID());
|
||||||
|
collection.setCreateTime(new Date());
|
||||||
|
ResultDomain<TbUserCollection> addCollection = userCollectionService.addCollection(collection);
|
||||||
|
if (addCollection.isSuccess() && addCollection.getData() != null) {
|
||||||
|
resourceMapper.updateResourceCollectCount(resourceID, 1);
|
||||||
|
resultDomain.success("已收藏", resource);
|
||||||
|
return resultDomain;
|
||||||
|
} else {
|
||||||
|
resultDomain.fail("收藏失败");
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
resultDomain.success("未收藏", resource);
|
||||||
return resultDomain;
|
return resultDomain;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -303,4 +303,11 @@
|
|||||||
<include refid="Where_Clause" />
|
<include refid="Where_Clause" />
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- updateResourceCollectCount -->
|
||||||
|
|
||||||
|
<update id="updateResourceCollectCount">
|
||||||
|
UPDATE tb_resource
|
||||||
|
SET collect_count = collect_count + #{collectionValue}
|
||||||
|
WHERE resource_id = #{resourceID}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -27,7 +27,11 @@
|
|||||||
<artifactId>api-study</artifactId>
|
<artifactId>api-study</artifactId>
|
||||||
<version>${school-news.version}</version>
|
<version>${school-news.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.xyzh</groupId>
|
||||||
|
<artifactId>system</artifactId>
|
||||||
|
<version>${school-news.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.xyzh</groupId>
|
<groupId>org.xyzh</groupId>
|
||||||
<artifactId>common-all</artifactId>
|
<artifactId>common-all</artifactId>
|
||||||
|
|||||||
@@ -6,8 +6,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.xyzh.api.study.course.CourseService;
|
import org.xyzh.api.study.course.CourseService;
|
||||||
import org.xyzh.common.core.domain.ResultDomain;
|
import org.xyzh.common.core.domain.ResultDomain;
|
||||||
|
import org.xyzh.common.core.page.PageRequest;
|
||||||
import org.xyzh.common.dto.study.TbCourse;
|
import org.xyzh.common.dto.study.TbCourse;
|
||||||
import org.xyzh.common.dto.study.TbCourseChapter;
|
import org.xyzh.common.dto.study.TbCourseChapter;
|
||||||
|
import org.xyzh.common.vo.ChapterVO;
|
||||||
|
import org.xyzh.common.vo.CourseVO;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 课程控制器
|
* @description 课程控制器
|
||||||
@@ -17,7 +23,7 @@ import org.xyzh.common.dto.study.TbCourseChapter;
|
|||||||
* @since 2025-10-15
|
* @since 2025-10-15
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/study/course")
|
@RequestMapping("/study/courses")
|
||||||
public class CourseController {
|
public class CourseController {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CourseController.class);
|
private static final Logger logger = LoggerFactory.getLogger(CourseController.class);
|
||||||
|
|
||||||
@@ -32,26 +38,34 @@ public class CourseController {
|
|||||||
return courseService.getCourseList(filter);
|
return courseService.getCourseList(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页获取课程列表
|
||||||
|
*/
|
||||||
|
@PostMapping("/page")
|
||||||
|
public ResultDomain<TbCourse> getCoursePage(@RequestBody PageRequest<TbCourse> pageRequest) {
|
||||||
|
return courseService.getCoursePage(pageRequest);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID获取课程详情
|
* 根据ID获取课程详情
|
||||||
*/
|
*/
|
||||||
@GetMapping("/{courseID}")
|
@GetMapping("/{courseID}")
|
||||||
public ResultDomain<TbCourse> getCourseById(@PathVariable String courseID) {
|
public ResultDomain<CourseVO> getCourseById(@PathVariable("courseID") String courseID) {
|
||||||
return courseService.getCourseById(courseID);
|
return courseService.getCourseById(courseID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建课程
|
* 创建课程
|
||||||
*/
|
*/
|
||||||
@PostMapping("/create")
|
@PostMapping("/course")
|
||||||
public ResultDomain<TbCourse> createCourse(@RequestBody TbCourse course) {
|
public ResultDomain<CourseVO> createCourse(@RequestBody CourseVO courseVO) {
|
||||||
return courseService.createCourse(course);
|
return courseService.createCourse(courseVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新课程
|
* 更新课程
|
||||||
*/
|
*/
|
||||||
@PutMapping("/update")
|
@PutMapping("/course")
|
||||||
public ResultDomain<TbCourse> updateCourse(@RequestBody TbCourse course) {
|
public ResultDomain<TbCourse> updateCourse(@RequestBody TbCourse course) {
|
||||||
return courseService.updateCourse(course);
|
return courseService.updateCourse(course);
|
||||||
}
|
}
|
||||||
@@ -59,7 +73,7 @@ public class CourseController {
|
|||||||
/**
|
/**
|
||||||
* 删除课程
|
* 删除课程
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/{courseID}")
|
@DeleteMapping("/course")
|
||||||
public ResultDomain<Boolean> deleteCourse(@PathVariable String courseID) {
|
public ResultDomain<Boolean> deleteCourse(@PathVariable String courseID) {
|
||||||
return courseService.deleteCourse(courseID);
|
return courseService.deleteCourse(courseID);
|
||||||
}
|
}
|
||||||
@@ -90,53 +104,4 @@ public class CourseController {
|
|||||||
return courseService.incrementLearnCount(courseID);
|
return courseService.incrementLearnCount(courseID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取课程章节列表
|
|
||||||
*/
|
|
||||||
@GetMapping("/{courseID}/chapters")
|
|
||||||
public ResultDomain<TbCourseChapter> getCourseChapters(@PathVariable String courseID) {
|
|
||||||
return courseService.getCourseChapters(courseID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据ID获取章节详情
|
|
||||||
*/
|
|
||||||
@GetMapping("/chapter/{chapterID}")
|
|
||||||
public ResultDomain<TbCourseChapter> getChapterById(@PathVariable String chapterID) {
|
|
||||||
return courseService.getChapterById(chapterID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建课程章节
|
|
||||||
*/
|
|
||||||
@PostMapping("/chapter/create")
|
|
||||||
public ResultDomain<TbCourseChapter> createChapter(@RequestBody TbCourseChapter chapter) {
|
|
||||||
return courseService.createChapter(chapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新课程章节
|
|
||||||
*/
|
|
||||||
@PutMapping("/chapter/update")
|
|
||||||
public ResultDomain<TbCourseChapter> updateChapter(@RequestBody TbCourseChapter chapter) {
|
|
||||||
return courseService.updateChapter(chapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除课程章节
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/chapter/{chapterID}")
|
|
||||||
public ResultDomain<Boolean> deleteChapter(@PathVariable String chapterID) {
|
|
||||||
return courseService.deleteChapter(chapterID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新章节排序
|
|
||||||
*/
|
|
||||||
@PutMapping("/chapter/{chapterID}/order")
|
|
||||||
public ResultDomain<TbCourseChapter> updateChapterOrder(
|
|
||||||
@PathVariable String chapterID,
|
|
||||||
@RequestParam Integer orderNum) {
|
|
||||||
return courseService.updateChapterOrder(chapterID, orderNum);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,176 +0,0 @@
|
|||||||
package org.xyzh.study.controller;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.xyzh.common.core.domain.ResultDomain;
|
|
||||||
import org.xyzh.common.dto.study.TbCourse;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description 课程管理控制器
|
|
||||||
* @filename CourseManagementController.java
|
|
||||||
* @author yslg
|
|
||||||
* @copyright xyzh
|
|
||||||
* @since 2025-10-15
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/study/course-management")
|
|
||||||
public class CourseManagementController {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CourseManagementController.class);
|
|
||||||
|
|
||||||
// ==================== 课程列表管理 ====================
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页展示所有课程
|
|
||||||
*/
|
|
||||||
@GetMapping("/list")
|
|
||||||
public ResultDomain<TbCourse> getCourseList(
|
|
||||||
@RequestParam(required = false) String courseName,
|
|
||||||
@RequestParam(required = false) String tag,
|
|
||||||
@RequestParam(required = false) Integer pageNum,
|
|
||||||
@RequestParam(required = false) Integer pageSize) {
|
|
||||||
// TODO: 实现分页展示所有课程(支持按课程名称/标签筛选)
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看课程详情
|
|
||||||
*/
|
|
||||||
@GetMapping("/detail/{courseID}")
|
|
||||||
public ResultDomain<TbCourse> getCourseDetail(@PathVariable String courseID) {
|
|
||||||
// TODO: 实现查看课程详情
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 按课程名称筛选
|
|
||||||
*/
|
|
||||||
@GetMapping("/filter/name")
|
|
||||||
public ResultDomain<TbCourse> filterByCourseName(@RequestParam String courseName) {
|
|
||||||
// TODO: 实现按课程名称筛选
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 按标签筛选课程
|
|
||||||
*/
|
|
||||||
@GetMapping("/filter/tag")
|
|
||||||
public ResultDomain<TbCourse> filterByTag(@RequestParam String tag) {
|
|
||||||
// TODO: 实现按标签筛选课程
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== 课程添加管理 ====================
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加课程
|
|
||||||
*/
|
|
||||||
@PostMapping("/add")
|
|
||||||
public ResultDomain<TbCourse> addCourse(@RequestBody Map<String, Object> courseData) {
|
|
||||||
// TODO: 实现添加课程(录入课程名称、上传课程图片、填写课程描述、选择课程标签、设置课程权限、设置课程状态)
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上传课程图片
|
|
||||||
*/
|
|
||||||
@PostMapping("/upload-image")
|
|
||||||
public ResultDomain<String> uploadCourseImage(@RequestParam("file") String file) {
|
|
||||||
// TODO: 实现上传课程图片
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置课程权限
|
|
||||||
*/
|
|
||||||
@PutMapping("/permission/set")
|
|
||||||
public ResultDomain<Boolean> setCoursePermission(@RequestBody Map<String, Object> params) {
|
|
||||||
// TODO: 实现设置课程权限(公开/指定部门)
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置课程状态
|
|
||||||
*/
|
|
||||||
@PutMapping("/status/set")
|
|
||||||
public ResultDomain<Boolean> setCourseStatus(@RequestBody Map<String, Object> params) {
|
|
||||||
// TODO: 实现设置课程状态(未上线/已上线)
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 选择课程标签
|
|
||||||
*/
|
|
||||||
@PutMapping("/tag/select")
|
|
||||||
public ResultDomain<Boolean> selectCourseTags(@RequestBody Map<String, Object> params) {
|
|
||||||
// TODO: 实现选择课程标签
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== 课程维护管理 ====================
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑课程信息
|
|
||||||
*/
|
|
||||||
@PutMapping("/edit")
|
|
||||||
public ResultDomain<TbCourse> editCourseInfo(@RequestBody TbCourse course) {
|
|
||||||
// TODO: 实现编辑课程信息
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新课程内容
|
|
||||||
*/
|
|
||||||
@PutMapping("/content/update")
|
|
||||||
public ResultDomain<Boolean> updateCourseContent(@RequestBody Map<String, Object> params) {
|
|
||||||
// TODO: 实现更新课程内容
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改课程状态
|
|
||||||
*/
|
|
||||||
@PutMapping("/status/change")
|
|
||||||
public ResultDomain<Boolean> changeCourseStatus(@RequestBody Map<String, Object> params) {
|
|
||||||
// TODO: 实现修改课程状态
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除课程
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/{courseID}")
|
|
||||||
public ResultDomain<Boolean> deleteCourse(@PathVariable String courseID) {
|
|
||||||
// TODO: 实现删除课程
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量更新课程状态
|
|
||||||
*/
|
|
||||||
@PutMapping("/batch-status-update")
|
|
||||||
public ResultDomain<Boolean> batchUpdateCourseStatus(@RequestBody Map<String, Object> params) {
|
|
||||||
// TODO: 实现批量更新课程状态
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取课程统计信息
|
|
||||||
*/
|
|
||||||
@GetMapping("/statistics")
|
|
||||||
public ResultDomain<Map<String, Object>> getCourseStatistics(@RequestParam String courseID) {
|
|
||||||
// TODO: 实现获取课程统计信息
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取课程学习情况
|
|
||||||
*/
|
|
||||||
@GetMapping("/learning-status")
|
|
||||||
public ResultDomain<Map<String, Object>> getCourseLearningStatus(@RequestParam String courseID) {
|
|
||||||
// TODO: 实现获取课程学习情况
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
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.TbCourseNode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 学习节点数据访问层
|
||||||
|
* @filename CourseNodeMapper.java
|
||||||
|
* @author yslg
|
||||||
|
* @copyright xyzh
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface CourseNodeMapper extends BaseMapper<TbCourseNode> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 查询学习节点列表
|
||||||
|
* @param filter 过滤条件
|
||||||
|
* @return List<TbCourseNode> 学习节点列表
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
List<TbCourseNode> selectCourseNodes(TbCourseNode filter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 根据章节ID列表查询学习节点列表
|
||||||
|
* @param chapterIDs 章节ID列表
|
||||||
|
* @return List<TbCourseNode> 学习节点列表
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
List<TbCourseNode> selectCourseNodesByChapterIDs(@Param("chapterIDs") List<String> chapterIDs);
|
||||||
|
/**
|
||||||
|
* @description 根据节点ID查询节点信息
|
||||||
|
* @param nodeId 节点ID
|
||||||
|
* @return TbCourseNode 节点信息
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
TbCourseNode selectByNodeId(@Param("nodeId") String nodeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 根据章节ID查询节点列表
|
||||||
|
* @param chapterId 章节ID
|
||||||
|
* @return List<TbCourseNode> 节点列表
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
List<TbCourseNode> selectByChapterId(@Param("chapterId") String chapterId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 根据节点名称查询节点
|
||||||
|
* @param name 节点名称
|
||||||
|
* @return TbCourseNode 节点信息
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
TbCourseNode selectByName(@Param("name") String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 根据节点类型查询节点列表
|
||||||
|
* @param nodeType 节点类型
|
||||||
|
* @return List<TbCourseNode> 节点列表
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
List<TbCourseNode> selectByNodeType(@Param("nodeType") Integer nodeType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 根据章节ID和排序查询节点列表
|
||||||
|
* @param chapterId 章节ID
|
||||||
|
* @return List<TbCourseNode> 节点列表
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
List<TbCourseNode> selectByChapterIdOrderBySort(@Param("chapterId") String chapterId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 检查节点名称是否存在
|
||||||
|
* @param name 节点名称
|
||||||
|
* @param excludeId 排除的节点ID(用于更新时排除自身)
|
||||||
|
* @return int 存在的数量
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
int countByName(@Param("name") String name, @Param("excludeId") String excludeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 插入学习节点
|
||||||
|
* @param courseNode 学习节点
|
||||||
|
* @return int 影响行数
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
int insertCourseNode(TbCourseNode courseNode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 更新学习节点
|
||||||
|
* @param courseNode 学习节点
|
||||||
|
* @return int 影响行数
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
int updateCourseNode(TbCourseNode courseNode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 删除学习节点
|
||||||
|
* @param courseNode 学习节点
|
||||||
|
* @return int 影响行数
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
int deleteCourseNode(TbCourseNode courseNode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 批量插入学习节点
|
||||||
|
* @param courseNodeList 学习节点列表
|
||||||
|
* @return int 影响行数
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
int batchInsertCourseNodes(@Param("courseNodeList") List<TbCourseNode> courseNodeList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 批量删除学习节点
|
||||||
|
* @param ids 节点ID列表
|
||||||
|
* @return int 影响行数
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
int batchDeleteCourseNodes(@Param("nodeIDs") List<String> nodeIDs);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 根据章节ID批量删除节点
|
||||||
|
* @param chapterId 章节ID
|
||||||
|
* @return int 影响行数
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
int deleteByChapterId(@Param("chapterId") String chapterId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 分页查询学习节点
|
||||||
|
* @param filter 过滤条件
|
||||||
|
* @param pageParam 分页参数
|
||||||
|
* @return List<TbCourseNode> 学习节点列表
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
List<TbCourseNode> selectCourseNodesPage(@Param("filter") TbCourseNode filter, @Param("pageParam") PageParam pageParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 统计学习节点总数
|
||||||
|
* @param filter 过滤条件
|
||||||
|
* @return long 总数
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
long countCourseNodes(@Param("filter") TbCourseNode filter);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,15 +1,33 @@
|
|||||||
package org.xyzh.study.service.impl;
|
package org.xyzh.study.service.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.xyzh.common.core.domain.ResultDomain;
|
import org.xyzh.common.core.domain.ResultDomain;
|
||||||
|
import org.xyzh.common.core.page.PageDomain;
|
||||||
|
import org.xyzh.common.core.page.PageParam;
|
||||||
|
import org.xyzh.common.core.page.PageRequest;
|
||||||
import org.xyzh.common.dto.study.TbCourse;
|
import org.xyzh.common.dto.study.TbCourse;
|
||||||
import org.xyzh.common.dto.study.TbCourseChapter;
|
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.user.TbSysUser;
|
||||||
|
import org.xyzh.common.utils.IDUtils;
|
||||||
|
import org.xyzh.common.vo.ChapterVO;
|
||||||
|
import org.xyzh.common.vo.CourseVO;
|
||||||
import org.xyzh.study.mapper.CourseMapper;
|
import org.xyzh.study.mapper.CourseMapper;
|
||||||
|
import org.xyzh.study.mapper.CourseTagMapper;
|
||||||
import org.xyzh.study.mapper.CourseChapterMapper;
|
import org.xyzh.study.mapper.CourseChapterMapper;
|
||||||
|
import org.xyzh.study.mapper.CourseNodeMapper;
|
||||||
import org.xyzh.study.service.SCCourseService;
|
import org.xyzh.study.service.SCCourseService;
|
||||||
|
import org.xyzh.system.utils.LoginUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 课程服务实现类
|
* @description 课程服务实现类
|
||||||
@@ -29,6 +47,12 @@ public class SCCourseServiceImpl implements SCCourseService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CourseChapterMapper courseChapterMapper;
|
private CourseChapterMapper courseChapterMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CourseTagMapper courseTagMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CourseNodeMapper courseNodeMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<TbCourse> getCourseList(TbCourse filter) {
|
public ResultDomain<TbCourse> getCourseList(TbCourse filter) {
|
||||||
// TODO: 实现获取课程列表
|
// TODO: 实现获取课程列表
|
||||||
@@ -36,15 +60,117 @@ public class SCCourseServiceImpl implements SCCourseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<TbCourse> getCourseById(String courseID) {
|
public ResultDomain<TbCourse> getCoursePage(PageRequest<TbCourse> pageRequest) {
|
||||||
// TODO: 实现根据ID获取课程详情
|
ResultDomain<TbCourse> resultDomain = new ResultDomain<>();
|
||||||
return null;
|
TbCourse filter = pageRequest.getFilter();
|
||||||
|
PageParam pageParam = pageRequest.getPageParam();
|
||||||
|
List<TbCourse> courses = courseMapper.selectCoursesPage(filter, pageParam);
|
||||||
|
int total = (int) courseMapper.countCourses(filter);
|
||||||
|
int totalPages = (int) Math.ceil((double) total / pageParam.getPageSize());
|
||||||
|
pageParam.setTotalPages(totalPages);
|
||||||
|
pageParam.setTotalElements(total);
|
||||||
|
PageDomain<TbCourse> pageDomain = new PageDomain<>(pageParam, courses);
|
||||||
|
resultDomain.success("获取课程列表成功", pageDomain);
|
||||||
|
return resultDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<TbCourse> createCourse(TbCourse course) {
|
public ResultDomain<CourseVO> getCourseById(String courseID) {
|
||||||
// TODO: 实现创建课程
|
ResultDomain<CourseVO> resultDomain = new ResultDomain<>();
|
||||||
return null;
|
// 查询课程
|
||||||
|
TbCourse course = courseMapper.selectByCourseId(courseID);
|
||||||
|
// 查询标签
|
||||||
|
List<TbCourseTag> tags = courseTagMapper.selectByCourseId(courseID);
|
||||||
|
CourseVO courseVO = new CourseVO();
|
||||||
|
courseVO.setCourse(course);
|
||||||
|
courseVO.setCourseTags(tags);
|
||||||
|
|
||||||
|
// 查询课程章节
|
||||||
|
TbCourseChapter filter = new TbCourseChapter();
|
||||||
|
filter.setCourseID(courseID);
|
||||||
|
List<TbCourseChapter> chapters = courseChapterMapper.selectCourseChapters(filter);
|
||||||
|
// 查询子节点
|
||||||
|
if (chapters.size() > 0) {
|
||||||
|
List<String> chapterIDs = chapters.stream().map(TbCourseChapter::getChapterID).collect(Collectors.toList());
|
||||||
|
List<TbCourseNode> nodes = courseNodeMapper.selectCourseNodesByChapterIDs(chapterIDs);
|
||||||
|
Map<String, List<TbCourseNode>> nodesMap = nodes.stream().collect(Collectors.groupingBy(TbCourseNode::getChapterID));
|
||||||
|
List<ChapterVO> chapterVOs = chapters.stream().map(chapter -> {
|
||||||
|
ChapterVO chapterVO = new ChapterVO();
|
||||||
|
chapterVO.setChapter(chapter);
|
||||||
|
chapterVO.setNodes(nodesMap.get(chapter.getChapterID()));
|
||||||
|
return chapterVO;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
courseVO.setCourseChapters(chapterVOs);
|
||||||
|
}
|
||||||
|
resultDomain.success("获取课程详情成功", courseVO);
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResultDomain<CourseVO> createCourse(CourseVO courseVO) {
|
||||||
|
ResultDomain<CourseVO> resultDomain = new ResultDomain<>();
|
||||||
|
TbSysUser user = LoginUtil.getCurrentUser();
|
||||||
|
if (user == null) {
|
||||||
|
resultDomain.fail("请先登录");
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
|
TbCourse course = courseVO.getCourse();
|
||||||
|
String courseID = IDUtils.generateID();
|
||||||
|
course.setCreator(user.getID());
|
||||||
|
course.setCourseID(courseID);
|
||||||
|
Date now = new Date();
|
||||||
|
course.setCreateTime(now);
|
||||||
|
course.setStatus(0);
|
||||||
|
|
||||||
|
|
||||||
|
courseMapper.insertCourse(course);
|
||||||
|
|
||||||
|
List<ChapterVO> courseChapters = courseVO.getCourseChapters();
|
||||||
|
List<TbCourseChapter> chapters = new ArrayList<>();
|
||||||
|
List<TbCourseNode> nodes = new ArrayList<>();
|
||||||
|
int length = courseChapters.size();
|
||||||
|
for (int i=0; i<length; i++) {
|
||||||
|
ChapterVO chapterVO = courseChapters.get(i);
|
||||||
|
TbCourseChapter chapter = chapterVO.getChapter();
|
||||||
|
List<TbCourseNode> nodesList = chapterVO.getNodes();
|
||||||
|
|
||||||
|
chapter.setCourseID(courseID);
|
||||||
|
String chapterID = IDUtils.generateID();
|
||||||
|
chapter.setID(IDUtils.generateID());
|
||||||
|
chapter.setChapterID(chapterID);
|
||||||
|
chapter.setCreator(user.getID());
|
||||||
|
chapter.setCreateTime(now);
|
||||||
|
chapter.setOrderNum(i);
|
||||||
|
chapters.add(chapter);
|
||||||
|
|
||||||
|
for (int j=0; j<nodesList.size(); j++) {
|
||||||
|
TbCourseNode node = nodesList.get(j);
|
||||||
|
node.setNodeID(IDUtils.generateID());
|
||||||
|
node.setChapterID(chapterID);
|
||||||
|
node.setCreator(user.getID());
|
||||||
|
node.setCreateTime(now);
|
||||||
|
nodes.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
courseChapterMapper.batchInsertCourseChapters(chapters);
|
||||||
|
courseNodeMapper.batchInsertCourseNodes(nodes);
|
||||||
|
|
||||||
|
List<TbCourseTag> courseTags = courseVO.getCourseTags();
|
||||||
|
length = courseTags.size();
|
||||||
|
if (length > 0) {
|
||||||
|
for (int i=0; i<length; i++) {
|
||||||
|
TbCourseTag tag = courseTags.get(i);
|
||||||
|
tag.setCourseID(courseID);
|
||||||
|
tag.setTagID(IDUtils.generateID());
|
||||||
|
tag.setCreator(user.getID());
|
||||||
|
tag.setCreateTime(now);
|
||||||
|
}
|
||||||
|
courseTagMapper.batchInsertCourseTags(courseTags);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
resultDomain.success("创建课程成功",courseVO);
|
||||||
|
return resultDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,9 +5,13 @@
|
|||||||
<!-- 基础结果映射 -->
|
<!-- 基础结果映射 -->
|
||||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.study.TbCourseChapter">
|
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.study.TbCourseChapter">
|
||||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||||
|
<result column="chapter_id" property="chapterID" jdbcType="VARCHAR"/>
|
||||||
<result column="course_id" property="courseID" jdbcType="VARCHAR"/>
|
<result column="course_id" property="courseID" jdbcType="VARCHAR"/>
|
||||||
|
<result column="parent_id" property="parentID" jdbcType="VARCHAR"/>
|
||||||
<result column="name" property="name" jdbcType="VARCHAR"/>
|
<result column="name" property="name" jdbcType="VARCHAR"/>
|
||||||
<result column="content" property="content" jdbcType="LONGVARCHAR"/>
|
<result column="content" property="content" jdbcType="LONGVARCHAR"/>
|
||||||
|
<result column="chapter_type" property="chapterType" jdbcType="INTEGER"/>
|
||||||
|
<result column="resource_id" property="resourceID" jdbcType="VARCHAR"/>
|
||||||
<result column="video_url" property="videoUrl" jdbcType="VARCHAR"/>
|
<result column="video_url" property="videoUrl" jdbcType="VARCHAR"/>
|
||||||
<result column="duration" property="duration" jdbcType="INTEGER"/>
|
<result column="duration" property="duration" jdbcType="INTEGER"/>
|
||||||
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
|
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
|
||||||
@@ -21,7 +25,7 @@
|
|||||||
|
|
||||||
<!-- 基础字段 -->
|
<!-- 基础字段 -->
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, course_id, name, content, video_url, duration, order_num,
|
id, chapter_id, course_id, parent_id, name, content, chapter_type, resource_id, video_url, duration, order_num,
|
||||||
creator, updater, create_time, update_time, delete_time, deleted
|
creator, updater, create_time, update_time, delete_time, deleted
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
@@ -29,12 +33,21 @@
|
|||||||
<sql id="Where_Clause">
|
<sql id="Where_Clause">
|
||||||
<where>
|
<where>
|
||||||
deleted = 0
|
deleted = 0
|
||||||
|
<if test="chapterID != null and chapterID != ''">
|
||||||
|
AND chapter_id = #{chapterID}
|
||||||
|
</if>
|
||||||
<if test="courseID != null and courseID != ''">
|
<if test="courseID != null and courseID != ''">
|
||||||
AND course_id = #{courseID}
|
AND course_id = #{courseID}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="parentID != null and parentID != ''">
|
||||||
|
AND parent_id = #{parentID}
|
||||||
|
</if>
|
||||||
<if test="name != null and name != ''">
|
<if test="name != null and name != ''">
|
||||||
AND name LIKE CONCAT('%', #{name}, '%')
|
AND name LIKE CONCAT('%', #{name}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="chapterType != null">
|
||||||
|
AND chapter_type = #{chapterType}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
@@ -103,10 +116,10 @@
|
|||||||
<!-- 插入课程章节 -->
|
<!-- 插入课程章节 -->
|
||||||
<insert id="insertCourseChapter" parameterType="org.xyzh.common.dto.study.TbCourseChapter">
|
<insert id="insertCourseChapter" parameterType="org.xyzh.common.dto.study.TbCourseChapter">
|
||||||
INSERT INTO tb_course_chapter (
|
INSERT INTO tb_course_chapter (
|
||||||
id, course_id, name, content, video_url, duration, order_num,
|
id, chapter_id, course_id, parent_id, name, content, chapter_type, resource_id, video_url, duration, order_num,
|
||||||
creator, updater, create_time, update_time, delete_time, deleted
|
creator, updater, create_time, update_time, delete_time, deleted
|
||||||
) VALUES (
|
) VALUES (
|
||||||
#{id}, #{courseID}, #{name}, #{content}, #{videoUrl}, #{duration}, #{orderNum},
|
#{id}, #{chapterID}, #{courseID}, #{parentID}, #{name}, #{content}, #{chapterType}, #{resourceID}, #{videoUrl}, #{duration}, #{orderNum},
|
||||||
#{creator}, #{updater}, #{createTime}, #{updateTime}, #{deleteTime}, #{deleted}
|
#{creator}, #{updater}, #{createTime}, #{updateTime}, #{deleteTime}, #{deleted}
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
@@ -115,15 +128,27 @@
|
|||||||
<update id="updateCourseChapter" parameterType="org.xyzh.common.dto.study.TbCourseChapter">
|
<update id="updateCourseChapter" parameterType="org.xyzh.common.dto.study.TbCourseChapter">
|
||||||
UPDATE tb_course_chapter
|
UPDATE tb_course_chapter
|
||||||
<set>
|
<set>
|
||||||
|
<if test="chapterID != null and chapterID != ''">
|
||||||
|
chapter_id = #{chapterID},
|
||||||
|
</if>
|
||||||
<if test="courseID != null and courseID != ''">
|
<if test="courseID != null and courseID != ''">
|
||||||
course_id = #{courseID},
|
course_id = #{courseID},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="parentID != null">
|
||||||
|
parent_id = #{parentID},
|
||||||
|
</if>
|
||||||
<if test="name != null and name != ''">
|
<if test="name != null and name != ''">
|
||||||
name = #{name},
|
name = #{name},
|
||||||
</if>
|
</if>
|
||||||
<if test="content != null and content != ''">
|
<if test="content != null and content != ''">
|
||||||
content = #{content},
|
content = #{content},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="chapterType != null">
|
||||||
|
chapter_type = #{chapterType},
|
||||||
|
</if>
|
||||||
|
<if test="resourceID != null">
|
||||||
|
resource_id = #{resourceID},
|
||||||
|
</if>
|
||||||
<if test="videoUrl != null and videoUrl != ''">
|
<if test="videoUrl != null and videoUrl != ''">
|
||||||
video_url = #{videoUrl},
|
video_url = #{videoUrl},
|
||||||
</if>
|
</if>
|
||||||
@@ -146,26 +171,25 @@
|
|||||||
deleted = #{deleted},
|
deleted = #{deleted},
|
||||||
</if>
|
</if>
|
||||||
</set>
|
</set>
|
||||||
WHERE id = #{id}
|
WHERE chapter_id = #{chapterID}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<!-- 删除课程章节 -->
|
<!-- 删除课程章节 -->
|
||||||
<delete id="deleteCourseChapter" parameterType="org.xyzh.common.dto.study.TbCourseChapter">
|
<delete id="deleteCourseChapter" parameterType="org.xyzh.common.dto.study.TbCourseChapter">
|
||||||
DELETE FROM tb_course_chapter
|
DELETE FROM tb_course_chapter
|
||||||
WHERE id = #{id}
|
WHERE chapter_id = #{chapterID}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<!-- 批量插入课程章节 -->
|
<!-- 批量插入课程章节 -->
|
||||||
<insert id="batchInsertCourseChapters" parameterType="java.util.List">
|
<insert id="batchInsertCourseChapters" parameterType="java.util.List">
|
||||||
INSERT INTO tb_course_chapter (
|
INSERT INTO tb_course_chapter (
|
||||||
id, course_id, name, content, video_url, duration, order_num,
|
id, chapter_id, course_id, parent_id, name, content, chapter_type, resource_id, video_url, duration, order_num,
|
||||||
creator, updater, create_time, update_time, delete_time, deleted
|
creator, create_time
|
||||||
) VALUES
|
) VALUES
|
||||||
<foreach collection="courseChapterList" item="item" separator=",">
|
<foreach collection="courseChapterList" item="item" separator=",">
|
||||||
(
|
(
|
||||||
#{item.id}, #{item.courseID}, #{item.name}, #{item.content}, #{item.videoUrl},
|
#{item.id}, #{item.chapterID}, #{item.courseID}, #{item.parentID}, #{item.name}, #{item.content}, #{item.chapterType},
|
||||||
#{item.duration}, #{item.orderNum}, #{item.creator}, #{item.updater},
|
#{item.resourceID}, #{item.videoUrl}, #{item.duration}, #{item.orderNum}, #{item.creator}, #{item.createTime}
|
||||||
#{item.createTime}, #{item.updateTime}, #{item.deleteTime}, #{item.deleted}
|
|
||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|||||||
@@ -49,6 +49,31 @@
|
|||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
<sql id="Filter_Clause">
|
||||||
|
<if test="filter != null">
|
||||||
|
<if test="filter.courseID != null and filter.courseID != ''">
|
||||||
|
AND course_id = #{filter.courseID}
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
<if test="filter.name != null and filter.name != ''">
|
||||||
|
AND name LIKE CONCAT('%', #{filter.name}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="filter.teacher != null and filter.teacher != ''">
|
||||||
|
AND teacher LIKE CONCAT('%', #{filter.teacher}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="filter.status != null">
|
||||||
|
AND status = #{filter.status}
|
||||||
|
</if>
|
||||||
|
<if test="filter.orderNum != null">
|
||||||
|
AND order_num = #{filter.orderNum}
|
||||||
|
</if>
|
||||||
|
<if test="filter.creator != null and filter.creator != ''">
|
||||||
|
AND creator = #{filter.creator}
|
||||||
|
</if>
|
||||||
|
<if test="filter.createTime != null">
|
||||||
|
AND create_time = #{filter.createTime}
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
|
|
||||||
<!-- selectCourses -->
|
<!-- selectCourses -->
|
||||||
<select id="selectCourses" resultMap="BaseResultMap">
|
<select id="selectCourses" resultMap="BaseResultMap">
|
||||||
@@ -153,12 +178,10 @@
|
|||||||
<insert id="insertCourse" parameterType="org.xyzh.common.dto.study.TbCourse">
|
<insert id="insertCourse" parameterType="org.xyzh.common.dto.study.TbCourse">
|
||||||
INSERT INTO tb_course (
|
INSERT INTO tb_course (
|
||||||
id, course_id, name, cover_image, description, content, duration,
|
id, course_id, name, cover_image, description, content, duration,
|
||||||
teacher, status, view_count, learn_count, order_num, creator, updater,
|
teacher, status, view_count, learn_count, order_num, creator, create_time
|
||||||
create_time, update_time, delete_time, deleted
|
|
||||||
) VALUES (
|
) VALUES (
|
||||||
#{id}, #{courseID}, #{name}, #{coverImage}, #{description}, #{content}, #{duration},
|
#{id}, #{courseID}, #{name}, #{coverImage}, #{description}, #{content}, #{duration},
|
||||||
#{teacher}, #{status}, #{viewCount}, #{learnCount}, #{orderNum}, #{creator}, #{updater},
|
#{teacher}, #{status}, #{viewCount}, #{learnCount}, #{orderNum}, #{creator},#{createTime}
|
||||||
#{createTime}, #{updateTime}, #{deleteTime}, #{deleted}
|
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -252,7 +275,7 @@
|
|||||||
SELECT
|
SELECT
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
FROM tb_course
|
FROM tb_course
|
||||||
<include refid="Where_Clause" />
|
<include refid="Filter_Clause" />
|
||||||
ORDER BY order_num ASC, create_time DESC
|
ORDER BY order_num ASC, create_time DESC
|
||||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
||||||
</select>
|
</select>
|
||||||
@@ -261,7 +284,7 @@
|
|||||||
<select id="countCourses" resultType="long">
|
<select id="countCourses" resultType="long">
|
||||||
SELECT COUNT(1)
|
SELECT COUNT(1)
|
||||||
FROM tb_course
|
FROM tb_course
|
||||||
<include refid="Where_Clause" />
|
<include refid="Filter_Clause" />
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -0,0 +1,239 @@
|
|||||||
|
<?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.CourseNodeMapper">
|
||||||
|
|
||||||
|
<!-- 基础结果映射 -->
|
||||||
|
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.study.TbCourseNode">
|
||||||
|
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||||
|
<result column="node_id" property="nodeID" jdbcType="VARCHAR"/>
|
||||||
|
<result column="chapter_id" property="chapterID" jdbcType="VARCHAR"/>
|
||||||
|
<result column="name" property="name" jdbcType="VARCHAR"/>
|
||||||
|
<result column="content" property="content" jdbcType="LONGVARCHAR"/>
|
||||||
|
<result column="node_type" property="nodeType" jdbcType="INTEGER"/>
|
||||||
|
<result column="resource_id" property="resourceID" jdbcType="VARCHAR"/>
|
||||||
|
<result column="video_url" property="videoUrl" jdbcType="VARCHAR"/>
|
||||||
|
<result column="duration" property="duration" jdbcType="INTEGER"/>
|
||||||
|
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
|
||||||
|
<result column="is_required" property="isRequired" jdbcType="INTEGER"/>
|
||||||
|
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
||||||
|
<result column="updater" property="updater" jdbcType="VARCHAR"/>
|
||||||
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||||
|
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||||
|
<result column="delete_time" property="deleteTime" jdbcType="TIMESTAMP"/>
|
||||||
|
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 基础字段 -->
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, node_id, chapter_id, name, content, node_type, resource_id, video_url, duration, order_num, is_required,
|
||||||
|
creator, updater, create_time, update_time, delete_time, deleted
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 通用条件 -->
|
||||||
|
<sql id="Where_Clause">
|
||||||
|
<where>
|
||||||
|
deleted = 0
|
||||||
|
<if test="nodeID != null and nodeID != ''">
|
||||||
|
AND node_id = #{nodeID}
|
||||||
|
</if>
|
||||||
|
<if test="chapterID != null and chapterID != ''">
|
||||||
|
AND chapter_id = #{chapterID}
|
||||||
|
</if>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
AND name LIKE CONCAT('%', #{name}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="nodeType != null">
|
||||||
|
AND node_type = #{nodeType}
|
||||||
|
</if>
|
||||||
|
<if test="isRequired != null">
|
||||||
|
AND is_required = #{isRequired}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- selectCourseNodes -->
|
||||||
|
<select id="selectCourseNodes" resultMap="BaseResultMap">
|
||||||
|
SELECT
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
FROM tb_course_node
|
||||||
|
<include refid="Where_Clause"/>
|
||||||
|
ORDER BY order_num ASC, create_time ASC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据节点ID查询节点信息 -->
|
||||||
|
<select id="selectByNodeId" resultMap="BaseResultMap">
|
||||||
|
SELECT
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
FROM tb_course_node
|
||||||
|
WHERE node_id = #{nodeID} AND deleted = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据章节ID查询节点列表 -->
|
||||||
|
<select id="selectByChapterId" resultMap="BaseResultMap">
|
||||||
|
SELECT
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
FROM tb_course_node
|
||||||
|
WHERE chapter_id = #{chapterId} AND deleted = 0
|
||||||
|
ORDER BY order_num ASC, create_time ASC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据节点名称查询节点 -->
|
||||||
|
<select id="selectByName" resultMap="BaseResultMap">
|
||||||
|
SELECT
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
FROM tb_course_node
|
||||||
|
WHERE name = #{name} AND deleted = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据节点类型查询节点列表 -->
|
||||||
|
<select id="selectByNodeType" resultMap="BaseResultMap">
|
||||||
|
SELECT
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
FROM tb_course_node
|
||||||
|
WHERE node_type = #{nodeType} AND deleted = 0
|
||||||
|
ORDER BY order_num ASC, create_time ASC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据章节ID和排序查询节点列表 -->
|
||||||
|
<select id="selectByChapterIdOrderBySort" resultMap="BaseResultMap">
|
||||||
|
SELECT
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
FROM tb_course_node
|
||||||
|
WHERE chapter_id = #{chapterId} AND deleted = 0
|
||||||
|
ORDER BY order_num ASC, create_time ASC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 检查节点名称是否存在 -->
|
||||||
|
<select id="countByName" resultType="int">
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM tb_course_node
|
||||||
|
WHERE name = #{name} AND deleted = 0
|
||||||
|
<if test="excludeId != null and excludeId != ''">
|
||||||
|
AND id != #{excludeId}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 插入学习节点 -->
|
||||||
|
<insert id="insertCourseNode" parameterType="org.xyzh.common.dto.study.TbCourseNode">
|
||||||
|
INSERT INTO tb_course_node (
|
||||||
|
id, chapter_id, name, content, node_type, resource_id, video_url, duration, order_num, is_required,
|
||||||
|
creator, updater, create_time, update_time, delete_time, deleted
|
||||||
|
) VALUES (
|
||||||
|
#{id}, #{chapterID}, #{name}, #{content}, #{nodeType}, #{resourceID}, #{videoUrl}, #{duration}, #{orderNum}, #{isRequired},
|
||||||
|
#{creator}, #{updater}, #{createTime}, #{updateTime}, #{deleteTime}, #{deleted}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 更新学习节点 -->
|
||||||
|
<update id="updateCourseNode" parameterType="org.xyzh.common.dto.study.TbCourseNode">
|
||||||
|
UPDATE tb_course_node
|
||||||
|
<set>
|
||||||
|
<if test="chapterID != null and chapterID != ''">
|
||||||
|
chapter_id = #{chapterID},
|
||||||
|
</if>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
name = #{name},
|
||||||
|
</if>
|
||||||
|
<if test="content != null and content != ''">
|
||||||
|
content = #{content},
|
||||||
|
</if>
|
||||||
|
<if test="nodeType != null">
|
||||||
|
node_type = #{nodeType},
|
||||||
|
</if>
|
||||||
|
<if test="resourceID != null">
|
||||||
|
resource_id = #{resourceID},
|
||||||
|
</if>
|
||||||
|
<if test="videoUrl != null and videoUrl != ''">
|
||||||
|
video_url = #{videoUrl},
|
||||||
|
</if>
|
||||||
|
<if test="duration != null">
|
||||||
|
duration = #{duration},
|
||||||
|
</if>
|
||||||
|
<if test="orderNum != null">
|
||||||
|
order_num = #{orderNum},
|
||||||
|
</if>
|
||||||
|
<if test="isRequired != null">
|
||||||
|
is_required = #{isRequired},
|
||||||
|
</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="deleteCourseNode" parameterType="org.xyzh.common.dto.study.TbCourseNode">
|
||||||
|
DELETE FROM tb_course_node
|
||||||
|
WHERE node_id = #{nodeID}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<!-- 批量插入学习节点 -->
|
||||||
|
<insert id="batchInsertCourseNodes" parameterType="java.util.List">
|
||||||
|
INSERT INTO tb_course_node (
|
||||||
|
id,node_id, chapter_id, name, content, node_type, resource_id, video_url, duration, order_num, is_required,
|
||||||
|
creator, create_time
|
||||||
|
) VALUES
|
||||||
|
<foreach collection="courseNodeList" item="item" separator=",">
|
||||||
|
(
|
||||||
|
#{item.id}, #{item.nodeID}, #{item.chapterID}, #{item.name}, #{item.content}, #{item.nodeType},
|
||||||
|
#{item.resourceID}, #{item.videoUrl}, #{item.duration}, #{item.orderNum}, #{item.isRequired},
|
||||||
|
#{item.creator}, #{item.createTime}
|
||||||
|
)
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 批量删除学习节点 -->
|
||||||
|
<delete id="batchDeleteCourseNodes">
|
||||||
|
DELETE FROM tb_course_node
|
||||||
|
WHERE node_id IN
|
||||||
|
<foreach collection="nodeIDs" item="nodeID" open="(" separator="," close=")">
|
||||||
|
#{nodeID}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<!-- 根据章节ID批量删除节点 -->
|
||||||
|
<delete id="deleteByChapterId">
|
||||||
|
DELETE FROM tb_course_node
|
||||||
|
WHERE chapter_id = #{chapterId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<!-- 分页查询学习节点 -->
|
||||||
|
<select id="selectCourseNodesPage" resultMap="BaseResultMap">
|
||||||
|
SELECT
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
FROM tb_course_node
|
||||||
|
<include refid="Where_Clause" />
|
||||||
|
ORDER BY order_num ASC, create_time ASC
|
||||||
|
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 统计学习节点总数 -->
|
||||||
|
<select id="countCourseNodes" resultType="long">
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM tb_course_node
|
||||||
|
<include refid="Where_Clause" />
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- selectCourseNodesByChapterIDs -->
|
||||||
|
|
||||||
|
<select id="selectCourseNodesByChapterIDs">
|
||||||
|
SELECT
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
FROM tb_course_node
|
||||||
|
WHERE chapter_id IN
|
||||||
|
<foreach collection="chapterIDs" item="chapterID" open="(" separator="," close=")">
|
||||||
|
#{chapterID}
|
||||||
|
</foreach>
|
||||||
|
AND deleted = 0
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -34,7 +34,7 @@ public interface UserCollectionMapper extends BaseMapper<TbUserCollection> {
|
|||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-15
|
* @since 2025-10-15
|
||||||
*/
|
*/
|
||||||
List<TbUserCollection> selectByUserId(@Param("userId") String userId);
|
List<TbUserCollection> selectByUserId(@Param("userID") String userID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 根据用户ID和类型查询收藏记录
|
* @description 根据用户ID和类型查询收藏记录
|
||||||
@@ -44,7 +44,7 @@ public interface UserCollectionMapper extends BaseMapper<TbUserCollection> {
|
|||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-15
|
* @since 2025-10-15
|
||||||
*/
|
*/
|
||||||
List<TbUserCollection> selectByUserIdAndType(@Param("userId") String userId, @Param("collectionType") Integer collectionType);
|
List<TbUserCollection> selectByUserIdAndType(@Param("userID") String userID, @Param("collectionType") Integer collectionType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 根据用户ID查询收藏记录(包含用户基本信息)
|
* @description 根据用户ID查询收藏记录(包含用户基本信息)
|
||||||
@@ -53,7 +53,7 @@ public interface UserCollectionMapper extends BaseMapper<TbUserCollection> {
|
|||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-15
|
* @since 2025-10-15
|
||||||
*/
|
*/
|
||||||
List<TbUserCollection> selectUserCollectionsWithUser(@Param("userId") String userId);
|
List<TbUserCollection> selectUserCollectionsWithUser(@Param("userID") String userID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 查询用户收藏统计
|
* @description 查询用户收藏统计
|
||||||
@@ -62,7 +62,7 @@ public interface UserCollectionMapper extends BaseMapper<TbUserCollection> {
|
|||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-15
|
* @since 2025-10-15
|
||||||
*/
|
*/
|
||||||
TbUserCollection selectCollectionStatistics(@Param("userId") String userId);
|
TbUserCollection selectCollectionStatistics(@Param("userID") String userID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 插入用户收藏
|
* @description 插入用户收藏
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.xyzh.usercenter.service.impl;
|
package org.xyzh.usercenter.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -26,38 +28,92 @@ public class UCUserCollectionServiceImpl implements UCUserCollectionService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<TbUserCollection> addCollection(TbUserCollection userCollection) {
|
public ResultDomain<TbUserCollection> addCollection(TbUserCollection userCollection) {
|
||||||
// TODO: 实现添加收藏
|
int result = userCollectionMapper.insertUserCollection(userCollection);
|
||||||
return null;
|
if (result > 0) {
|
||||||
|
ResultDomain<TbUserCollection> resultDomain = new ResultDomain<>();
|
||||||
|
resultDomain.success("添加收藏成功", userCollection);
|
||||||
|
return resultDomain;
|
||||||
|
} else {
|
||||||
|
ResultDomain<TbUserCollection> resultDomain = new ResultDomain<>();
|
||||||
|
resultDomain.fail("添加收藏失败");
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<TbUserCollection> getCollectionDetail(String userID, Integer collectionType,
|
public ResultDomain<TbUserCollection> getCollectionDetail(String userID, Integer collectionType,
|
||||||
String collectionID) {
|
String collectionID) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<TbUserCollection> getUserCollections(String userID, Integer collectionType) {
|
public ResultDomain<TbUserCollection> getUserCollections(String userID, Integer collectionType) {
|
||||||
// TODO Auto-generated method stub
|
TbUserCollection filter = new TbUserCollection();
|
||||||
return null;
|
filter.setUserID(userID);
|
||||||
|
filter.setCollectionType(collectionType);
|
||||||
|
List<TbUserCollection> list = userCollectionMapper.selectUserCollections(filter);
|
||||||
|
if (list != null && list.size() > 0) {
|
||||||
|
ResultDomain<TbUserCollection> resultDomain = new ResultDomain<>();
|
||||||
|
resultDomain.success("获取收藏列表成功", list);
|
||||||
|
return resultDomain;
|
||||||
|
} else {
|
||||||
|
ResultDomain<TbUserCollection> resultDomain = new ResultDomain<>();
|
||||||
|
resultDomain.fail("获取收藏列表失败");
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<Boolean> isCollected(String userID, Integer collectionType, String collectionID) {
|
public ResultDomain<Boolean> isCollected(String userID, Integer collectionType, String collectionID) {
|
||||||
// TODO Auto-generated method stub
|
TbUserCollection filter = new TbUserCollection();
|
||||||
return null;
|
filter.setUserID(userID);
|
||||||
|
filter.setCollectionType(collectionType);
|
||||||
|
filter.setCollectionID(collectionID);
|
||||||
|
long count = userCollectionMapper.countUserCollections(filter);
|
||||||
|
if (count > 0) {
|
||||||
|
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||||
|
resultDomain.success("已收藏", true);
|
||||||
|
return resultDomain;
|
||||||
|
} else {
|
||||||
|
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||||
|
resultDomain.success("未收藏", false);
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<Boolean> removeCollection(String userID, Integer collectionType, String collectionID) {
|
public ResultDomain<Boolean> removeCollection(String userID, Integer collectionType, String collectionID) {
|
||||||
// TODO Auto-generated method stub
|
TbUserCollection filter = new TbUserCollection();
|
||||||
return null;
|
filter.setUserID(userID);
|
||||||
|
filter.setCollectionType(collectionType);
|
||||||
|
filter.setCollectionID(collectionID);
|
||||||
|
int result = userCollectionMapper.deleteUserCollection(filter);
|
||||||
|
if (result > 0) {
|
||||||
|
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||||
|
resultDomain.success("删除收藏成功", true);
|
||||||
|
return resultDomain;
|
||||||
|
} else {
|
||||||
|
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||||
|
resultDomain.fail("删除收藏失败");
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<Integer> getCollectionCount(String userID, Integer collectionType, String collectionID) {
|
public ResultDomain<Integer> getCollectionCount(String userID, Integer collectionType, String collectionID) {
|
||||||
// TODO Auto-generated method stub
|
TbUserCollection filter = new TbUserCollection();
|
||||||
return null;
|
filter.setUserID(userID);
|
||||||
|
filter.setCollectionType(collectionType);
|
||||||
|
filter.setCollectionID(collectionID);
|
||||||
|
long count = userCollectionMapper.countUserCollections(filter);
|
||||||
|
if (count > 0) {
|
||||||
|
ResultDomain<Integer> resultDomain = new ResultDomain<>();
|
||||||
|
resultDomain.success("获取收藏数量成功", (int)count);
|
||||||
|
return resultDomain;
|
||||||
|
} else {
|
||||||
|
ResultDomain<Integer> resultDomain = new ResultDomain<>();
|
||||||
|
resultDomain.fail("获取收藏数量失败");
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,9 +5,9 @@
|
|||||||
<!-- 结果映射 -->
|
<!-- 结果映射 -->
|
||||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.usercenter.TbUserCollection">
|
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.usercenter.TbUserCollection">
|
||||||
<id column="id" property="id" />
|
<id column="id" property="id" />
|
||||||
<result column="user_id" property="userId" />
|
<result column="user_id" property=".userID" />
|
||||||
<result column="collection_type" property="collectionType" />
|
<result column="collection_type" property="collectionType" />
|
||||||
<result column="collection_id" property="collectionId" />
|
<result column="collection_id" property="collectionID" />
|
||||||
<result column="create_time" property="createTime" />
|
<result column="create_time" property="createTime" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
@@ -23,14 +23,14 @@
|
|||||||
<if test="filter.id != null and filter.id != ''">
|
<if test="filter.id != null and filter.id != ''">
|
||||||
AND id = #{filter.id}
|
AND id = #{filter.id}
|
||||||
</if>
|
</if>
|
||||||
<if test="filter.userId != null and filter.userId != ''">
|
<if test="filter.userID != null and filter.userID != ''">
|
||||||
AND user_id = #{filter.userId}
|
AND user_id = #{filter.userID}
|
||||||
</if>
|
</if>
|
||||||
<if test="filter.collectionType != null">
|
<if test="filter.collectionType != null">
|
||||||
AND collection_type = #{filter.collectionType}
|
AND collection_type = #{filter.collectionType}
|
||||||
</if>
|
</if>
|
||||||
<if test="filter.collectionId != null and filter.collectionId != ''">
|
<if test="filter.collectionID != null and filter.collectionID != ''">
|
||||||
AND collection_id = #{filter.collectionId}
|
AND collection_id = #{filter.collectionID}
|
||||||
</if>
|
</if>
|
||||||
<if test="filter.createTime != null">
|
<if test="filter.createTime != null">
|
||||||
AND create_time = #{filter.createTime}
|
AND create_time = #{filter.createTime}
|
||||||
@@ -105,7 +105,7 @@
|
|||||||
INSERT INTO tb_user_collection (
|
INSERT INTO tb_user_collection (
|
||||||
id, user_id, collection_type, collection_id, create_time
|
id, user_id, collection_type, collection_id, create_time
|
||||||
) VALUES (
|
) VALUES (
|
||||||
#{entity.id}, #{entity.userId}, #{entity.collectionType}, #{entity.collectionId}, #{entity.createTime}
|
#{entity.id}, #{entity.userID}, #{entity.collectionType}, #{entity.collectionID}, #{entity.createTime}
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@
|
|||||||
) VALUES
|
) VALUES
|
||||||
<foreach collection="entities" item="entity" separator=",">
|
<foreach collection="entities" item="entity" separator=",">
|
||||||
(
|
(
|
||||||
#{entity.id}, #{entity.userId}, #{entity.collectionType}, #{entity.collectionId}, #{entity.createTime}
|
#{entity.id}, #{entity.userID}, #{entity.collectionType}, #{entity.collectionID}, #{entity.createTime}
|
||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
@@ -125,14 +125,14 @@
|
|||||||
<update id="updateById" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
<update id="updateById" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
||||||
UPDATE tb_user_collection
|
UPDATE tb_user_collection
|
||||||
<set>
|
<set>
|
||||||
<if test="entity.userId != null and entity.userId != ''">
|
<if test="entity.userID != null and entity.userID != ''">
|
||||||
user_id = #{entity.userId},
|
user_id = #{entity.userID},
|
||||||
</if>
|
</if>
|
||||||
<if test="entity.collectionType != null">
|
<if test="entity.collectionType != null">
|
||||||
collection_type = #{entity.collectionType},
|
collection_type = #{entity.collectionType},
|
||||||
</if>
|
</if>
|
||||||
<if test="entity.collectionId != null and entity.collectionId != ''">
|
<if test="entity.collectionID != null and entity.collectionID != ''">
|
||||||
collection_id = #{entity.collectionId},
|
collection_id = #{entity.collectionID},
|
||||||
</if>
|
</if>
|
||||||
</set>
|
</set>
|
||||||
WHERE id = #{entity.id}
|
WHERE id = #{entity.id}
|
||||||
@@ -142,14 +142,14 @@
|
|||||||
<update id="updateByFilter" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
<update id="updateByFilter" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
||||||
UPDATE tb_user_collection
|
UPDATE tb_user_collection
|
||||||
<set>
|
<set>
|
||||||
<if test="entity.userId != null and entity.userId != ''">
|
<if test="entity.userID != null and entity.userID != ''">
|
||||||
user_id = #{entity.userId},
|
user_id = #{entity.userID},
|
||||||
</if>
|
</if>
|
||||||
<if test="entity.collectionType != null">
|
<if test="entity.collectionType != null">
|
||||||
collection_type = #{entity.collectionType},
|
collection_type = #{entity.collectionType},
|
||||||
</if>
|
</if>
|
||||||
<if test="entity.collectionId != null and entity.collectionId != ''">
|
<if test="entity.collectionID != null and entity.collectionID != ''">
|
||||||
collection_id = #{entity.collectionId},
|
collection_id = #{entity.collectionID},
|
||||||
</if>
|
</if>
|
||||||
</set>
|
</set>
|
||||||
<include refid="Base_Where_Clause" />
|
<include refid="Base_Where_Clause" />
|
||||||
@@ -188,7 +188,7 @@
|
|||||||
SELECT
|
SELECT
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
FROM tb_user_collection
|
FROM tb_user_collection
|
||||||
WHERE user_id = #{userId}
|
WHERE user_id = #{userID}
|
||||||
ORDER BY create_time DESC
|
ORDER BY create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@
|
|||||||
SELECT
|
SELECT
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
FROM tb_user_collection
|
FROM tb_user_collection
|
||||||
WHERE user_id = #{userId} AND collection_type = #{collectionType}
|
WHERE user_id = #{userID} AND collection_type = #{collectionType}
|
||||||
ORDER BY create_time DESC
|
ORDER BY create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@
|
|||||||
uc.id, uc.user_id, uc.collection_type, uc.collection_id, uc.create_time
|
uc.id, uc.user_id, uc.collection_type, uc.collection_id, uc.create_time
|
||||||
FROM tb_user_collection uc
|
FROM tb_user_collection uc
|
||||||
LEFT JOIN tb_sys_user u ON uc.user_id = u.id
|
LEFT JOIN tb_sys_user u ON uc.user_id = u.id
|
||||||
WHERE uc.user_id = #{userId}
|
WHERE uc.user_id = #{userID}
|
||||||
ORDER BY uc.create_time DESC
|
ORDER BY uc.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@
|
|||||||
COUNT(*) as collection_type,
|
COUNT(*) as collection_type,
|
||||||
MAX(create_time) as create_time
|
MAX(create_time) as create_time
|
||||||
FROM tb_user_collection
|
FROM tb_user_collection
|
||||||
WHERE user_id = #{userId}
|
WHERE user_id = #{userID}
|
||||||
GROUP BY user_id
|
GROUP BY user_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@
|
|||||||
INSERT INTO tb_user_collection (
|
INSERT INTO tb_user_collection (
|
||||||
id, user_id, collection_type, collection_id, create_time
|
id, user_id, collection_type, collection_id, create_time
|
||||||
) VALUES (
|
) VALUES (
|
||||||
#{id}, #{userId}, #{collectionType}, #{collectionId}, #{createTime}
|
#{id}, #{userID}, #{collectionType}, #{collectionID}, #{createTime}
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -235,14 +235,14 @@
|
|||||||
<update id="updateUserCollection" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
<update id="updateUserCollection" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
||||||
UPDATE tb_user_collection
|
UPDATE tb_user_collection
|
||||||
<set>
|
<set>
|
||||||
<if test="userId != null and userId != ''">
|
<if test="userID != null and userID != ''">
|
||||||
user_id = #{userId},
|
user_id = #{userID},
|
||||||
</if>
|
</if>
|
||||||
<if test="collectionType != null">
|
<if test="collectionType != null">
|
||||||
collection_type = #{collectionType},
|
collection_type = #{collectionType},
|
||||||
</if>
|
</if>
|
||||||
<if test="collectionId != null and collectionId != ''">
|
<if test="collectionID != null and collectionID != ''">
|
||||||
collection_id = #{collectionId},
|
collection_id = #{collectionID},
|
||||||
</if>
|
</if>
|
||||||
</set>
|
</set>
|
||||||
WHERE id = #{id}
|
WHERE id = #{id}
|
||||||
@@ -251,7 +251,7 @@
|
|||||||
<!-- 删除用户收藏 -->
|
<!-- 删除用户收藏 -->
|
||||||
<delete id="deleteUserCollection" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
<delete id="deleteUserCollection" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
||||||
DELETE FROM tb_user_collection
|
DELETE FROM tb_user_collection
|
||||||
WHERE id = #{id}
|
WHERE user_id = #{userID} AND collection_type = #{collectionType} AND collection_id = #{collectionID}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<!-- 批量插入用户收藏 -->
|
<!-- 批量插入用户收藏 -->
|
||||||
@@ -261,7 +261,7 @@
|
|||||||
) VALUES
|
) VALUES
|
||||||
<foreach collection="userCollectionList" item="item" separator=",">
|
<foreach collection="userCollectionList" item="item" separator=",">
|
||||||
(
|
(
|
||||||
#{item.id}, #{item.userId}, #{item.collectionType}, #{item.collectionId}, #{item.createTime}
|
#{item.id}, #{item.userID}, #{item.collectionType}, #{item.collectionID}, #{item.createTime}
|
||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|||||||
Reference in New Issue
Block a user