/api/project/getModuleContent速度优化

This commit is contained in:
litianxiang
2025-09-16 11:01:22 +08:00
parent 5d8bdf9ecc
commit 630dfe98a4

View File

@@ -26,6 +26,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -1830,19 +1831,31 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
ModuleChooseVO moduleChooseVO = new ModuleChooseVO();
moduleChooseVO.setProjectId(projectDTO.getId());
// UserLikeCollectionVO userLikeCollectionVO = new UserLikeCollectionVO();
LambdaQueryWrapper<Project> projectLambdaQueryWrapper = new LambdaQueryWrapper<>();
projectLambdaQueryWrapper.select(Project::getAccountId).eq(Project::getId, projectDTO.getId());
Project project = projectService.getOne(projectLambdaQueryWrapper);
LambdaQueryWrapper<CollectionElement> queryWrapper = new LambdaQueryWrapper<>();
// 判空处理
if (project != null && project.getAccountId() != null) {
queryWrapper.eq(CollectionElement::getAccountId, project.getAccountId());
}
queryWrapper.eq(CollectionElement::getProjectId, projectDTO.getId());
List<CollectionElement> allCollectionElements = collectionElementMapper.selectList(queryWrapper);
for (String module : projectDTO.getModuleList()) {
if (module.equals(Module.colorBoard.name())) {
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId());
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.COLOR_BOARD.getRealName());
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
List<CollectionElement> collectionElements = allCollectionElements.stream()
.filter(element -> CollectionLevel1TypeEnum.COLOR_BOARD.getRealName().equals(element.getLevel1Type()))
.collect(Collectors.toList());
moduleChooseVO.setColorBoard(collectionService.resolveColorBoard(collectionElements));
}else if (module.equals(Module.moodBoard.name())) {
MoodBoardModuleChooseVO moodBoardModuleChooseVO = new MoodBoardModuleChooseVO();
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId());
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MOOD_BOARD.getRealName());
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
List<CollectionElement> collectionElements = allCollectionElements.stream()
.filter(element -> CollectionLevel1TypeEnum.MOOD_BOARD.getRealName().equals(element.getLevel1Type()))
.collect(Collectors.toList());
List<CollectionElementVO> list = new ArrayList<>();
for (CollectionElement collectionElement : collectionElements) {
@@ -1872,10 +1885,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
moduleChooseVO.setMoodBoard(moodBoardModuleChooseVO);
}else if (module.equals(Module.printBoard.name())) {
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId());
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.PRINT_BOARD.getRealName());
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
List<CollectionElement> collectionElements = allCollectionElements.stream()
.filter(element -> CollectionLevel1TypeEnum.PRINT_BOARD.getRealName().equals(element.getLevel1Type()))
.collect(Collectors.toList());
List<CollectionElementVO> list = new ArrayList<>();
for (CollectionElement collectionElement : collectionElements) {
@@ -1894,10 +1906,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
moduleChooseVO.setPrintBoard(list);
}else if (module.equals(Module.sketchBoard.name())) {
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId());
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName());
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
List<CollectionElement> collectionElements = allCollectionElements.stream()
.filter(element -> CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName().equals(element.getLevel1Type()))
.collect(Collectors.toList());
List<CollectionElementVO> list = new ArrayList<>();
for (CollectionElement collectionElement : collectionElements) {
@@ -2180,10 +2191,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
}
}
}else if (module.equals(Module.mannequin.name())) {
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId());
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName());
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
List<CollectionElement> collectionElements = allCollectionElements.stream()
.filter(element -> CollectionLevel1TypeEnum.MODEL.getRealName().equals(element.getLevel1Type()))
.collect(Collectors.toList());
List<CollectionElementVO> list = new ArrayList<>();
if (CollectionUtil.isNotEmpty(collectionElements)) {
for (CollectionElement collectionElement : collectionElements) {