【8.1.3】【file】更新文件批量获取url方法

dev-8.1.9 v8.1.3
fengshuonan 2024-03-26 23:18:15 +08:00
parent 011bbda9e6
commit bd8222d683
2 changed files with 37 additions and 0 deletions

View File

@ -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
*

View File

@ -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();