公共属性 - 属性组

master
DongZeLiang 2024-03-06 15:09:08 +08:00
parent 79a7391d39
commit 29e536f837
1 changed files with 33 additions and 1 deletions

View File

@ -43,6 +43,9 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
@Autowired
private AsCategoryBrandService asCategoryBrandService;
@Autowired
private AsAttributeGroupService asAttributeGroupService;
@Autowired
private AttributeInfoService attributeInfoService;
@ -284,8 +287,37 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
*/
@Override
public CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId) {
List<TemplateAttributeGroupModel> attributeGroupModelList = new ArrayList<>();
// 取出和品类相关联的属性组关系 - 中间表
LambdaQueryWrapper<AsCategoryAttributeGroup> asCategoryAttributeGroupLambdaQueryWrapper = new LambdaQueryWrapper<>();
asCategoryAttributeGroupLambdaQueryWrapper.eq(AsCategoryAttributeGroup::getCategoryId, cateGoryId);
List<AsCategoryAttributeGroup> categoryAttributeGroupList = asCategoryAttributeGroupService.list(asCategoryAttributeGroupLambdaQueryWrapper);
// 根据中间表取出属性组 信息
for (AsCategoryAttributeGroup asCategoryAttributeGroup : categoryAttributeGroupList) {
AttributeGroup attributeGroup = attributeGroupService.getById(asCategoryAttributeGroup.getAttributeGroupId());
// 根据属性组信息 取出和属性组相关联的属性信息
LambdaQueryWrapper<AsAttributeGroup> asAttributeGroupQueryWrapper = new LambdaQueryWrapper<>();
asAttributeGroupQueryWrapper.eq(AsAttributeGroup::getGroupId, attributeGroup.getId());
List<AsAttributeGroup> asAttributeGroupList = asAttributeGroupService.list(asAttributeGroupQueryWrapper);
List<TemplateAttributeModel> 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<TemplateAttributeModel> templateAttributeModelList = new ArrayList<>();