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