作业导出判空

This commit is contained in:
lu
2024-08-02 13:40:39 +08:00
parent a9be34631a
commit 389dff8fbe

View File

@@ -20,6 +20,7 @@ import com.xboe.module.course.entity.*;
import com.xboe.module.course.vo.TeacherVo;
import com.xboe.school.study.dao.StudyCourseDao;
import com.xboe.school.study.dao.StudySignupDao;
import com.xboe.school.study.entity.StudyHomeWork;
import com.xboe.school.study.entity.StudySignup;
import com.xboe.school.study.service.IStudyHomeWorkService;
import com.xboe.school.study.service.IStudyService;
@@ -368,13 +369,17 @@ public class CoursePortalApi extends ApiBaseController{
return error("查询不到用户");
}
List<User>user=studyService.getUserNo(userIds);
try {
try {//筛选出的人员
List<StudyCourseItem> list = studyService.getList(courseId, contentId, name, status);
if(list.isEmpty()){
return success("暂无数据");
}
list.stream().filter(Objects::nonNull).forEach(s->{
shomeworkService.getByStudyIdAndContentId(s.getStudyId(),contentId).stream().filter(e-> !Objects.equals(e.getFilePath(), "")).filter(e->e.getFilePath()!=null).forEach(e->{
for (StudyCourseItem s : list) {
List<StudyHomeWork> studyHomeWorks = shomeworkService.getByStudyIdAndContentId(s.getStudyId(), contentId).stream().filter(e-> !Objects.equals(e.getFilePath(), "")).filter(e->e.getFilePath()!=null).collect(Collectors.toList());
if(studyHomeWorks.isEmpty()){
return success("暂无数据");
}
studyHomeWorks.forEach(e->{
user.forEach(u->{
if(u.getId().equals(s.getAid())){
//取后缀
@@ -384,8 +389,7 @@ public class CoursePortalApi extends ApiBaseController{
}
});
});
});
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("导出异常"+e.getMessage());
@@ -410,7 +414,7 @@ public class CoursePortalApi extends ApiBaseController{
// 检查加上当前文件大小后是否会超过2GB
long fileSizeInBytes = fileToZip.length();
if (totalCompressedSize + fileSizeInBytes > 2L * 1024 * 1024 * 1024) {
return success("您要下载的作业过大,请分批下载或联系管理员!");
return success("您要下载的作业过大,联系管理员!");
}
// 添加 ZIP 条目
ZipEntry entry = new ZipEntry(e.getKey());