mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-06 09:26:48 +08:00
Merge branch 'zcwy-0724'
This commit is contained in:
@@ -365,7 +365,7 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
}
|
||||
//作业导出
|
||||
@GetMapping("/export")
|
||||
public JsonResponse<String> export(String courseName,String courseId,String contentId,String name,Integer status) throws IOException {
|
||||
public JsonResponse<String> export(String courseId,String contentId,String name,Integer status) throws IOException {
|
||||
Map<String, String>map=new HashMap<>();
|
||||
List<String> userIds = studyCourseDao.findList(FieldFilters.eq("courseId", courseId)).stream().filter(Objects::nonNull).map(StudyCourse::getAid).collect(Collectors.toList());
|
||||
if (userIds.isEmpty()){
|
||||
@@ -404,21 +404,7 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
if (totalFileSize > 2L * 1024 * 1024 * 1024) {
|
||||
return success("您要下载的作业过大,请分批下载或联系管理员!");
|
||||
}
|
||||
|
||||
// String encodedFilename = URLEncoder.encode(courseName+"【作业】.zip")
|
||||
// .replace("+", "%20") // 空格替换为"%20"
|
||||
// .replace("%2F", "/"); // 解决斜杠问题
|
||||
// StringBuilder contentDispositionValue = new StringBuilder();
|
||||
// contentDispositionValue.append("attachment; filename=\"")
|
||||
// .append(encodedFilename)
|
||||
// .append("\"")
|
||||
// .append("; filename*=utf-8''")
|
||||
// .append(encodedFilename);
|
||||
//
|
||||
// // 设置响应类型和Content-Disposition头
|
||||
// response.setContentType("application/zip");
|
||||
|
||||
// 创建一个临时文件用于存储ZIP文件
|
||||
// 创建一个临时文件用于存储ZIP文件
|
||||
File tempZipFile = new File("/home/www/elearning/upload/temp.zip");
|
||||
|
||||
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tempZipFile))) {
|
||||
@@ -447,6 +433,9 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
Path destination = Paths.get("/home/www/elearning/upload/saveZip/" + uuid + ".zip");
|
||||
|
||||
// 确保目标目录存在
|
||||
Files.createDirectories(destination.getParent());
|
||||
|
||||
// 删除目标文件如果已存在
|
||||
if (Files.exists(destination)) {
|
||||
Files.delete(destination);
|
||||
|
||||
Reference in New Issue
Block a user