From f79a159e2295c971086b60c3232ee53c1b8ad0dd Mon Sep 17 00:00:00 2001 From: lu Date: Wed, 31 Jul 2024 17:48:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=AF=BC=E5=87=BA=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=BF=94=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xboe/module/course/api/CoursePortalApi.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CoursePortalApi.java b/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CoursePortalApi.java index c06882f5..bcfc7094 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CoursePortalApi.java +++ b/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CoursePortalApi.java @@ -366,15 +366,15 @@ public class CoursePortalApi extends ApiBaseController{ } //作业导出 @GetMapping("/export") - public void export(String courseName,String courseId,String contentId,String name,Integer status,HttpServletResponse response) throws IOException { + public JsonResponse export(String courseName,String courseId,String contentId,String name,Integer status,HttpServletResponse response) throws IOException { Mapmap=new HashMap<>(); try { List list = studyService.getList(courseId, contentId, name, status); if(list.isEmpty()){ - throw new RuntimeException("暂无数据"); + return success("暂无数据"); } list.stream().filter(Objects::nonNull).forEach(s->{ - shomeworkService.getByStudyIdAndContentId(s.getStudyId(),contentId).stream().filter(Objects::nonNull).filter(e->e.getFilePath()!=null).forEach(e->{ + shomeworkService.getByStudyIdAndContentId(s.getStudyId(),contentId).stream().filter(e-> !Objects.equals(e.getFilePath(), "")).filter(e->e.getFilePath()!=null).forEach(e->{ //取作业后缀名 int dotIndex = e.getFilePath().lastIndexOf('/'); // 查找最后一个'.'的位置 String extension = e.getFilePath().substring(dotIndex+1); @@ -406,7 +406,7 @@ public class CoursePortalApi extends ApiBaseController{ // 检查加上当前文件大小后,是否会超过2GB long fileSizeInBytes = fileToZip.length(); if (totalCompressedSize + fileSizeInBytes > 2L * 1024 * 1024 * 1024) { - throw new RuntimeException("您要下载的作业过大,请分批下载或联系管理员!"); + return success("您要下载的作业过大,请分批下载或联系管理员!"); } // 添加 ZIP 条目 ZipEntry entry = new ZipEntry(e.getKey()); @@ -426,6 +426,7 @@ public class CoursePortalApi extends ApiBaseController{ zos.closeEntry(); } } + return success("导出成功"); } @GetMapping("/detail-study") public JsonResponse> detailStudy(String courseId, String aid){