|
@@ -14,6 +14,7 @@ package vip.xiaonuo.disk.controller;
|
|
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
|
@@ -29,11 +30,17 @@ import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
|
|
|
import vip.xiaonuo.common.annotation.CommonLog;
|
|
import vip.xiaonuo.common.annotation.CommonLog;
|
|
|
import vip.xiaonuo.common.pojo.CommonResult;
|
|
import vip.xiaonuo.common.pojo.CommonResult;
|
|
|
import vip.xiaonuo.common.pojo.CommonValidList;
|
|
import vip.xiaonuo.common.pojo.CommonValidList;
|
|
|
|
|
+import vip.xiaonuo.disk.domain.Chapter;
|
|
|
|
|
+import vip.xiaonuo.disk.domain.ClassHour;
|
|
|
|
|
+import vip.xiaonuo.disk.domain.CourseAuditRecord;
|
|
|
import vip.xiaonuo.disk.domain.CourseInfo;
|
|
import vip.xiaonuo.disk.domain.CourseInfo;
|
|
|
import vip.xiaonuo.disk.param.courseInfo.CourseInfoAddParam;
|
|
import vip.xiaonuo.disk.param.courseInfo.CourseInfoAddParam;
|
|
|
import vip.xiaonuo.disk.param.courseInfo.CourseInfoEditParam;
|
|
import vip.xiaonuo.disk.param.courseInfo.CourseInfoEditParam;
|
|
|
import vip.xiaonuo.disk.param.courseInfo.CourseInfoIdParam;
|
|
import vip.xiaonuo.disk.param.courseInfo.CourseInfoIdParam;
|
|
|
import vip.xiaonuo.disk.param.courseInfo.CourseInfoPageParam;
|
|
import vip.xiaonuo.disk.param.courseInfo.CourseInfoPageParam;
|
|
|
|
|
+import vip.xiaonuo.disk.param.courseauditrecord.CourseAuditRecordEditParam;
|
|
|
|
|
+import vip.xiaonuo.disk.service.ChapterService;
|
|
|
|
|
+import vip.xiaonuo.disk.service.ClassHourService;
|
|
|
import vip.xiaonuo.disk.service.CourseAuditRecordService;
|
|
import vip.xiaonuo.disk.service.CourseAuditRecordService;
|
|
|
import vip.xiaonuo.disk.service.CourseInfoService;
|
|
import vip.xiaonuo.disk.service.CourseInfoService;
|
|
|
|
|
|
|
@@ -42,6 +49,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 课程信息表控制器
|
|
* 课程信息表控制器
|
|
@@ -59,6 +67,10 @@ public class CourseInfoController {
|
|
|
private CourseInfoService courseInfoService;
|
|
private CourseInfoService courseInfoService;
|
|
|
@Resource
|
|
@Resource
|
|
|
private CourseAuditRecordService courseAuditRecordService;
|
|
private CourseAuditRecordService courseAuditRecordService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private ChapterService chapterService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private ClassHourService classHourService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 课程信息-分页列表
|
|
* 课程信息-分页列表
|
|
@@ -263,4 +275,105 @@ public class CourseInfoController {
|
|
|
return CommonResult.data(result);
|
|
return CommonResult.data(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 课程中心-添加浏览次数
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author honorfire
|
|
|
|
|
+ * @date 2025/06/20 14:58
|
|
|
|
|
+ */
|
|
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
|
|
+ @ApiOperation("课程中心-添加浏览次数")
|
|
|
|
|
+ @CommonLog("课程中心-添加浏览次数")
|
|
|
|
|
+ @SaCheckPermission("/disk/coursecentry/addViewCount")
|
|
|
|
|
+ @PostMapping("/disk/coursecentry/addViewCount")
|
|
|
|
|
+ public CommonResult<String> addViewCount(@RequestBody @Valid CourseInfoEditParam courseInfoEditParam) {
|
|
|
|
|
+ CourseInfo courseInfo=courseInfoService.queryEntity(courseInfoEditParam.getCourseId());
|
|
|
|
|
+ courseInfo.setViewCount(String.valueOf(Integer.valueOf(courseInfo.getViewCount())+1));
|
|
|
|
|
+ courseInfoService.editOne(courseInfo);
|
|
|
|
|
+ return CommonResult.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 课程信息-复制课程
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author honorfire
|
|
|
|
|
+ * @date 2025/06/20 15:00
|
|
|
|
|
+ */
|
|
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
|
|
+ @ApiOperation("课程信息-编辑")
|
|
|
|
|
+ @CommonLog("课程信息-编辑")
|
|
|
|
|
+ @SaCheckPermission("/disk/courseinfo/copy")
|
|
|
|
|
+ @PostMapping("/disk/courseinfo/copy")
|
|
|
|
|
+ public CommonResult<String> copy(@RequestBody @Valid CourseInfoEditParam courseInfoEditParam) {
|
|
|
|
|
+ //查回课程基础信息
|
|
|
|
|
+ CourseInfo courseInfo=courseInfoService.queryEntity(courseInfoEditParam.getCourseId());
|
|
|
|
|
+ //查回课程所有章节信息
|
|
|
|
|
+ Map param =new HashMap();
|
|
|
|
|
+ param.put("courseId", courseInfoEditParam.getCourseId());
|
|
|
|
|
+ List<Map<String,Object>> chapterList=chapterService.queryAllList(param);
|
|
|
|
|
+ //查回课程所有课时信息进行复制
|
|
|
|
|
+ List<String> chapterIdList= chapterList.stream().map(map -> (String) map.get("id")).collect(Collectors.toList());
|
|
|
|
|
+ param.clear();
|
|
|
|
|
+ param.put("chapterIdList", chapterIdList);
|
|
|
|
|
+ //只查出资源审核通过的课时
|
|
|
|
|
+ param.put("verifyPass", "1");
|
|
|
|
|
+ List<Map<String,Object>> classHourList =classHourService.queryAllList(param);
|
|
|
|
|
+ //进行复制步骤
|
|
|
|
|
+ //1.添加课程信息
|
|
|
|
|
+ CourseInfo newCourseInfo=new CourseInfo();
|
|
|
|
|
+ BeanUtil.copyProperties(courseInfo, newCourseInfo);
|
|
|
|
|
+ newCourseInfo.setCourseId(null);
|
|
|
|
|
+ newCourseInfo=courseInfoService.addOne(newCourseInfo);
|
|
|
|
|
+ //2.添加章节和对应课时信息
|
|
|
|
|
+ //预添加章节列表
|
|
|
|
|
+ List<Chapter> chapterAddList=new ArrayList<>();
|
|
|
|
|
+ //预添加课时列表
|
|
|
|
|
+ List<ClassHour> classHourAddList=new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ for (Map<String, Object> chapter : chapterList) {
|
|
|
|
|
+ if (chapter == null || chapter.get("id") == null) continue;
|
|
|
|
|
+ //先预先准备该章节信息
|
|
|
|
|
+ Chapter addChapter=new Chapter();
|
|
|
|
|
+ String willAddChapterId=IdUtil.getSnowflakeNextIdStr();
|
|
|
|
|
+ addChapter.setId(willAddChapterId);
|
|
|
|
|
+ addChapter.setCourseId(newCourseInfo.getCourseId());
|
|
|
|
|
+ addChapter.setName(chapter.get("name").toString());
|
|
|
|
|
+ addChapter.setPid(chapter.get("pid").toString());
|
|
|
|
|
+ chapterAddList.add(addChapter);
|
|
|
|
|
+
|
|
|
|
|
+ String chapterId = chapter.get("id").toString();
|
|
|
|
|
+ List<Map<String, Object>> chapterClassHours = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 倒序遍历课程列表(关键点!)
|
|
|
|
|
+ for (int i = classHourList.size() - 1; i >= 0; i--) {
|
|
|
|
|
+ Map<String, Object> classHour = classHourList.get(i);
|
|
|
|
|
+ if (classHour == null || classHour.get("chapterId") == null) continue;
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 匹配当前章节
|
|
|
|
|
+ if (chapterId.equals(classHour.get("chapterId").toString())) {
|
|
|
|
|
+ //预先准备该课时信息
|
|
|
|
|
+ ClassHour addClassHour=new ClassHour();
|
|
|
|
|
+ addClassHour.setId(IdUtil.getSnowflakeNextIdStr());
|
|
|
|
|
+ addClassHour.setChapterId(willAddChapterId);
|
|
|
|
|
+ addClassHour.setName(classHour.get("name").toString());
|
|
|
|
|
+ if(StringUtils.isEmpty(classHour.get("startTime").toString()))addClassHour.setStartTime(new Date(classHour.get("startTime").toString()));
|
|
|
|
|
+ if(StringUtils.isEmpty(classHour.get("endTime").toString()))addClassHour.setEndTime(new Date(classHour.get("endTime").toString()));
|
|
|
|
|
+ addClassHour.setVideoResource(classHour.get("videoResource").toString());
|
|
|
|
|
+ addClassHour.setTeachmaterialsFile(classHour.get("teachmaterialsFile").toString());
|
|
|
|
|
+ addClassHour.setSubtitleFile(classHour.get("subtitleFile").toString());
|
|
|
|
|
+ addClassHour.setRemark(classHour.get("remark").toString());
|
|
|
|
|
+ classHourAddList.add(addClassHour);
|
|
|
|
|
+
|
|
|
|
|
+ //为效率,匹配完的从列表中剔除
|
|
|
|
|
+ classHourList.remove(i); // 从原列表删除(安全操作)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ chapter.put("classHours", chapterClassHours);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return CommonResult.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|