From 59f3687b4712430f74db8653859e286f5daa6f39 Mon Sep 17 00:00:00 2001 From: yaoxin <1752800946@qq.com> Date: Tue, 5 Mar 2024 21:10:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=93=81=E7=B1=BB=E6=B7=BB=E5=8A=A0=E5=8F=8A?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=88=B6=E7=B1=BB=E5=B1=9E=E6=80=A7,?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=BB=84,=E5=93=81=E7=89=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AttributeGroupController.java | 2 +- .../service/AsAttributeGroupService.java | 2 +- .../service/AttributeGroupService.java | 2 + .../impl/AsAttributeGroupServiceImpl.java | 16 +++-- .../impl/AsBrandProjectServiceImpl.java | 6 +- .../impl/AttributeGroupServiceImpl.java | 6 ++ .../service/impl/CategoryInfoServiceImpl.java | 65 +++++++++++++++++-- 7 files changed, 81 insertions(+), 18 deletions(-) diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/AttributeGroupController.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/AttributeGroupController.java index ebc4d9f..a38851d 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/AttributeGroupController.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/AttributeGroupController.java @@ -112,7 +112,7 @@ public class AttributeGroupController extends BaseController { @ApiOperation("删除属性组") @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4") public Result remove(@PathVariable List ids) { - System.out.println(); + attributeGroupService.deleteAsAttributeGroup(ids); return toAjax(attributeGroupService.removeBatchByIds(ids)); } } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsAttributeGroupService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsAttributeGroupService.java index e0377ea..86bf033 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsAttributeGroupService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsAttributeGroupService.java @@ -19,6 +19,6 @@ public interface AsAttributeGroupService extends IService { */ public List list(AsAttributeGroup asAttributeGroup); - void deleteAsAttributeGroup(List attributeId); + void deleteAsAttributeGroup(List groupId); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AttributeGroupService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AttributeGroupService.java index 455262a..a23cd25 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AttributeGroupService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AttributeGroupService.java @@ -41,4 +41,6 @@ public interface AttributeGroupService extends IService { public Boolean save(AttributeGroupSaveModel attributeGroupSaveModel); void updateAsAttributeGrop(AttributeGroupEditReq attributeGroupEditReq,Long groupId); + + void deleteAsAttributeGroup(List ids); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsAttributeGroupServiceImpl.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsAttributeGroupServiceImpl.java index 83ec3a4..965df85 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsAttributeGroupServiceImpl.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsAttributeGroupServiceImpl.java @@ -1,6 +1,7 @@ package com.muyu.product.service.impl; import java.util.List; +import java.util.stream.Collectors; import com.muyu.common.core.utils.ObjUtils; import lombok.extern.slf4j.Slf4j; @@ -44,15 +45,18 @@ public class AsAttributeGroupServiceImpl extends ServiceImpl attributeId) { - asAttributeGroupMapper.deleteAsAttributeGroup(attributeId); + public void deleteAsAttributeGroup(List groupId) { + List> lists = groupId.stream() + .map(id -> this.list(new AsAttributeGroup(null, id, null))) + .toList(); + List collect = lists.stream().flatMap(List::stream).collect(Collectors.toList()); + List longs = collect.stream() + .map(asAttributeGroup -> asAttributeGroup.getId()) + .toList(); + this.removeBatchByIds(longs); } } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsBrandProjectServiceImpl.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsBrandProjectServiceImpl.java index e5c906d..17a859f 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsBrandProjectServiceImpl.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsBrandProjectServiceImpl.java @@ -3,6 +3,7 @@ package com.muyu.product.service.impl; import java.util.List; import com.muyu.common.core.utils.ObjUtils; +import lombok.extern.log4j.Log4j2; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import com.muyu.product.mapper.AsBrandProjectMapper; @@ -19,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; */ @Slf4j @Service +@Log4j2 public class AsBrandProjectServiceImpl extends ServiceImpl implements AsBrandProjectService { /** @@ -40,10 +42,6 @@ public class AsBrandProjectServiceImpl extends ServiceImpl ids) { + asAttributeGroupService.deleteAsAttributeGroup(ids); + } } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/CategoryInfoServiceImpl.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/CategoryInfoServiceImpl.java index 6148c22..977db28 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/CategoryInfoServiceImpl.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/CategoryInfoServiceImpl.java @@ -39,7 +39,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl getAttributeGroupList(Long categoryId) { - return null; + ArrayList attributeGroups = new ArrayList<>(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(AsCategoryAttributeGroup::getCategoryId,categoryId); + List asCategoryAttributeGroups = asCategoryAttributeGroupService.list(queryWrapper); + if (asCategoryAttributeGroups != null && !asCategoryAttributeGroups.isEmpty()){ + List attributeGroupIdList = asCategoryAttributeGroups.stream() + .map(AsCategoryAttributeGroup::getAttributeGroupId) + .toList(); + attributeGroups.addAll(attributeGroupService.listByIds(attributeGroupIdList)); + } + CategoryInfo categoryInfo = this.getById(categoryId); + if (categoryInfo.getParentId() !=0){ + if (attributeGroups.isEmpty()){ + attributeGroups.addAll(getAttributeGroupList(categoryInfo.getParentId())); + }else{ + List attributeGroupList = getAttributeGroupList(categoryInfo.getParentId()); + for (AttributeGroup attributeGroup : attributeGroupList) { + if (!attributeGroups.contains(attributeGroup)){ + attributeGroups.add(attributeGroup); + } + } + } + } + return attributeGroups; } /** @@ -113,7 +136,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(AsCategoryAttribute::getCategoryId,categoryId); List asCategoryAttributeList = asCategoryAttributeService.list(queryWrapper); - if (asCategoryAttributeList != null && asCategoryAttributeList.isEmpty()){ + if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()){ List attributeIdList = asCategoryAttributeList.stream() .map(AsCategoryAttribute::getAttributeId) .toList(); @@ -122,10 +145,17 @@ public class CategoryInfoServiceImpl extends ServiceImpl attributeList = getAttributeInfoList(categoryInfo.getParentId()); + for (AttributeInfo attribute : attributeList) { + if (!attributeInfoList.contains(attribute)){ + attributeInfoList.add(attribute); + } + } } } - return null; + return attributeInfoList; } /** @@ -135,7 +165,30 @@ public class CategoryInfoServiceImpl extends ServiceImpl getBrandInfoList(Long categoryId) { - return null; + ArrayList brandInfos = new ArrayList<>(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(AsCategoryBrand::getCategoryId,categoryId); + List asCategoryBrands = asCategoryBrandService.list(queryWrapper); + if (asCategoryBrands != null && !asCategoryBrands.isEmpty()){ + List brandIdList = asCategoryBrands.stream() + .map(AsCategoryBrand::getBrandId) + .toList(); + brandInfos.addAll(brandInfoService.listByIds(brandIdList)); + } + CategoryInfo categoryInfo = this.getById(categoryId); + if (categoryInfo.getParentId() !=0){ + if (brandInfos.isEmpty()){ + brandInfos.addAll(getBrandInfoList(categoryInfo.getParentId())); + }else{ + List brandInfoList = getBrandInfoList(categoryInfo.getParentId()); + for (BrandInfo brandInfo : brandInfoList) { + if (!brandInfos.contains(brandInfo)){ + brandInfos.add(brandInfo); + } + } + } + } + return brandInfos; } @Override