commit
This commit is contained in:
+9
-22
@@ -187,33 +187,20 @@ public class YearPlanController {
|
||||
|
||||
try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())) {
|
||||
for (String url : urlList) {
|
||||
String fileId = extractFileId(url);
|
||||
if(StrUtil.isNotBlank(fileId)) {
|
||||
Sys_file file = dao.fetch(Sys_file.class, fileId);
|
||||
byte[] bytes = SysFileMinIoUtil.getFileBytes(file.getBucket(), file.getStoragePath());
|
||||
if(bytes == null || bytes.length == 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
String entryName = file.getName();
|
||||
zos.putNextEntry(new ZipEntry(entryName));
|
||||
zos.write(bytes);
|
||||
zos.closeEntry();
|
||||
Sys_file file = dao.fetch(Sys_file.class, Cnd.where(Sys_file::getDownloadPath, "=", url));
|
||||
byte[] bytes = SysFileMinIoUtil.getFileBytes(file.getBucket(), file.getStoragePath());
|
||||
if(bytes == null || bytes.length == 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
String entryName = file.getName();
|
||||
zos.putNextEntry(new ZipEntry(entryName));
|
||||
zos.write(bytes);
|
||||
zos.closeEntry();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "生成ZIP文件失败");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String extractFileId(String url) {
|
||||
if (url == null) return null;
|
||||
Pattern pattern = Pattern.compile("[?&]id=([^&]*)");
|
||||
Matcher matcher = pattern.matcher(url);
|
||||
if (matcher.find()) {
|
||||
return matcher.group(1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-22
@@ -168,33 +168,20 @@ public class YearSummaryController {
|
||||
|
||||
try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())) {
|
||||
for (String url : urlList) {
|
||||
String fileId = extractFileId(url);
|
||||
if(StrUtil.isNotBlank(fileId)) {
|
||||
Sys_file file = dao.fetch(Sys_file.class, fileId);
|
||||
byte[] bytes = SysFileMinIoUtil.getFileBytes(file.getBucket(), file.getStoragePath());
|
||||
if(bytes == null || bytes.length == 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
String entryName = file.getName();
|
||||
zos.putNextEntry(new ZipEntry(entryName));
|
||||
zos.write(bytes);
|
||||
zos.closeEntry();
|
||||
Sys_file file = dao.fetch(Sys_file.class, Cnd.where(Sys_file::getDownloadPath, "=", url));
|
||||
byte[] bytes = SysFileMinIoUtil.getFileBytes(file.getBucket(), file.getStoragePath());
|
||||
if(bytes == null || bytes.length == 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
String entryName = file.getName();
|
||||
zos.putNextEntry(new ZipEntry(entryName));
|
||||
zos.write(bytes);
|
||||
zos.closeEntry();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "生成ZIP文件失败");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String extractFileId(String url) {
|
||||
if (url == null) return null;
|
||||
Pattern pattern = Pattern.compile("[?&]id=([^&]*)");
|
||||
Matcher matcher = pattern.matcher(url);
|
||||
if (matcher.find()) {
|
||||
return matcher.group(1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user