diff --git a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java index b96f0f7e..45946802 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java @@ -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 projectLambdaQueryWrapper = new LambdaQueryWrapper<>(); + projectLambdaQueryWrapper.select(Project::getAccountId).eq(Project::getId, projectDTO.getId()); + Project project = projectService.getOne(projectLambdaQueryWrapper); + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + // 判空处理 + if (project != null && project.getAccountId() != null) { + queryWrapper.eq(CollectionElement::getAccountId, project.getAccountId()); + } + queryWrapper.eq(CollectionElement::getProjectId, projectDTO.getId()); + + List allCollectionElements = collectionElementMapper.selectList(queryWrapper); + for (String module : projectDTO.getModuleList()) { if (module.equals(Module.colorBoard.name())) { - QueryWrapper qw = new QueryWrapper<>(); - qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId()); - qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.COLOR_BOARD.getRealName()); - List collectionElements = collectionElementMapper.selectList(qw); + List 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 qw = new QueryWrapper<>(); - qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId()); - qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MOOD_BOARD.getRealName()); - List collectionElements = collectionElementMapper.selectList(qw); + + List collectionElements = allCollectionElements.stream() + .filter(element -> CollectionLevel1TypeEnum.MOOD_BOARD.getRealName().equals(element.getLevel1Type())) + .collect(Collectors.toList()); List list = new ArrayList<>(); for (CollectionElement collectionElement : collectionElements) { @@ -1872,10 +1885,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl qw = new QueryWrapper<>(); - qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId()); - qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.PRINT_BOARD.getRealName()); - List collectionElements = collectionElementMapper.selectList(qw); + List collectionElements = allCollectionElements.stream() + .filter(element -> CollectionLevel1TypeEnum.PRINT_BOARD.getRealName().equals(element.getLevel1Type())) + .collect(Collectors.toList()); List list = new ArrayList<>(); for (CollectionElement collectionElement : collectionElements) { @@ -1894,10 +1906,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl qw = new QueryWrapper<>(); - qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId()); - qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()); - List collectionElements = collectionElementMapper.selectList(qw); + List collectionElements = allCollectionElements.stream() + .filter(element -> CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName().equals(element.getLevel1Type())) + .collect(Collectors.toList()); List list = new ArrayList<>(); for (CollectionElement collectionElement : collectionElements) { @@ -2180,10 +2191,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl qw = new QueryWrapper<>(); - qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId()); - qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName()); - List collectionElements = collectionElementMapper.selectList(qw); + List collectionElements = allCollectionElements.stream() + .filter(element -> CollectionLevel1TypeEnum.MODEL.getRealName().equals(element.getLevel1Type())) + .collect(Collectors.toList()); List list = new ArrayList<>(); if (CollectionUtil.isNotEmpty(collectionElements)) { for (CollectionElement collectionElement : collectionElements) {