抓取失败返回优化
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileInfo upload(MultipartFile file, String path, String storageCode, Boolean createMin, Boolean store) {
|
||||
public FileInfo upload(MultipartFile file, String path, String storageCode, Boolean createMin, Boolean store) {
|
||||
StorageDO storage;
|
||||
if (StrUtil.isBlank(storageCode)) {
|
||||
storage = storageService.getDefaultStorage();
|
||||
@@ -100,13 +100,18 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes
|
||||
}
|
||||
});
|
||||
// 处理本地存储文件 URL
|
||||
FileInfo 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())) {
|
||||
fileInfo.setThUrl(URLUtil.normalize(domain + fileInfo.getPath() + fileInfo.getThFilename()));
|
||||
} else {
|
||||
fileInfo.setThUrl(fileInfo.getUrl());
|
||||
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())) {
|
||||
fileInfo.setThUrl(URLUtil.normalize(domain + fileInfo.getPath() + fileInfo.getThFilename()));
|
||||
} else {
|
||||
fileInfo.setThUrl(fileInfo.getUrl());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return fileInfo;
|
||||
}
|
||||
@@ -146,4 +151,4 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes
|
||||
fileResp.setStorageName("%s (%s)".formatted(storage.getName(), storage.getCode()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user