TASK:模块化;
This commit is contained in:
@@ -121,8 +121,8 @@ public class ProjectController {
|
||||
@GetMapping("/downloadZip")
|
||||
@ApiOperationSupport(order = 11)
|
||||
@ApiOperation(value = "下载", notes = "传入project")
|
||||
public void downloadZip(@RequestParam(value = "threeDSimpleId") Long threeDSimpleId, @RequestParam(value = "sizeType") String sizeType, @RequestParam(value = "size") String size, HttpServletResponse response) throws MinioException, IOException {
|
||||
userLikeGroupService.downloadZip(threeDSimpleId, sizeType, size, response);
|
||||
public Response<String> downloadZip(@RequestParam(value = "threeDSimpleId") Long threeDSimpleId, @RequestParam(value = "sizeType") String sizeType, @RequestParam(value = "size") String size, HttpServletResponse response) throws MinioException, IOException {
|
||||
return Response.success(userLikeGroupService.downloadZip(threeDSimpleId, sizeType, size, response));
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
|
||||
@@ -102,7 +102,7 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
||||
|
||||
void getThreeDGlb(Long threeDSimpleId, HttpServletResponse response) throws MinioException, IOException;
|
||||
|
||||
void downloadZip(Long threeDSimpleId, String sizeType, String size, HttpServletResponse response) throws MinioException, IOException;
|
||||
String downloadZip(Long threeDSimpleId, String sizeType, String size, HttpServletResponse response) throws MinioException, IOException;
|
||||
|
||||
Boolean delete(Long projectId);
|
||||
}
|
||||
|
||||
@@ -2145,7 +2145,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadZip(Long threeDSimpleId, String sizeType, String size, HttpServletResponse response) throws MinioException, IOException {
|
||||
public String downloadZip(Long threeDSimpleId, String sizeType, String size, HttpServletResponse response) throws MinioException, IOException {
|
||||
QueryWrapper<ThreeDDetail> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(ThreeDDetail::getThreeDSimpleId, threeDSimpleId);
|
||||
qw.lambda().eq(ThreeDDetail::getSizeType, sizeType);
|
||||
@@ -2154,29 +2154,29 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
if (ObjectUtils.isAllFieldNull(threeDDetail)) {
|
||||
throw new BusinessException("3D file is not exist");
|
||||
}
|
||||
InputStream inputStream = minioUtil.download(threeDDetail.getUrl());
|
||||
return minioUtil.getPreSignedUrl(threeDDetail.getUrl(), 24 * 60);
|
||||
|
||||
// 设置响应头
|
||||
response.setContentType("application/zip"); // 确保 ZIP 格式
|
||||
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
String fileName = threeDDetail.getName();
|
||||
if (!fileName.toLowerCase().endsWith(".zip")) {
|
||||
fileName += ".zip";
|
||||
}
|
||||
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString()));
|
||||
|
||||
// 将文件内容写入响应输出流
|
||||
try {
|
||||
byte[] buffer = new byte[8192];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
response.getOutputStream().write(buffer, 0, bytesRead);
|
||||
}
|
||||
inputStream.close();
|
||||
response.getOutputStream().flush();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to download ZIP file", e);
|
||||
}
|
||||
// // 设置响应头
|
||||
// response.setContentType("application/zip"); // 确保 ZIP 格式
|
||||
// response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
// String fileName = threeDDetail.getName();
|
||||
// if (!fileName.toLowerCase().endsWith(".zip")) {
|
||||
// fileName += ".zip";
|
||||
// }
|
||||
// response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString()));
|
||||
//
|
||||
// // 将文件内容写入响应输出流
|
||||
// try {
|
||||
// byte[] buffer = new byte[8192];
|
||||
// int bytesRead;
|
||||
// while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
// response.getOutputStream().write(buffer, 0, bytesRead);
|
||||
// }
|
||||
// inputStream.close();
|
||||
// response.getOutputStream().flush();
|
||||
// } catch (Exception e) {
|
||||
// throw new RuntimeException("Failed to download ZIP file", e);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user