serv-学习管理
This commit is contained in:
@@ -6,8 +6,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.xyzh.api.study.course.CourseService;
|
||||
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.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 课程控制器
|
||||
@@ -17,7 +23,7 @@ import org.xyzh.common.dto.study.TbCourseChapter;
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/study/course")
|
||||
@RequestMapping("/study/courses")
|
||||
public class CourseController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CourseController.class);
|
||||
|
||||
@@ -32,26 +38,34 @@ public class CourseController {
|
||||
return courseService.getCourseList(filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取课程列表
|
||||
*/
|
||||
@PostMapping("/page")
|
||||
public ResultDomain<TbCourse> getCoursePage(@RequestBody PageRequest<TbCourse> pageRequest) {
|
||||
return courseService.getCoursePage(pageRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取课程详情
|
||||
*/
|
||||
@GetMapping("/{courseID}")
|
||||
public ResultDomain<TbCourse> getCourseById(@PathVariable String courseID) {
|
||||
public ResultDomain<CourseVO> getCourseById(@PathVariable("courseID") String courseID) {
|
||||
return courseService.getCourseById(courseID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建课程
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
public ResultDomain<TbCourse> createCourse(@RequestBody TbCourse course) {
|
||||
return courseService.createCourse(course);
|
||||
@PostMapping("/course")
|
||||
public ResultDomain<CourseVO> createCourse(@RequestBody CourseVO courseVO) {
|
||||
return courseService.createCourse(courseVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新课程
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
@PutMapping("/course")
|
||||
public ResultDomain<TbCourse> updateCourse(@RequestBody TbCourse course) {
|
||||
return courseService.updateCourse(course);
|
||||
}
|
||||
@@ -59,7 +73,7 @@ public class CourseController {
|
||||
/**
|
||||
* 删除课程
|
||||
*/
|
||||
@DeleteMapping("/{courseID}")
|
||||
@DeleteMapping("/course")
|
||||
public ResultDomain<Boolean> deleteCourse(@PathVariable String courseID) {
|
||||
return courseService.deleteCourse(courseID);
|
||||
}
|
||||
@@ -90,53 +104,4 @@ public class CourseController {
|
||||
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;
|
||||
|
||||
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.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.core.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.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.CourseTagMapper;
|
||||
import org.xyzh.study.mapper.CourseChapterMapper;
|
||||
import org.xyzh.study.mapper.CourseNodeMapper;
|
||||
import org.xyzh.study.service.SCCourseService;
|
||||
import org.xyzh.system.utils.LoginUtil;
|
||||
|
||||
/**
|
||||
* @description 课程服务实现类
|
||||
@@ -29,6 +47,12 @@ public class SCCourseServiceImpl implements SCCourseService {
|
||||
@Autowired
|
||||
private CourseChapterMapper courseChapterMapper;
|
||||
|
||||
@Autowired
|
||||
private CourseTagMapper courseTagMapper;
|
||||
|
||||
@Autowired
|
||||
private CourseNodeMapper courseNodeMapper;
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbCourse> getCourseList(TbCourse filter) {
|
||||
// TODO: 实现获取课程列表
|
||||
@@ -36,15 +60,117 @@ public class SCCourseServiceImpl implements SCCourseService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbCourse> getCourseById(String courseID) {
|
||||
// TODO: 实现根据ID获取课程详情
|
||||
return null;
|
||||
public ResultDomain<TbCourse> getCoursePage(PageRequest<TbCourse> pageRequest) {
|
||||
ResultDomain<TbCourse> resultDomain = new ResultDomain<>();
|
||||
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
|
||||
public ResultDomain<TbCourse> createCourse(TbCourse course) {
|
||||
// TODO: 实现创建课程
|
||||
return null;
|
||||
public ResultDomain<CourseVO> getCourseById(String courseID) {
|
||||
ResultDomain<CourseVO> resultDomain = new ResultDomain<>();
|
||||
// 查询课程
|
||||
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
|
||||
|
||||
@@ -5,9 +5,13 @@
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.study.TbCourseChapter">
|
||||
<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="parent_id" property="parentID" jdbcType="VARCHAR"/>
|
||||
<result column="name" property="name" jdbcType="VARCHAR"/>
|
||||
<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="duration" property="duration" jdbcType="INTEGER"/>
|
||||
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
|
||||
@@ -21,7 +25,7 @@
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<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
|
||||
</sql>
|
||||
|
||||
@@ -29,12 +33,21 @@
|
||||
<sql id="Where_Clause">
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="chapterID != null and chapterID != ''">
|
||||
AND chapter_id = #{chapterID}
|
||||
</if>
|
||||
<if test="courseID != null and courseID != ''">
|
||||
AND course_id = #{courseID}
|
||||
</if>
|
||||
<if test="parentID != null and parentID != ''">
|
||||
AND parent_id = #{parentID}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="chapterType != null">
|
||||
AND chapter_type = #{chapterType}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
@@ -103,10 +116,10 @@
|
||||
<!-- 插入课程章节 -->
|
||||
<insert id="insertCourseChapter" parameterType="org.xyzh.common.dto.study.TbCourseChapter">
|
||||
INSERT INTO tb_course_chapter (
|
||||
id, course_id, name, content, video_url, duration, order_num,
|
||||
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
|
||||
) 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}
|
||||
)
|
||||
</insert>
|
||||
@@ -115,15 +128,27 @@
|
||||
<update id="updateCourseChapter" parameterType="org.xyzh.common.dto.study.TbCourseChapter">
|
||||
UPDATE tb_course_chapter
|
||||
<set>
|
||||
<if test="chapterID != null and chapterID != ''">
|
||||
chapter_id = #{chapterID},
|
||||
</if>
|
||||
<if test="courseID != null and courseID != ''">
|
||||
course_id = #{courseID},
|
||||
</if>
|
||||
<if test="parentID != null">
|
||||
parent_id = #{parentID},
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="content != null and content != ''">
|
||||
content = #{content},
|
||||
</if>
|
||||
<if test="chapterType != null">
|
||||
chapter_type = #{chapterType},
|
||||
</if>
|
||||
<if test="resourceID != null">
|
||||
resource_id = #{resourceID},
|
||||
</if>
|
||||
<if test="videoUrl != null and videoUrl != ''">
|
||||
video_url = #{videoUrl},
|
||||
</if>
|
||||
@@ -146,26 +171,25 @@
|
||||
deleted = #{deleted},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
WHERE chapter_id = #{chapterID}
|
||||
</update>
|
||||
|
||||
<!-- 删除课程章节 -->
|
||||
<delete id="deleteCourseChapter" parameterType="org.xyzh.common.dto.study.TbCourseChapter">
|
||||
DELETE FROM tb_course_chapter
|
||||
WHERE id = #{id}
|
||||
WHERE chapter_id = #{chapterID}
|
||||
</delete>
|
||||
|
||||
<!-- 批量插入课程章节 -->
|
||||
<insert id="batchInsertCourseChapters" parameterType="java.util.List">
|
||||
INSERT INTO tb_course_chapter (
|
||||
id, course_id, name, content, video_url, duration, order_num,
|
||||
creator, updater, create_time, update_time, delete_time, deleted
|
||||
id, chapter_id, course_id, parent_id, name, content, chapter_type, resource_id, video_url, duration, order_num,
|
||||
creator, create_time
|
||||
) VALUES
|
||||
<foreach collection="courseChapterList" item="item" separator=",">
|
||||
(
|
||||
#{item.id}, #{item.courseID}, #{item.name}, #{item.content}, #{item.videoUrl},
|
||||
#{item.duration}, #{item.orderNum}, #{item.creator}, #{item.updater},
|
||||
#{item.createTime}, #{item.updateTime}, #{item.deleteTime}, #{item.deleted}
|
||||
#{item.id}, #{item.chapterID}, #{item.courseID}, #{item.parentID}, #{item.name}, #{item.content}, #{item.chapterType},
|
||||
#{item.resourceID}, #{item.videoUrl}, #{item.duration}, #{item.orderNum}, #{item.creator}, #{item.createTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
@@ -49,6 +49,31 @@
|
||||
</if>
|
||||
</where>
|
||||
</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 -->
|
||||
<select id="selectCourses" resultMap="BaseResultMap">
|
||||
@@ -153,12 +178,10 @@
|
||||
<insert id="insertCourse" parameterType="org.xyzh.common.dto.study.TbCourse">
|
||||
INSERT INTO tb_course (
|
||||
id, course_id, name, cover_image, description, content, duration,
|
||||
teacher, status, view_count, learn_count, order_num, creator, updater,
|
||||
create_time, update_time, delete_time, deleted
|
||||
teacher, status, view_count, learn_count, order_num, creator, create_time
|
||||
) VALUES (
|
||||
#{id}, #{courseID}, #{name}, #{coverImage}, #{description}, #{content}, #{duration},
|
||||
#{teacher}, #{status}, #{viewCount}, #{learnCount}, #{orderNum}, #{creator}, #{updater},
|
||||
#{createTime}, #{updateTime}, #{deleteTime}, #{deleted}
|
||||
#{teacher}, #{status}, #{viewCount}, #{learnCount}, #{orderNum}, #{creator},#{createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
@@ -252,7 +275,7 @@
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_course
|
||||
<include refid="Where_Clause" />
|
||||
<include refid="Filter_Clause" />
|
||||
ORDER BY order_num ASC, create_time DESC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
||||
</select>
|
||||
@@ -261,7 +284,7 @@
|
||||
<select id="countCourses" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_course
|
||||
<include refid="Where_Clause" />
|
||||
<include refid="Filter_Clause" />
|
||||
</select>
|
||||
|
||||
</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>
|
||||
Reference in New Issue
Block a user