返回文件流接口兼容fileKey值为url情况处理
This commit is contained in:
parent
735fa2c24b
commit
84ff298710
@ -28,4 +28,6 @@ public interface FileDao extends IService<File> {
|
|||||||
List<File> getByFileUuids(List<String> fileKey);
|
List<File> getByFileUuids(List<String> fileKey);
|
||||||
|
|
||||||
List<File> getByUrlMd5s(List<String> urlMd5List);
|
List<File> getByUrlMd5s(List<String> urlMd5List);
|
||||||
|
|
||||||
|
File getByUrlMd5(String urlMd5);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,4 +53,13 @@ public class FileDaoImpl extends ServiceImpl<FileMapper, File> implements FileDa
|
|||||||
.eq(File::getIsDelete, TableDelete.UN_DELETED)
|
.eq(File::getIsDelete, TableDelete.UN_DELETED)
|
||||||
.list();
|
.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getByUrlMd5(String urlMd5) {
|
||||||
|
return lambdaQuery().eq(File::getUrlMd5, urlMd5)
|
||||||
|
.eq(File::getStatus, FileStatus.SUCCESS)
|
||||||
|
.eq(File::getIsDelete, TableDelete.UN_DELETED)
|
||||||
|
.last("limit 1")
|
||||||
|
.one();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -157,8 +157,14 @@ public class FileServiceImpl implements FileService {
|
|||||||
@Override
|
@Override
|
||||||
public ServerFileDownloadResponse download(ServerFileDownloadDto dto) {
|
public ServerFileDownloadResponse download(ServerFileDownloadDto dto) {
|
||||||
log.info("file download dto = {}", JsonUtil.obj2Str(dto));
|
log.info("file download dto = {}", JsonUtil.obj2Str(dto));
|
||||||
|
File file = null;
|
||||||
String fileKey = dto.getFileKey();
|
String fileKey = dto.getFileKey();
|
||||||
File file = fileDao.getByFileUuid(fileKey);
|
if (fileKey.contains(IS_URL)) {
|
||||||
|
String urlMd5 = Utility.getMd5(fileKey);
|
||||||
|
file = fileDao.getByUrlMd5(urlMd5);
|
||||||
|
} else {
|
||||||
|
file = fileDao.getByFileUuid(fileKey);
|
||||||
|
}
|
||||||
if (Utility.objIsNull(file)) {
|
if (Utility.objIsNull(file)) {
|
||||||
log.warn("file download is null, fileKey = {}", fileKey);
|
log.warn("file download is null, fileKey = {}", fileKey);
|
||||||
BizException.error(Utility.objIsNotNull(file), CodeEnum.FILE_NOT_FOUND);
|
BizException.error(Utility.objIsNotNull(file), CodeEnum.FILE_NOT_FOUND);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user