From 29e536f83705068c89cd99fb456807be28c2d023 Mon Sep 17 00:00:00 2001 From: DongZeLiang <2746733890@qq.com> Date: Wed, 6 Mar 2024 15:09:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=85=B1=E5=B1=9E=E6=80=A7=20-=20?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CategoryInfoServiceImpl.java | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) 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 6a72131..92e7d01 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 @@ -43,6 +43,9 @@ public class CategoryInfoServiceImpl extends ServiceImpl attributeGroupModelList = new ArrayList<>(); + // 取出和品类相关联的属性组关系 - 中间表 + LambdaQueryWrapper asCategoryAttributeGroupLambdaQueryWrapper = new LambdaQueryWrapper<>(); + asCategoryAttributeGroupLambdaQueryWrapper.eq(AsCategoryAttributeGroup::getCategoryId, cateGoryId); + List categoryAttributeGroupList = asCategoryAttributeGroupService.list(asCategoryAttributeGroupLambdaQueryWrapper); + + // 根据中间表取出属性组 信息 + for (AsCategoryAttributeGroup asCategoryAttributeGroup : categoryAttributeGroupList) { + AttributeGroup attributeGroup = attributeGroupService.getById(asCategoryAttributeGroup.getAttributeGroupId()); + // 根据属性组信息 取出和属性组相关联的属性信息 + LambdaQueryWrapper asAttributeGroupQueryWrapper = new LambdaQueryWrapper<>(); + asAttributeGroupQueryWrapper.eq(AsAttributeGroup::getGroupId, attributeGroup.getId()); + List asAttributeGroupList = asAttributeGroupService.list(asAttributeGroupQueryWrapper); + List attributeModelList = new ArrayList<>(); + for (AsAttributeGroup asAttributeGroup : asAttributeGroupList) { + AttributeInfo attributeInfo = attributeInfoService.getById(asAttributeGroup.getAttributeId()); + attributeModelList.add( + TemplateAttributeModel.builder() + .id(attributeInfo.getId()) + .code(attributeInfo.getCode()) + .name(attributeInfo.getName()) + .build() + ); + } + attributeGroupModelList.add( + TemplateAttributeGroupModel.builder() + .groupName(attributeGroup.getName()) + .attributeList(attributeModelList) + .build() + ); + } List templateAttributeModelList = new ArrayList<>();