|
@@ -79,7 +79,7 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
|
|
String path = file.getUrlName();
|
|
String path = file.getUrlName();
|
|
file.setFilePath(getFilePath(file, path));
|
|
file.setFilePath(getFilePath(file, path));
|
|
if (file.getType() == 2) {
|
|
if (file.getType() == 2) {
|
|
- handleCourseFile(file);
|
|
|
|
|
|
+ handleCourseFile(file,true);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
courseHandoutsVo.setFileList(courseFileVos);
|
|
courseHandoutsVo.setFileList(courseFileVos);
|
|
@@ -87,7 +87,48 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
|
|
List<CourseFileVo> fileVos = courseFileVos.stream().filter(item -> item.getParentId() == 0L).collect(Collectors.toList());
|
|
List<CourseFileVo> fileVos = courseFileVos.stream().filter(item -> item.getParentId() == 0L).collect(Collectors.toList());
|
|
if (!CollectionUtils.isEmpty(fileVos)) {
|
|
if (!CollectionUtils.isEmpty(fileVos)) {
|
|
fileVos.forEach(file -> {
|
|
fileVos.forEach(file -> {
|
|
- assembleFile(file, courseFileVos);
|
|
|
|
|
|
+ assembleFile(file, courseFileVos,true);
|
|
|
|
+ });
|
|
|
|
+ courseHandoutsVo.setFileList(fileVos);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return courseHandoutsVo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public CourseHandoutsVo queryByIdNoUrl(CourseHandoutsFileQueryBo queryBo) {
|
|
|
|
+ CourseHandouts db = this.baseMapper.selectById(queryBo.getHandoutsId());
|
|
|
|
+ if (Validator.isEmpty(db)) {
|
|
|
|
+ throw new CustomException("查无数据");
|
|
|
|
+ }
|
|
|
|
+ //获得讲义业务层
|
|
|
|
+ CourseHandoutsVo courseHandoutsVo = BeanUtil.toBean(db, CourseHandoutsVo.class);
|
|
|
|
+ List<CourseHandoutsBusinessVo> courseHandoutsBusinessVos = baseMapper.selectEntity(courseHandoutsVo.getHandoutsId());
|
|
|
|
+ courseHandoutsVo.setCourseHandoutsBusinessVo(courseHandoutsBusinessVos);
|
|
|
|
+
|
|
|
|
+ CourseFileQueryBo bo = new CourseFileQueryBo();
|
|
|
|
+ bo.setHandoutsId(courseHandoutsVo.getHandoutsId());
|
|
|
|
+ bo.setUrlName(queryBo.getFileName());
|
|
|
|
+ List<CourseFileVo> courseFileVos = iCourseFileService.queryList(bo);
|
|
|
|
+ if (CollectionUtils.isEmpty(courseFileVos)) {
|
|
|
|
+ courseHandoutsVo.setFileList(new ArrayList<>());
|
|
|
|
+ return courseHandoutsVo;
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(queryBo.getFileName())) {
|
|
|
|
+ courseFileVos.forEach(file -> {
|
|
|
|
+ //获取路径
|
|
|
|
+ String path = file.getUrlName();
|
|
|
|
+ file.setFilePath(getFilePath(file, path));
|
|
|
|
+ if (file.getType() == 2) {
|
|
|
|
+ handleCourseFile(file,false);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ courseHandoutsVo.setFileList(courseFileVos);
|
|
|
|
+ } else {
|
|
|
|
+ List<CourseFileVo> fileVos = courseFileVos.stream().filter(item -> item.getParentId() == 0L).collect(Collectors.toList());
|
|
|
|
+ if (!CollectionUtils.isEmpty(fileVos)) {
|
|
|
|
+ fileVos.forEach(file -> {
|
|
|
|
+ assembleFile(file, courseFileVos,false);
|
|
});
|
|
});
|
|
courseHandoutsVo.setFileList(fileVos);
|
|
courseHandoutsVo.setFileList(fileVos);
|
|
}
|
|
}
|
|
@@ -104,7 +145,10 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
|
|
return getFilePath(BeanUtil.toBean(courseFile, CourseFileVo.class), urlName);
|
|
return getFilePath(BeanUtil.toBean(courseFile, CourseFileVo.class), urlName);
|
|
}
|
|
}
|
|
|
|
|
|
- private void handleCourseFile(CourseFileVo file) {
|
|
|
|
|
|
+ private void handleCourseFile(CourseFileVo file,Boolean withUrl) {
|
|
|
|
+ if(!withUrl){
|
|
|
|
+ file.setUrl(null);
|
|
|
|
+ }
|
|
List<CourseFile> list = iCourseFileService
|
|
List<CourseFile> list = iCourseFileService
|
|
.list(new LambdaQueryWrapper<CourseFile>()
|
|
.list(new LambdaQueryWrapper<CourseFile>()
|
|
.eq(CourseFile::getParentId, file.getFileId())
|
|
.eq(CourseFile::getParentId, file.getFileId())
|
|
@@ -113,12 +157,15 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
list.forEach(item -> {
|
|
list.forEach(item -> {
|
|
- handleCourseFile(BeanUtil.toBean(item, CourseFileVo.class));
|
|
|
|
|
|
+ handleCourseFile(BeanUtil.toBean(item, CourseFileVo.class),withUrl);
|
|
});
|
|
});
|
|
file.setChildren(list.stream().map(x -> BeanUtil.toBean(x, CourseFileVo.class)).collect(Collectors.toList()));
|
|
file.setChildren(list.stream().map(x -> BeanUtil.toBean(x, CourseFileVo.class)).collect(Collectors.toList()));
|
|
}
|
|
}
|
|
|
|
|
|
- private void assembleFile(CourseFileVo parent, List<CourseFileVo> childs) {
|
|
|
|
|
|
+ private void assembleFile(CourseFileVo parent, List<CourseFileVo> childs,Boolean withUrl) {
|
|
|
|
+ if(!withUrl){
|
|
|
|
+ parent.setUrl(null);
|
|
|
|
+ }
|
|
if (CollectionUtils.isEmpty(childs)) {
|
|
if (CollectionUtils.isEmpty(childs)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -128,7 +175,7 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
|
|
}
|
|
}
|
|
parent.setChildren(collect);
|
|
parent.setChildren(collect);
|
|
collect.forEach(item -> {
|
|
collect.forEach(item -> {
|
|
- assembleFile(item, childs);
|
|
|
|
|
|
+ assembleFile(item, childs,withUrl);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|