提交 9edfa7d2 authored 作者: 任建彩's avatar 任建彩

feat:删除文件

1.resource
上级 22f512fa
...@@ -372,6 +372,8 @@ public class FileController { ...@@ -372,6 +372,8 @@ public class FileController {
if (file.exists() && file.isFile()) { if (file.exists() && file.isFile()) {
String[] cmd = new String[]{"/bin/sh", "-c", "rm -rf " + filePath}; String[] cmd = new String[]{"/bin/sh", "-c", "rm -rf " + filePath};
Process process = Runtime.getRuntime().exec(cmd); Process process = Runtime.getRuntime().exec(cmd);
}else{
throw new FileBizException("没有找到该文件!");
} }
return true; return true;
} }
......
...@@ -103,7 +103,7 @@ public class GoodsLibraryController { ...@@ -103,7 +103,7 @@ public class GoodsLibraryController {
List<String> fileNames = resourceRelationService.queryRelationFileNameList(list); List<String> fileNames = resourceRelationService.queryRelationFileNameList(list);
FileDownloadForm fileForm = new FileDownloadForm(); FileDownloadForm fileForm = new FileDownloadForm();
fileForm.setFileNames(fileNames); fileForm.setFileNames(fileNames);
fileForm.setName(goodsLibrary.getName()); //fileForm.setName(goodsLibrary.getName());
//打包zip //打包zip
String zipFileName = fileClient.wholeDownload(fileForm); String zipFileName = fileClient.wholeDownload(fileForm);
goodsLibrary.setFileName(zipFileName); goodsLibrary.setFileName(zipFileName);
...@@ -111,6 +111,26 @@ public class GoodsLibraryController { ...@@ -111,6 +111,26 @@ public class GoodsLibraryController {
} }
return CallBack.success(true); return CallBack.success(true);
} }
@ApiOperation(value = "删除zip压缩文件")
@PostMapping(value = "/deleteZip")
public CallBack<Boolean> downLoadResource(@RequestBody String id) throws Exception {
GoodsLibrary goodsLibrary = service.getById(id);
if (goodsLibrary != null) {
if (StringUtils.isNotBlank(goodsLibrary.getFileName())) {
//删除源ZIP文件
File file = new File(goodsLibrary.getFileName());
if (file.exists() && file.isFile()) {
String[] cmd = new String[]{"/bin/sh", "-c", "rm -rf " + goodsLibrary.getFileName()};
Process process = Runtime.getRuntime().exec(cmd);
goodsLibrary.setFileName(null);
service.updateById(goodsLibrary);
}else{
throw new ResourceBizException("没有找到该文件!");
}
}
}
return CallBack.success(true);
}
@ApiOperation(value = "查询关联File文件", notes = "查询关联File文件") @ApiOperation(value = "查询关联File文件", notes = "查询关联File文件")
@GetMapping(value = "/getRelationFile") @GetMapping(value = "/getRelationFile")
public CallBack<List<String>> getRelationFile(String id) throws Exception { public CallBack<List<String>> getRelationFile(String id) throws Exception {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论