|
@@ -96,11 +96,14 @@ public class CourseClassHourController {
|
|
|
classHourService.addOne(classHour);
|
|
classHourService.addOne(classHour);
|
|
|
//添加文件,测验等关联信息
|
|
//添加文件,测验等关联信息
|
|
|
List<CourseRelate> courseRelates = classHourAddParam.getCourseRelates();
|
|
List<CourseRelate> courseRelates = classHourAddParam.getCourseRelates();
|
|
|
- courseRelates = courseRelates.stream()
|
|
|
|
|
- .peek(oneCourseRelate -> oneCourseRelate.setChapterhourType("1")) // 修改属性
|
|
|
|
|
- .peek(oneCourseRelate -> oneCourseRelate.setMainId(classHour.getId())) // 修改属性
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
- courseRelateService.addBatch(courseRelates);
|
|
|
|
|
|
|
+ if(courseRelates.size()>0)
|
|
|
|
|
+ {
|
|
|
|
|
+ courseRelates = courseRelates.stream()
|
|
|
|
|
+ .peek(oneCourseRelate -> oneCourseRelate.setChapterhourType("1")) // 修改属性
|
|
|
|
|
+ .peek(oneCourseRelate -> oneCourseRelate.setMainId(classHour.getId())) // 修改属性
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ courseRelateService.addBatch(courseRelates);
|
|
|
|
|
+ }
|
|
|
return CommonResult.ok();
|
|
return CommonResult.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -118,21 +121,23 @@ public class CourseClassHourController {
|
|
|
ClassHour classHour = classHourService.queryEntity(classHourEditParam.getId());
|
|
ClassHour classHour = classHourService.queryEntity(classHourEditParam.getId());
|
|
|
BeanUtil.copyProperties(classHourEditParam, classHour);
|
|
BeanUtil.copyProperties(classHourEditParam, classHour);
|
|
|
classHourService.editOne(classHour);
|
|
classHourService.editOne(classHour);
|
|
|
- //先删除过往关联内容
|
|
|
|
|
- Map relateParam =new HashMap();
|
|
|
|
|
- relateParam.put("mainId", classHour.getId());
|
|
|
|
|
- relateParam.put("chapterhourType","0");
|
|
|
|
|
- List<CourseRelate> delCourseRelateList=courseRelateService.wrapperList(relateParam);
|
|
|
|
|
- List<String> delCourseRelateIdList=CollStreamUtil.toList(delCourseRelateList, CourseRelate::getId);
|
|
|
|
|
- courseRelateService.deleteByIds(delCourseRelateIdList);
|
|
|
|
|
//重新添加关联内容
|
|
//重新添加关联内容
|
|
|
List<CourseRelate> courseRelates = classHourEditParam.getCourseRelates();
|
|
List<CourseRelate> courseRelates = classHourEditParam.getCourseRelates();
|
|
|
- courseRelates = courseRelates.stream()
|
|
|
|
|
- .peek(oneCourseRelate -> oneCourseRelate.setChapterhourType("1"))
|
|
|
|
|
- .peek(oneCourseRelate -> oneCourseRelate.setMainId(classHour.getId())) // 修改属性
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
- courseRelateService.addBatch(courseRelates);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if(courseRelates.size()>0)
|
|
|
|
|
+ {
|
|
|
|
|
+ //先删除过往关联内容
|
|
|
|
|
+ Map relateParam =new HashMap();
|
|
|
|
|
+ relateParam.put("mainId", classHour.getId());
|
|
|
|
|
+ relateParam.put("chapterhourType","0");
|
|
|
|
|
+ List<CourseRelate> delCourseRelateList=courseRelateService.wrapperList(relateParam);
|
|
|
|
|
+ List<String> delCourseRelateIdList=CollStreamUtil.toList(delCourseRelateList, CourseRelate::getId);
|
|
|
|
|
+ courseRelateService.deleteByIds(delCourseRelateIdList);
|
|
|
|
|
+ courseRelates = courseRelates.stream()
|
|
|
|
|
+ .peek(oneCourseRelate -> oneCourseRelate.setChapterhourType("1"))
|
|
|
|
|
+ .peek(oneCourseRelate -> oneCourseRelate.setMainId(classHour.getId())) // 修改属性
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ courseRelateService.addBatch(courseRelates);
|
|
|
|
|
+ }
|
|
|
return CommonResult.ok();
|
|
return CommonResult.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|