抓取失败返回优化

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){
String photoStoragePath = "catch" + DateUtil.today() + "/";
FileInfo fileInfo = fileService.upload(file, photoStoragePath, null, true, true);
CheckUtils.throwIfEmpty(fileInfo.getUrl(),"上传失败,请重新上传");
CheckUtils.throwIfNull(fileInfo,"照片上传失败");
return fileInfo.getUrl();
}

View File

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