商品详情页面 1.0
parent
abd068cfb0
commit
51ba9f2877
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -33,4 +34,12 @@ public class TemplateAttributeModel extends BaseEntity {
|
|||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
public static TemplateAttributeModel attributeInfoBuild(AttributeInfo attributeInfo){
|
||||
return TemplateAttributeModel.builder()
|
||||
.id(attributeInfo.getId())
|
||||
.name(attributeInfo.getName())
|
||||
.code(attributeInfo.getCode())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ private List<CategoryInfo> categoryInfoList;
|
|||
*/
|
||||
private ProjectInfo projectInfo;
|
||||
/**
|
||||
* 品类信息
|
||||
* 品牌信息
|
||||
*/
|
||||
private BrandInfo brandInfo;
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ public class ProjectInfoServiceImpl extends ServiceImpl<ProjectInfoMapper, Proje
|
|||
private AttributeInfoService attributeInfoService;
|
||||
@Autowired
|
||||
private BrandInfoService brandInfoService;
|
||||
|
||||
/**
|
||||
* 查询商品信息列表
|
||||
*
|
||||
|
@ -236,16 +237,57 @@ private AsBrandProjectService asBrandProjectService;
|
|||
}}).stream()
|
||||
.map(RuleAttrAddModel::infoBuild).toList();
|
||||
CategoryCommonElementResp templateAttribute = this.categoryInfoService.getTemplateAttributeByCateGoryId(projectInfo.getType());
|
||||
List<TemplateAttributeGroupModel> templateAttributeGroupList = templateAttribute.getTemplateAttributeGroupList();
|
||||
ArrayList<TemplateAttributeModel> templateAttributeList = new ArrayList<>() {{
|
||||
addAll(templateAttribute.getTemplateAttributeList());
|
||||
}};
|
||||
//属性组和商品属性的id
|
||||
ArrayList<Long> notInAttributeIdList = new ArrayList<>();
|
||||
List<Long> attributeGroupIdList = templateAttributeGroupList.stream()
|
||||
.flatMap(templateAttributeGroupModel -> templateAttributeGroupModel.getAttributeList().stream())
|
||||
.map(TemplateAttributeModel::getId)
|
||||
.toList();
|
||||
List<Long> attributeIdList = templateAttributeList.stream()
|
||||
.map(TemplateAttributeModel::getId)
|
||||
.toList();
|
||||
if (!attributeGroupIdList.isEmpty()){
|
||||
notInAttributeIdList.addAll(attributeGroupIdList);
|
||||
}
|
||||
if (!attributeIdList.isEmpty()){
|
||||
notInAttributeIdList.addAll(attributeIdList);
|
||||
}
|
||||
|
||||
List<AsProductAttributeInfo> productAttributeList = this.asProductAttributeInfoService.list(
|
||||
new LambdaQueryWrapper<>() {{
|
||||
eq(AsProductAttributeInfo::getProductId, projectInfo.getId());
|
||||
notIn(AsProductAttributeInfo::getAttributeId, notInAttributeIdList);
|
||||
}}
|
||||
);
|
||||
|
||||
List<TemplateAttributeModel> projectAttributeList = new ArrayList<>();
|
||||
if (!projectAttributeList.isEmpty()){
|
||||
List<Long> attrIdList = productAttributeList.stream()
|
||||
.map(AsProductAttributeInfo::getAttributeId)
|
||||
.toList();
|
||||
projectAttributeList = attributeInfoService.list(new LambdaQueryWrapper<>(){{
|
||||
in(AttributeInfo::getId, attrIdList);
|
||||
}}).stream()
|
||||
.map(TemplateAttributeModel::attributeInfoBuild)
|
||||
.toList();
|
||||
}
|
||||
//把自由属性添加到商品属性的集合当中,进行合并
|
||||
if (!projectAttributeList.isEmpty()){
|
||||
templateAttributeList.addAll(projectAttributeList);
|
||||
}
|
||||
return ProjectDetailResp.builder()
|
||||
.projectInfo(projectInfo)
|
||||
.projectInfo(projectInfo)
|
||||
.brandInfo(brandInfo)
|
||||
.categoryInfoList(categoryInfoList)
|
||||
.projectSkuInfoList(projectSkuInfoList)
|
||||
.productAttributeInfoList(productAttributeInfoList)
|
||||
.ruleAttrAddModelList(ruleAttrModelList)
|
||||
.attributeInfoList(templateAttribute.getTemplateAttributeList())
|
||||
.attributeGroupList(templateAttribute.getTemplateAttributeGroupList())
|
||||
.attributeInfoList(templateAttributeList)
|
||||
.attributeGroupList(templateAttributeGroupList)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue