feat(infra): 文件列表及详情接口增加私有桶预签名
- FileController.getFilePage/getFile 对私有桶文件 URL 生成预签名访问地址 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -77,7 +77,12 @@ public class FileController {
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:file:query')")
|
||||
public CommonResult<FileRespVO> getFile(@RequestParam("id") Long id) {
|
||||
return success(BeanUtils.toBean(fileService.getFile(id), FileRespVO.class));
|
||||
FileRespVO respVO = BeanUtils.toBean(fileService.getFile(id), FileRespVO.class);
|
||||
// 私有桶:对文件 URL 生成预签名访问地址
|
||||
if (respVO != null && StrUtil.isNotEmpty(respVO.getUrl())) {
|
||||
respVO.setUrl(fileService.presignGetUrl(respVO.getUrl(), null));
|
||||
}
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@@ -131,7 +136,14 @@ public class FileController {
|
||||
@PreAuthorize("@ss.hasPermission('infra:file:query')")
|
||||
public CommonResult<PageResult<FileRespVO>> getFilePage(@Valid FilePageReqVO pageVO) {
|
||||
PageResult<FileDO> pageResult = fileService.getFilePage(pageVO);
|
||||
return success(BeanUtils.toBean(pageResult, FileRespVO.class));
|
||||
PageResult<FileRespVO> voPageResult = BeanUtils.toBean(pageResult, FileRespVO.class);
|
||||
// 私有桶:对文件 URL 生成预签名访问地址
|
||||
voPageResult.getList().forEach(vo -> {
|
||||
if (StrUtil.isNotEmpty(vo.getUrl())) {
|
||||
vo.setUrl(fileService.presignGetUrl(vo.getUrl(), null));
|
||||
}
|
||||
});
|
||||
return success(voPageResult);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user