BUGFIX: 隐藏加载不出minio的相关数据;
This commit is contained in:
@@ -440,6 +440,16 @@ public class MinioUtil {
|
||||
return getPreSignedUrl(bucketName, String.valueOf(fileName), expiry);
|
||||
}
|
||||
|
||||
public boolean doesObjectExist(String path) {
|
||||
if (!path.contains("/")) {
|
||||
throw new BusinessException("the.path.is.error");
|
||||
}
|
||||
int index = path.indexOf("/");
|
||||
String bucketName = path.substring(0, index);
|
||||
String objectName = path.substring(index + 1);
|
||||
return doesObjectExist(bucketName, objectName);
|
||||
}
|
||||
|
||||
public boolean doesObjectExist(String bucketName, String objectName) {
|
||||
try {
|
||||
minioClient.statObject(
|
||||
|
||||
@@ -101,8 +101,15 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(byId)) {
|
||||
if (minioUtil.doesObjectExist(byId.getUrl())) {
|
||||
response.setMoodTemplateName(byId.getName());
|
||||
response.setMoodTemplateUrl(minioUtil.getPreSignedUrl(byId.getUrl(), 24 * 60));
|
||||
}else {
|
||||
response.setMoodTemplateId(null);
|
||||
if (!StringUtils.isBlank(response.getMoodboardPosition())) {
|
||||
response.setMoodboardPosition(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, List<CollectionElement>> maps = collectionElements
|
||||
@@ -117,28 +124,42 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
|
||||
case MOOD_BOARD:
|
||||
response.setMoodBoards(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
|
||||
d.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||
d.setUrl(minioUtil.getPreSignedUrl(o.getUrl(), 24 * 60));
|
||||
String url = o.getUrl();
|
||||
if (minioUtil.doesObjectExist(url)) {
|
||||
d.setUrl(minioUtil.getPreSignedUrl(url, 24 * 60));
|
||||
} else {
|
||||
response.getMoodBoards().remove(d);
|
||||
}
|
||||
}));
|
||||
break;
|
||||
case PRINT_BOARD:
|
||||
response.setPrintBoards(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
|
||||
d.setIsPin(o.getHasPin());
|
||||
d.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||
d.setUrl(minioUtil.getPreSignedUrl(o.getUrl(), 24 * 60));
|
||||
String url = o.getUrl();
|
||||
if (minioUtil.doesObjectExist(url)) {
|
||||
d.setUrl(minioUtil.getPreSignedUrl(url, 24 * 60));
|
||||
} else {
|
||||
response.getPrintBoards().remove(d);
|
||||
}
|
||||
}));
|
||||
break;
|
||||
case SKETCH_BOARD:
|
||||
response.setSketchBoards(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
|
||||
d.setIsPin(o.getHasPin());
|
||||
d.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||
d.setUrl(minioUtil.getPreSignedUrl(o.getUrl(), 24 * 60));
|
||||
String url = o.getUrl();
|
||||
if (minioUtil.doesObjectExist(url)) {
|
||||
d.setUrl(minioUtil.getPreSignedUrl(url, 24 * 60));
|
||||
if (url.contains(".")) {
|
||||
String[] split = url.split("\\.");
|
||||
d.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60));
|
||||
}else {
|
||||
} else {
|
||||
d.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60));
|
||||
}
|
||||
} else {
|
||||
response.getSketchBoards().remove(d);
|
||||
}
|
||||
}));
|
||||
break;
|
||||
case COLOR_BOARD:
|
||||
|
||||
@@ -1346,6 +1346,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
throw new BusinessException("design.not.found");
|
||||
}
|
||||
List<DesignItemDetail> designItemDetails = designItemDetailService.selectByDesignItemId(designItemId);
|
||||
designItemDetails.removeIf(designItemDetail -> !minioUtil.doesObjectExist(designItemDetail.getPath()));
|
||||
if (CollectionUtil.isEmpty(designItemDetails)) {
|
||||
throw new BusinessException("designItemDetails.not.found");
|
||||
}
|
||||
@@ -1382,6 +1383,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
if (!StringUtil.isNullOrEmpty(o.getUndividedLayer())) d.setUndividedLayer(minioUtil.getPreSignedUrl(o.getUndividedLayer(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
// 根据designItemDetailId获取印花
|
||||
List<DesignItemDetailPrint> prints = designItemDetailPrintService.getByDesignItemDetailId(o.getId(), "print");
|
||||
prints.removeIf(print -> !minioUtil.doesObjectExist(print.getPath()));
|
||||
// 判断有无印花
|
||||
if (CollectionUtil.isNotEmpty(prints)) {
|
||||
// 有印花
|
||||
|
||||
@@ -206,6 +206,8 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
QueryLibraryPageVO libraryPageVO = CopyUtil.copyObject(library, QueryLibraryPageVO.class);
|
||||
libraryPageVO.setDesignType(DesignTypeEnum.LIBRARY.getRealName());
|
||||
libraryPageVO.setMinIOPath(library.getUrl());
|
||||
String url = library.getUrl();
|
||||
if (minioUtil.doesObjectExist(url)) {
|
||||
libraryPageVO.setUrl(minioUtil.getPreSignedUrl(library.getUrl(), 24 * 60));
|
||||
if (finalMap != null && finalMap.containsKey(library.getId())) {
|
||||
libraryPageVO.setLibraryModelPoint(finalMap.get(library.getId()));
|
||||
@@ -225,6 +227,9 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
libraryPageVO.setLevel2TypeEnum(new BizJson(designElementsEnum.getValue(), designElementsEnum.name(), BusinessException.getMessageFromResource(designElementsEnum.name())));
|
||||
}
|
||||
return libraryPageVO;
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
return PageBaseResponse.success(convert);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user