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