mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-11 03:46:50 +08:00
作业导出增加返回值
This commit is contained in:
@@ -366,15 +366,15 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
}
|
}
|
||||||
//作业导出
|
//作业导出
|
||||||
@GetMapping("/export")
|
@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 {
|
||||||
Map<String, String>map=new HashMap<>();
|
Map<String, String>map=new HashMap<>();
|
||||||
try {
|
try {
|
||||||
List<StudyCourseItem> list = studyService.getList(courseId, contentId, name, status);
|
List<StudyCourseItem> list = studyService.getList(courseId, contentId, name, status);
|
||||||
if(list.isEmpty()){
|
if(list.isEmpty()){
|
||||||
throw new RuntimeException("暂无数据");
|
return success("暂无数据");
|
||||||
}
|
}
|
||||||
list.stream().filter(Objects::nonNull).forEach(s->{
|
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('/'); // 查找最后一个'.'的位置
|
int dotIndex = e.getFilePath().lastIndexOf('/'); // 查找最后一个'.'的位置
|
||||||
String extension = e.getFilePath().substring(dotIndex+1);
|
String extension = e.getFilePath().substring(dotIndex+1);
|
||||||
@@ -406,7 +406,7 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
// 检查加上当前文件大小后,是否会超过2GB
|
// 检查加上当前文件大小后,是否会超过2GB
|
||||||
long fileSizeInBytes = fileToZip.length();
|
long fileSizeInBytes = fileToZip.length();
|
||||||
if (totalCompressedSize + fileSizeInBytes > 2L * 1024 * 1024 * 1024) {
|
if (totalCompressedSize + fileSizeInBytes > 2L * 1024 * 1024 * 1024) {
|
||||||
throw new RuntimeException("您要下载的作业过大,请分批下载或联系管理员!");
|
return success("您要下载的作业过大,请分批下载或联系管理员!");
|
||||||
}
|
}
|
||||||
// 添加 ZIP 条目
|
// 添加 ZIP 条目
|
||||||
ZipEntry entry = new ZipEntry(e.getKey());
|
ZipEntry entry = new ZipEntry(e.getKey());
|
||||||
@@ -426,6 +426,7 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
zos.closeEntry();
|
zos.closeEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return success("导出成功");
|
||||||
}
|
}
|
||||||
@GetMapping("/detail-study")
|
@GetMapping("/detail-study")
|
||||||
public JsonResponse<List<CourseStudyVo>> detailStudy(String courseId, String aid){
|
public JsonResponse<List<CourseStudyVo>> detailStudy(String courseId, String aid){
|
||||||
|
|||||||
Reference in New Issue
Block a user