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