Skip to content

Commit 7e77e3a

Browse files
committed
feat: 添加文件删除接口
1 parent f15a0e6 commit 7e77e3a

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public PageResult<PlgFilePageResVo> page(@RequestBody @Valid PlgFilePageReqVo re
6666
return new PageResult<>((int) pageInfo.getTotal(), voList);
6767
}
6868

69-
@ApiOperation("删除-批量")
69+
@ApiOperation("删除记录-批量")
7070
@PostMapping("record/delete")
7171
public boolean delete(@RequestBody @NotEmpty List<Long> idList) {
7272
return plgFileService.removeBatchByIds(idList);
@@ -132,4 +132,20 @@ public void downloadTemp(HttpServletResponse response,
132132
fileStorageService.download(fileInfo).inputStream(in -> ServletUtil.write(response, in));
133133
fileStorageService.delete(fileInfo);
134134
}
135+
136+
@ApiOperation("通用删除文件-byUrl")
137+
@PostMapping("storage/delete_by_url")
138+
public boolean deleteFile(@RequestParam String url) {
139+
return fileStorageService.delete(url);
140+
}
141+
142+
@ApiOperation("通用删除文件-byId")
143+
@PostMapping("storage/delete_by_id")
144+
public List<FileInfo> deleteFiles(@RequestBody List<Long> idList) {
145+
List<PlgFile> plgFileList = plgFileService.listByIds(idList);
146+
List<FileInfo> fileInfoList = PlgFileConvert.INSTANCE.poToFileInfo(plgFileList);
147+
return fileInfoList.stream()
148+
.filter(fileStorageService::delete)
149+
.collect(Collectors.toList());
150+
}
135151
}

framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgFileConvert.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ public interface PlgFileConvert {
2929
PlgFile fileInfoToPo(FileInfo fileInfo);
3030

3131
List<PlgFilePageResVo> poToPageResVo(List<PlgFile> poList);
32+
33+
List<FileInfo> poToFileInfo(List<PlgFile> plgFileList);
3234
}

0 commit comments

Comments
 (0)