|
@@ -129,8 +129,8 @@ public class LessonCoursewareController extends BaseController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "获取课件关联的课程列表")
|
|
|
- @GetMapping("/getLessonCoursewareCourseList")
|
|
|
- public HttpResponseResult<List<LessonCoursewareWrapper.CourseScheduleCoursewareDetail>> getLessonCoursewareCourseList(Long id,String search){
|
|
|
+ @GetMapping("/getLessonCoursewareCourseList/{id}")
|
|
|
+ public HttpResponseResult<List<LessonCoursewareWrapper.CourseScheduleCoursewareDetail>> getLessonCoursewareCourseList(@PathVariable("id") Long id,String search){
|
|
|
List<CbsLessonCoursewareWrapper.CourseScheduleCoursewareDetail> courseScheduleCoursewareDetails = coursewareFeignService.coursewareDetail(id).feignData();
|
|
|
if (CollectionUtils.isNotEmpty(courseScheduleCoursewareDetails)) {
|
|
|
if(StringUtils.isNotEmpty(search)){
|
|
@@ -161,26 +161,36 @@ public class LessonCoursewareController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 对 children 进行处理:始终对 child 的 materialList 进行模糊匹配
|
|
|
+ // 处理子知识点的 materialList,始终进行模糊搜索
|
|
|
List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> children = knowledgePointSmall.getChildren();
|
|
|
if (CollectionUtils.isNotEmpty(children)) {
|
|
|
- for (CbsLessonCoursewareDetailWrapper.KnowledgePointSmall child : children) {
|
|
|
- List<CbsLessonCoursewareDetailWrapper.MaterialSmall> childMaterialList = child.getMaterialList();
|
|
|
-
|
|
|
- // 对子知识点的 materialList 进行模糊搜索
|
|
|
- if (CollectionUtils.isNotEmpty(childMaterialList)) {
|
|
|
- if (StringUtils.isNotEmpty(search)) {
|
|
|
- childMaterialList = childMaterialList.stream()
|
|
|
- .filter(materialSmall -> materialSmall.getName().contains(search))
|
|
|
- .collect(Collectors.toList());
|
|
|
- child.setMaterialList(childMaterialList);
|
|
|
- }
|
|
|
-
|
|
|
- // 如果子知识点的 materialList 仍不为空,保留该子知识点
|
|
|
- if (CollectionUtils.isNotEmpty(childMaterialList)) {
|
|
|
- return true; // 保留该知识点
|
|
|
- }
|
|
|
- }
|
|
|
+ // 对 children 中每个子知识点的 materialList 进行模糊匹配
|
|
|
+ List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> validChildren = children.stream()
|
|
|
+ .filter(child -> {
|
|
|
+ List<CbsLessonCoursewareDetailWrapper.MaterialSmall> childMaterialList = child.getMaterialList();
|
|
|
+
|
|
|
+ // 对子知识点的 materialList 进行模糊搜索
|
|
|
+ if (CollectionUtils.isNotEmpty(childMaterialList)) {
|
|
|
+ if (StringUtils.isNotEmpty(search)) {
|
|
|
+ childMaterialList = childMaterialList.stream()
|
|
|
+ .filter(materialSmall -> materialSmall.getName().contains(search))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ child.setMaterialList(childMaterialList);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果子知识点的 materialList 仍不为空,保留该子知识点
|
|
|
+ return CollectionUtils.isNotEmpty(childMaterialList);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 更新 children 为剔除空的 materialList 后的有效子知识点
|
|
|
+ knowledgePointSmall.setChildren(validChildren);
|
|
|
+
|
|
|
+ // 如果 children 中有有效的子知识点,保留该知识点
|
|
|
+ if (!validChildren.isEmpty()) {
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -191,6 +201,7 @@ public class LessonCoursewareController extends BaseController {
|
|
|
// 更新 courseScheduleCoursewareDetail 的 knowledgePointList
|
|
|
courseScheduleCoursewareDetail.setKnowledgePointList(knowledgePointList);
|
|
|
}
|
|
|
+
|
|
|
// 返回更新后的 courseScheduleCoursewareDetail
|
|
|
return courseScheduleCoursewareDetail;
|
|
|
}).collect(Collectors.toList());
|