Merge remote-tracking branch 'origin/release/3.0' into release/3.0

This commit is contained in:
2025-03-18 15:33:38 +08:00
5 changed files with 150 additions and 57 deletions

View File

@@ -101,13 +101,21 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
}
}
if (Objects.nonNull(byId)) {
response.setMoodTemplateName(byId.getName());
response.setMoodTemplateUrl(minioUtil.getPreSignedUrl(byId.getUrl(), 24 * 60));
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
.stream()
.collect(Collectors.groupingBy(CollectionElement::getLevel1Type));
maps.forEach((k, v) -> {
CollectionLevel1TypeEnum level1TypeEnum = CollectionLevel1TypeEnum.uploadOf(k);
if (Objects.isNull(level1TypeEnum)) {
@@ -115,43 +123,70 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
}
switch (level1TypeEnum) {
case MOOD_BOARD:
response.setMoodBoards(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
List<CollectionElementVO> moodBoards = CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
d.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
d.setUrl(minioUtil.getPreSignedUrl(o.getUrl(), 24 * 60));
}));
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));
}));
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 (url.contains(".")) {
String[] split = url.split("\\.");
d.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60));
}else {
d.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60));
d.setOriginalUrl(url);
if (minioUtil.doesObjectExist(url)) {
d.setUrl(minioUtil.getPreSignedUrl(url, 24 * 60));
}
}));
});
response.setMoodBoards(moodBoards.stream()
.filter(d -> minioUtil.doesObjectExist(d.getOriginalUrl()))
.collect(Collectors.toList()));
break;
case PRINT_BOARD:
List<CollectionElementVO> printBoards = CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
d.setIsPin(o.getHasPin());
d.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
String url = o.getUrl();
d.setOriginalUrl(url);
if (minioUtil.doesObjectExist(url)) {
d.setUrl(minioUtil.getPreSignedUrl(url, 24 * 60));
}
});
response.setPrintBoards(printBoards.stream()
.filter(d -> minioUtil.doesObjectExist(d.getOriginalUrl()))
.collect(Collectors.toList()));
break;
case SKETCH_BOARD:
List<CollectionElementVO> sketchBoards = CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
d.setIsPin(o.getHasPin());
d.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
String url = o.getUrl();
d.setOriginalUrl(url);
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 {
d.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60));
}
}
});
response.setSketchBoards(sketchBoards.stream()
.filter(d -> minioUtil.doesObjectExist(d.getOriginalUrl()))
.collect(Collectors.toList()));
break;
case COLOR_BOARD:
response.setColorBoards(resolveColorBoard(v));
break;
case MARKETING_SKETCH:
response.setMarketingSketchs(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
d.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
}));
break;
default:
break;
}
});
if (CollectionUtil.isNotEmpty(response.getColorBoards())) {
List<CollectionColorVO> collect = response.getColorBoards().stream()
.distinct()

View File

@@ -1348,6 +1348,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");
}
@@ -1384,6 +1385,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)) {
// 有印花
@@ -1408,6 +1410,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
d.setMinIOPath(o.getPath());
d.setPrintObject(new DesignPythonItemPrint());
}));
response.getOthers().removeIf(o -> !minioUtil.doesObjectExist(o.getMinIOPath()));
return editDesignItemLayer(flag, designPythonOutfit,
minioUtil.getPreSignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60),
editResponseColor(designItemDetails, response));

View File

@@ -51,6 +51,7 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
@@ -182,51 +183,93 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
}
}
queryWrapper.orderByDesc("id");
IPage<Library> page = getBaseMapper().selectPage(
new Page<>(query.getPage(), query.getSize()), queryWrapper);
if (CollectionUtils.isEmpty(page.getRecords())) {
// 1. 先查询所有符合条件的 Library 数据
List<Library> libraryList = getBaseMapper().selectList(queryWrapper);
if (CollectionUtils.isEmpty(libraryList)) {
return PageBaseResponse.success(new Page<>());
}
// 2. 封装打点内容
Map<Long, LibraryModelPointVO> map = null;
//封装打点内容
Boolean isExist = page.getRecords().stream()
boolean isExist = libraryList.stream()
.anyMatch(library -> library.getLevel1Type().equals(LibraryLevel1TypeEnum.MODELS.getRealName()));
if (isExist) {
List<Long> libarayIds = page.getRecords().stream()
List<Long> libraryIds = libraryList.stream()
.filter(library -> library.getLevel1Type().equals(LibraryLevel1TypeEnum.MODELS.getRealName()))
.map(Library::getId)
.collect(Collectors.toList());
List<LibraryModelPointVO> libraryModelPointVOS = libraryModelPointService.selectByLibraryIds(libarayIds);
List<LibraryModelPointVO> libraryModelPointVOS = libraryModelPointService.selectByLibraryIds(libraryIds);
if (!CollectionUtils.isEmpty(libraryModelPointVOS)) {
map = libraryModelPointVOS.stream().collect(Collectors.toMap(LibraryModelPointVO::getRelationId, v -> v));
map = libraryModelPointVOS.stream()
.collect(Collectors.toMap(LibraryModelPointVO::getRelationId, v -> v));
}
}
Map<Long, LibraryModelPointVO> finalMap = map;
IPage<QueryLibraryPageVO> convert = page.convert((Function<Library, QueryLibraryPageVO>) library -> {
QueryLibraryPageVO libraryPageVO = CopyUtil.copyObject(library, QueryLibraryPageVO.class);
libraryPageVO.setDesignType(DesignTypeEnum.LIBRARY.getRealName());
libraryPageVO.setMinIOPath(library.getUrl());
libraryPageVO.setUrl(minioUtil.getPreSignedUrl(library.getUrl(), 24 * 60));
if (finalMap != null && finalMap.containsKey(library.getId())) {
libraryPageVO.setLibraryModelPoint(finalMap.get(library.getId()));
}
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;
});
return PageBaseResponse.success(convert);
// 3. 转换 Library 为 QueryLibraryPageVO并通过 minioUtil 过滤掉不存在的 URL
List<QueryLibraryPageVO> convertedList = libraryList.stream()
.map(library -> {
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(url, 24 * 60));
if (finalMap != null && finalMap.containsKey(library.getId())) {
libraryPageVO.setLibraryModelPoint(finalMap.get(library.getId()));
}
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 {
// 如果对应的 MinIO 文件不存在,则返回 null后续过滤掉
return null;
}
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
// 4. 手动分页
int total = convertedList.size();
int currentPage = query.getPage(); // 当前页码从1开始
int pageSize = query.getSize(); // 每页大小
int fromIndex = (currentPage - 1) * pageSize;
int toIndex = Math.min(total, currentPage * pageSize);
List<QueryLibraryPageVO> pageList = new ArrayList<>();
if (fromIndex < total) {
pageList = convertedList.subList(fromIndex, toIndex);
}
// 5. 构造 IPage 对象(使用 MyBatis-Plus 的 Page 实现)
IPage<QueryLibraryPageVO> pageResult = new Page<>(currentPage, pageSize, total);
pageResult.setRecords(pageList);
// 6. 返回结果
return PageBaseResponse.success(pageResult);
}
@Override