Procházet zdrojové kódy

1.课程章节相关功能,所有相关关联信息用关联表动态处理,修改对应增改查
2.修复一些bug

honorfire před 7 měsíci
rodič
revize
5c208fd470

+ 109 - 2
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/controller/CourseChapterController.java

@@ -31,6 +31,7 @@ import vip.xiaonuo.common.pojo.CommonResult;
 import vip.xiaonuo.common.pojo.CommonValidList;
 import vip.xiaonuo.disk.domain.Chapter;
 import vip.xiaonuo.disk.domain.CourseInfo;
+import vip.xiaonuo.disk.domain.CourseRelate;
 import vip.xiaonuo.disk.domain.ResourceRecordUserRelate;
 import vip.xiaonuo.disk.param.ChapterAddParam;
 import vip.xiaonuo.disk.param.ChapterEditParam;
@@ -38,6 +39,7 @@ import vip.xiaonuo.disk.param.ChapterIdParam;
 import vip.xiaonuo.disk.param.ChapterPageParam;
 import vip.xiaonuo.disk.service.ChapterService;
 import vip.xiaonuo.disk.service.ClassHourService;
+import vip.xiaonuo.disk.service.CourseRelateService;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -62,6 +64,8 @@ public class CourseChapterController {
     private ChapterService chapterService;
     @Resource
     private ClassHourService classHourService;
+    @Resource
+    private CourseRelateService courseRelateService;
 
     /**
      * 课程章节表-分页列表
@@ -205,7 +209,14 @@ public class CourseChapterController {
     @PostMapping("/disk/chapter/add")
     public CommonResult<String> add(@RequestBody @Valid ChapterAddParam chapterAddParam) {
         Chapter chapter = BeanUtil.toBean(chapterAddParam, Chapter.class);
-        chapter=chapterService.addOne(chapter);
+        chapterService.addOne(chapter);
+        //添加文件,测验等关联信息
+        List<CourseRelate> courseRelates = chapterAddParam.getCourseRelates();
+        courseRelates = courseRelates.stream()
+                .peek(oneCourseRelate -> oneCourseRelate.setChapterhourType("0")) // 修改属性
+                .peek(oneCourseRelate -> oneCourseRelate.setMainId(chapter.getId())) // 修改属性
+                .collect(Collectors.toList());
+        courseRelateService.addBatch(courseRelates);
         return CommonResult.ok();
     }
 
@@ -222,7 +233,14 @@ public class CourseChapterController {
     @PostMapping("/disk/chapter/edit")
     public CommonResult<String> edit(@RequestBody @Valid ChapterEditParam chapterEditParam) {
         Chapter chapter = BeanUtil.toBean(chapterEditParam, Chapter.class);
-        chapter=chapterService.editOne(chapter);
+        chapterService.editOne(chapter);
+        //添加文件,测验等关联信息
+        List<CourseRelate> courseRelates = chapterEditParam.getCourseRelates();
+        courseRelates = courseRelates.stream()
+                .peek(oneCourseRelate -> oneCourseRelate.setChapterhourType("0")) // 修改属性
+                .peek(oneCourseRelate -> oneCourseRelate.setMainId(chapter.getId())) // 修改属性
+                .collect(Collectors.toList());
+        courseRelateService.addBatch(courseRelates);
         return CommonResult.ok();
     }
 
@@ -257,6 +275,95 @@ public class CourseChapterController {
         Map param =new HashMap();
         param.put("id", req.getParameter("id"));
         Map<String,Object> result=chapterService.queryInfo(param);
+        //查回课程关联信息
+        List<Map<String,Object>> courseRelatesList=new ArrayList<>();
+        Map funcTypeParam =new HashMap();
+        funcTypeParam.put("mainId", chapterIdParam.getId());
+        funcTypeParam.put("chapterhourType","0");
+        List<CourseRelate> relateList=courseRelateService.wrapperList(funcTypeParam);
+        List<String>funcTypeList=CollStreamUtil.toList(relateList, CourseRelate::getFuncType);
+        //去重类型
+        funcTypeList=funcTypeList.stream().distinct().collect(Collectors.toList());
+        Map relateParam =new HashMap();
+        relateParam.put("mainId", req.getParameter("id"));
+        relateParam.put("chapterhourType", "0");
+        //分别查回视频,讲义,字幕,作业,测验等
+        for(String oneFunctype:funcTypeList)
+        {
+            relateParam.put("funcType", oneFunctype);
+            List<Map<String,Object>> videoList=courseRelateService.queryMapList(relateParam);
+            courseRelatesList.addAll(videoList);
+        }
+        result.put("courseRelates", courseRelatesList);
+        return CommonResult.data(result);
+    }
+
+    /**
+     * 课程中心-课程章节表详情
+     *
+     * @author pans
+     * @date  2025/07/02 15:34
+     */
+    @ApiOperationSupport(order = 5)
+    @ApiOperation("课程中心-课程章节表详情")
+    @SaCheckPermission("/disk/coursecentry/chapterDetail")
+    @GetMapping("/disk/coursecentry/chapterDetail")
+    public CommonResult<Map<String,Object>> chapterDetail(@Valid ChapterIdParam chapterIdParam, HttpServletRequest req) {
+        Map param =new HashMap();
+        param.put("id", req.getParameter("id"));
+        Map<String,Object> result=chapterService.queryInfo(param);
+        //查回课程关联信息
+        List<Map<String,Object>> courseRelatesList=new ArrayList<>();
+        Map funcTypeParam =new HashMap();
+        funcTypeParam.put("mainId", chapterIdParam.getId());
+        funcTypeParam.put("chapterhourType","0");
+        List<CourseRelate> relateList=courseRelateService.wrapperList(funcTypeParam);
+        List<String>funcTypeList=CollStreamUtil.toList(relateList, CourseRelate::getFuncType);
+        Map relateParam =new HashMap();
+        relateParam.put("mainId", req.getParameter("id"));
+        relateParam.put("chapterhourType", "0");
+        //分别查回视频,讲义,字幕,作业,测验等
+        for(String oneFunctype:funcTypeList)
+        {
+            relateParam.put("funcType", oneFunctype);
+            List<Map<String,Object>> videoList=courseRelateService.queryMapList(relateParam);
+            courseRelatesList.addAll(videoList);
+        }
+        result.put("courseRelates", courseRelatesList);
+        return CommonResult.data(result);
+    }
+
+    /**
+     * 课程中心-获取课程章节关联资源
+     *
+     * @author pans
+     * @date  2025/07/02 15:34
+     */
+    @ApiOperationSupport(order = 5)
+    @ApiOperation("课程中心-获取课程章节关联资源")
+    @SaCheckPermission("/disk/coursecentry/chapterRelate")
+    @GetMapping("/disk/coursecentry/chapterRelate")
+    public CommonResult<Map<String,Object>> chapterRelate(@Valid ChapterIdParam chapterIdParam, HttpServletRequest req) {
+        Map result=new HashMap();
+        //查回课程关联信息
+        List<Map<String,Object>> courseRelatesList=new ArrayList<>();
+        Map funcTypeParam =new HashMap();
+        funcTypeParam.put("mainId", chapterIdParam.getId());
+        funcTypeParam.put("chapterhourType","1");
+        funcTypeParam.put("funcType",req.getParameter("funcType"));
+        List<CourseRelate> relateList=courseRelateService.wrapperList(funcTypeParam);
+        List<String>funcTypeList=CollStreamUtil.toList(relateList, CourseRelate::getFuncType);
+        Map relateParam =new HashMap();
+        relateParam.put("mainId", req.getParameter("id"));
+        relateParam.put("chapterhourType", "1");
+        //分别查回视频,讲义,字幕,作业,测验等
+        for(String oneFunctype:funcTypeList)
+        {
+            relateParam.put("funcType", oneFunctype);
+            List<Map<String,Object>> videoList=courseRelateService.queryMapList(relateParam);
+            courseRelatesList.addAll(videoList);
+        }
+        result.put("courseRelates", courseRelatesList);
         return CommonResult.data(result);
     }
 

+ 4 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/controller/CourseClassHourController.java

@@ -172,6 +172,8 @@ public class CourseClassHourController {
         funcTypeParam.put("chapterhourType","1");
         List<CourseRelate> relateList=courseRelateService.wrapperList(funcTypeParam);
         List<String>funcTypeList=CollStreamUtil.toList(relateList, CourseRelate::getFuncType);
+        //去重类型
+        funcTypeList=funcTypeList.stream().distinct().collect(Collectors.toList());
         Map relateParam =new HashMap();
         relateParam.put("mainId", req.getParameter("id"));
         relateParam.put("chapterhourType", "1");
@@ -208,6 +210,8 @@ public class CourseClassHourController {
         funcTypeParam.put("chapterhourType","1");
         List<CourseRelate> relateList=courseRelateService.wrapperList(funcTypeParam);
         List<String>funcTypeList=CollStreamUtil.toList(relateList, CourseRelate::getFuncType);
+        //去重类型
+        funcTypeList=funcTypeList.stream().distinct().collect(Collectors.toList());
         Map relateParam =new HashMap();
         relateParam.put("mainId", req.getParameter("id"));
         relateParam.put("chapterhourType", "1");

+ 6 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/param/ChapterAddParam.java

@@ -15,11 +15,13 @@ package vip.xiaonuo.disk.param;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
+import vip.xiaonuo.disk.domain.CourseRelate;
 
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 课程章节表添加参数
@@ -47,4 +49,8 @@ public class ChapterAddParam {
     @ApiModelProperty(value = "文件id", position = 10)
     private String userFileId;
 
+    /** 关联信息 */
+    @ApiModelProperty(value = "关联信息", position = 6)
+    private List<CourseRelate> courseRelates;
+
 }

+ 7 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/param/ChapterEditParam.java

@@ -15,11 +15,13 @@ package vip.xiaonuo.disk.param;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
+import vip.xiaonuo.disk.domain.CourseRelate;
 
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 课程章节表编辑参数
@@ -52,4 +54,9 @@ public class ChapterEditParam {
     @ApiModelProperty(value = "文件id", position = 10)
     private String userFileId;
 
+    /** 关联信息 */
+    @ApiModelProperty(value = "关联信息", position = 6)
+    private List<CourseRelate> courseRelates;
+
+
 }

+ 6 - 2
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/service/impl/CourseRelateServiceImpl.java

@@ -65,14 +65,18 @@ public class CourseRelateServiceImpl extends ServiceImpl<CourseRelateMapper, Cou
     @Override
     public List<CourseRelate> wrapperList(Map param){
         QueryWrapper<CourseRelate> queryWrapper = new QueryWrapper<>();
-        if(StringUtils.isNotEmpty(param.get("mainId").toString()))
+        if(ObjectUtil.isNotEmpty(param.get("mainId")))
         {
             queryWrapper.lambda().eq(CourseRelate::getMainId, param.get("mainId"));
         }
-        if(StringUtils.isNotEmpty(param.get("chapterhourType").toString()))
+        if(ObjectUtil.isNotEmpty(param.get("chapterhourType")))
         {
             queryWrapper.lambda().eq(CourseRelate::getChapterhourType, param.get("chapterhourType"));
         }
+        if(ObjectUtil.isNotEmpty(param.get("funcType")))
+        {
+            queryWrapper.lambda().eq(CourseRelate::getFuncType, param.get("funcType"));
+        }
 
         return this.list(queryWrapper);
     }