规格新增
parent
90ec9846a3
commit
0b98947165
|
@ -23,6 +23,10 @@ public class RuleInfoEditReq extends BaseEntity {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 规格名称 */
|
||||
@ApiModelProperty(name = "主键", value = "主键")
|
||||
private Integer id;
|
||||
|
||||
/** 规格名称 */
|
||||
@ApiModelProperty(name = "规格名称", value = "规格名称")
|
||||
private String name;
|
||||
|
@ -31,4 +35,7 @@ public class RuleInfoEditReq extends BaseEntity {
|
|||
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty(name = "规格备注", value = "规格备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
@RestController
|
||||
@RequestMapping("/attribute")
|
||||
public class AttributeInfoController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private AttributeInfoService attributeInfoService;
|
||||
|
||||
|
@ -83,7 +85,8 @@ public class AttributeInfoController extends BaseController {
|
|||
@PostMapping
|
||||
@ApiOperation("新增商品属性")
|
||||
public Result<String> add(@RequestBody AttributeInfoSaveReq attributeInfoSaveReq) {
|
||||
return toAjax(attributeInfoService.save(AttributeInfo.saveBuild(attributeInfoSaveReq)));
|
||||
AttributeInfo attributeInfo = AttributeInfo.saveBuild(attributeInfoSaveReq);
|
||||
return attributeInfoService.save(attributeInfo) ? success(attributeInfo.getId()) : error();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,10 +40,6 @@ public class AsAttributeGroupServiceImpl extends ServiceImpl<AsAttributeGroupMap
|
|||
queryWrapper.eq(AsAttributeGroup::getAttributeId, asAttributeGroup.getAttributeId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -299,8 +299,9 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
*/
|
||||
@Override
|
||||
public CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId) {
|
||||
ArrayList<Long> cateGoryIdList = new ArrayList<>();
|
||||
List<Long> cateGoryIdList = new ArrayList<>();
|
||||
getParentIdListByCateGoryId(cateGoryIdList, cateGoryId);
|
||||
// 取出和品类相关联的属性组关系 - 中间表
|
||||
LambdaQueryWrapper<AsCategoryAttributeGroup> asCategoryAttributeGroupLambdaQueryWrapper = new LambdaQueryWrapper<>(){{
|
||||
in(AsCategoryAttributeGroup::getCategoryId, cateGoryIdList);
|
||||
}};
|
||||
|
@ -309,50 +310,50 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
.map(asCategoryAttributeGroup -> TemplateAttributeGroupModel.attributeGroupBuild(
|
||||
attributeGroupService.getById(asCategoryAttributeGroup.getAttributeGroupId()),
|
||||
attributeGroupId -> {
|
||||
LambdaQueryWrapper<AsAttributeGroup> asAttributeGroupLambdaQueryWrapper = new LambdaQueryWrapper<>() {{
|
||||
LambdaQueryWrapper<AsAttributeGroup> asAttributeGroupQueryWrapper = new LambdaQueryWrapper<>() {{
|
||||
eq(AsAttributeGroup::getGroupId, asCategoryAttributeGroup.getAttributeGroupId());
|
||||
}};
|
||||
List<Long> attributeList = asAttributeGroupService.list(asAttributeGroupLambdaQueryWrapper).stream()
|
||||
List<Long> attributeIdList = asAttributeGroupService.list(asAttributeGroupQueryWrapper).stream()
|
||||
.map(AsAttributeGroup::getAttributeId)
|
||||
.toList();
|
||||
if (attributeList.isEmpty()) {
|
||||
if (attributeIdList.isEmpty()){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return attributeInfoService.listByIds(attributeList).stream()
|
||||
return attributeInfoService.listByIds(attributeIdList).stream()
|
||||
.map(AttributeInfo::buildTemplateModel)
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
))
|
||||
.filter(TemplateAttributeGroupModel::isEffective)
|
||||
.toList();
|
||||
// 查重集合
|
||||
Set<Long> attributeIdSet = new HashSet<>();
|
||||
// 获取组内所有的属性Id
|
||||
if (!attributeGroupModelList.isEmpty()){
|
||||
attributeIdSet.addAll(
|
||||
attributeGroupModelList.stream()
|
||||
.flatMap((Function<? super TemplateAttributeGroupModel,Stream<TemplateAttributeModel>>) templateAttributeGroupModel -> templateAttributeGroupModel.getAttributeList().stream())
|
||||
.flatMap((Function<TemplateAttributeGroupModel, Stream<TemplateAttributeModel>>) templateAttributeGroupModel -> templateAttributeGroupModel.getAttributeList().stream())
|
||||
.map(TemplateAttributeModel::getId)
|
||||
.toList()
|
||||
);
|
||||
}
|
||||
|
||||
List<TemplateAttributeModel> templateAttributeModelList = new ArrayList<>();
|
||||
LambdaQueryWrapper<AsCategoryAttribute> categoryAttributeLambdaQueryWrapper=new LambdaQueryWrapper<>();
|
||||
categoryAttributeLambdaQueryWrapper.in(AsCategoryAttribute::getCategoryId,cateGoryIdList);
|
||||
List<AsCategoryAttribute> asCategoryAttributeList=asCategoryAttributeService.list(categoryAttributeLambdaQueryWrapper);
|
||||
LambdaQueryWrapper<AsCategoryAttribute> categoryAttributeQueryWrapper = new LambdaQueryWrapper<>();
|
||||
categoryAttributeQueryWrapper.in(AsCategoryAttribute::getCategoryId, cateGoryIdList);
|
||||
List<AsCategoryAttribute> asCategoryAttributeList = asCategoryAttributeService.list(categoryAttributeQueryWrapper);
|
||||
if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()){
|
||||
List<Long> templateAttributeIdList = asCategoryAttributeList.stream()
|
||||
.map(AsCategoryAttribute::getAttributeId)
|
||||
.filter(templateAttributeId -> !attributeIdSet.contains(templateAttributeId))
|
||||
.toList();
|
||||
if (asCategoryAttributeList!=null && ! asCategoryAttributeList.isEmpty())
|
||||
asCategoryAttributeList.stream()
|
||||
.map(AsCategoryAttribute::getAttributeId)
|
||||
.filter(templateAttributeId -> !attributeIdSet.contains(templateAttributeId))
|
||||
.toList();
|
||||
templateAttributeModelList = attributeInfoService.listByIds(templateAttributeIdList).stream()
|
||||
.map(AttributeInfo::buildTemplateModel)
|
||||
.toList();
|
||||
}
|
||||
|
||||
List<TemplateAttributeModel> attributeModelList = new ArrayList<>();
|
||||
|
||||
if (!templateAttributeModelList.isEmpty()){
|
||||
attributeIdSet.addAll(
|
||||
templateAttributeModelList.stream().map(TemplateAttributeModel::getId).toList()
|
||||
|
@ -365,8 +366,8 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
|
||||
return CategoryCommonElementResp.builder()
|
||||
.templateAttributeGroupList(attributeGroupModelList)
|
||||
.templateAttributeList(templateAttributeModelList)
|
||||
.attributeList(attributeModelList)
|
||||
.build();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 122.51.111.225:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 122.51.111.225:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
Loading…
Reference in New Issue