抓取失败返回优化

This commit is contained in:
2026-03-09 16:25:41 +08:00
parent e4d6de61ae
commit df9479f870
2 changed files with 15 additions and 10 deletions

View File

@@ -418,7 +418,7 @@ public class MaterialInfoServiceImpl extends BaseServiceImpl<MaterialInfoMapper,
public String catchPhoto(MultipartFile file){ public String catchPhoto(MultipartFile file){
String photoStoragePath = "catch" + DateUtil.today() + "/"; String photoStoragePath = "catch" + DateUtil.today() + "/";
FileInfo fileInfo = fileService.upload(file, photoStoragePath, null, true, true); FileInfo fileInfo = fileService.upload(file, photoStoragePath, null, true, true);
CheckUtils.throwIfEmpty(fileInfo.getUrl(),"上传失败,请重新上传"); CheckUtils.throwIfNull(fileInfo,"照片上传失败");
return fileInfo.getUrl(); return fileInfo.getUrl();
} }

View File

@@ -100,7 +100,9 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes
} }
}); });
// 处理本地存储文件 URL // 处理本地存储文件 URL
FileInfo fileInfo = uploadPretreatment.upload(); FileInfo fileInfo = null;
try {
fileInfo = uploadPretreatment.upload();
String domain = StrUtil.appendIfMissing(storage.getDomain(), StringConstants.SLASH); String domain = StrUtil.appendIfMissing(storage.getDomain(), StringConstants.SLASH);
fileInfo.setUrl(URLUtil.normalize(domain + fileInfo.getPath() + fileInfo.getFilename())); fileInfo.setUrl(URLUtil.normalize(domain + fileInfo.getPath() + fileInfo.getFilename()));
if (StrUtil.isNotBlank(fileInfo.getThFilename())) { if (StrUtil.isNotBlank(fileInfo.getThFilename())) {
@@ -108,6 +110,9 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes
} else { } else {
fileInfo.setThUrl(fileInfo.getUrl()); fileInfo.setThUrl(fileInfo.getUrl());
} }
} catch (Exception e) {
}
return fileInfo; return fileInfo;
} }