mirror of https://gitee.com/stylefeng/roses
parent
011bbda9e6
commit
bd8222d683
|
@ -80,6 +80,16 @@ public interface FileInfoApi {
|
|||
*/
|
||||
String getFileUnAuthUrl(Long fileId);
|
||||
|
||||
/**
|
||||
* 获取文件的下载地址(不带鉴权的),生成外网地址
|
||||
*
|
||||
* @param fileIdList 文件id集合
|
||||
* @return 外部系统可以直接访问的url
|
||||
* @author fengshuonan
|
||||
* @since 2024/3/26 22:38
|
||||
*/
|
||||
List<String> batchGetFileUnAuthUrl(List<Long> fileIdList);
|
||||
|
||||
/**
|
||||
* 获取AntdV组件格式对应的文件信息封装
|
||||
*
|
||||
|
|
|
@ -514,6 +514,33 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> batchGetFileUnAuthUrl(List<Long> fileIdList) {
|
||||
if (ObjectUtil.isEmpty(fileIdList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
LambdaQueryWrapper<SysFileInfo> sysFileInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sysFileInfoLambdaQueryWrapper.in(SysFileInfo::getFileId, fileIdList);
|
||||
sysFileInfoLambdaQueryWrapper.select(SysFileInfo::getFileId, SysFileInfo::getFileLocation, SysFileInfo::getFileBucket, SysFileInfo::getFileObjectName);
|
||||
List<SysFileInfo> list = this.list(sysFileInfoLambdaQueryWrapper);
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
ArrayList<String> urlList = new ArrayList<>();
|
||||
for (SysFileInfo sysFileInfo : list) {
|
||||
String url;
|
||||
if (sysFileInfo.getFileLocation().equals(FileLocationEnum.DB.getCode())) {
|
||||
url = this.sysFileStorageService.getFileUnAuthUrl(String.valueOf(sysFileInfo.getFileId()));
|
||||
} else {
|
||||
// 返回第三方存储文件url
|
||||
url = fileOperatorApi.getFileUnAuthUrl(sysFileInfo.getFileBucket(), sysFileInfo.getFileObjectName());
|
||||
}
|
||||
urlList.add(url);
|
||||
}
|
||||
return urlList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AntdvFileInfo buildAntdvFileInfo(Long fileId) {
|
||||
AntdvFileInfo antdvFileInfo = new AntdvFileInfo();
|
||||
|
|
Loading…
Reference in New Issue