商品修改 商品分组
This commit is contained in:
@@ -43,6 +43,11 @@ public class ProductDTO implements Serializable {
|
||||
*/
|
||||
@NotNull(message = "商品分类不能为空", groups = DefaultGroup.class)
|
||||
private Long categoryId;
|
||||
/**
|
||||
* 商品分组
|
||||
*/
|
||||
private List<Long> proGroupIds;
|
||||
|
||||
/**
|
||||
* 商品分类名称
|
||||
*/
|
||||
|
||||
@@ -449,6 +449,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
List<ProdConsRelationDTO> consList = prodConsRelationService.selectListByProdId(dto.getId());
|
||||
dto.setConsList(consList);
|
||||
dto.setRelatedRecommendJson(getRelateProductList(dto.getRelatedRecommend()));
|
||||
dto.setProGroupIds(prodGroupRelationMapper.selectListByQueryAs(query().select(ProdGroupRelation::getProdGroupId)
|
||||
.eq(ProdGroupRelation::getProductId, dto.getId()), Long.class));
|
||||
return dto;
|
||||
}
|
||||
|
||||
@@ -478,6 +480,18 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
entity.setRelatedRecommend(dto.getRelatedRecommendStr());
|
||||
super.save(entity);
|
||||
dto.setId(entity.getId());
|
||||
List<Long> groupIds = dto.getProGroupIds();
|
||||
if (CollUtil.isNotEmpty(groupIds)) {
|
||||
List<ProdGroupRelation> prodGroupRelations = new ArrayList<>();
|
||||
for (Long groupId : groupIds) {
|
||||
ProdGroupRelation prodGroupRelation = new ProdGroupRelation();
|
||||
prodGroupRelation.setProductId(entity.getId());
|
||||
prodGroupRelation.setProdGroupId(groupId);
|
||||
prodGroupRelations.add(prodGroupRelation);
|
||||
}
|
||||
prodGroupRelationMapper.insertBatch(prodGroupRelations);
|
||||
}
|
||||
|
||||
List<ProdSkuDTO> skuList = dto.getSkuList();
|
||||
if (CollUtil.isNotEmpty(skuList)) {
|
||||
List<ProdSku> prodSkuList = new ArrayList<>();
|
||||
@@ -556,6 +570,19 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
List<Long> list = skuList.stream().map(ProdSkuDTO::getId).filter(Objects::nonNull).distinct().toList();
|
||||
skuIdList.removeAll(list);
|
||||
}
|
||||
List<Long> groupIds = dto.getProGroupIds();
|
||||
if (CollUtil.isNotEmpty(groupIds)) {
|
||||
prodGroupRelationMapper.deleteByQuery(query().eq(ProdGroupRelation::getProductId, entity.getId()));
|
||||
List<ProdGroupRelation> prodGroupRelations = new ArrayList<>();
|
||||
for (Long groupId : groupIds) {
|
||||
ProdGroupRelation prodGroupRelation = new ProdGroupRelation();
|
||||
prodGroupRelation.setProductId(entity.getId());
|
||||
prodGroupRelation.setProdGroupId(groupId);
|
||||
prodGroupRelations.add(prodGroupRelation);
|
||||
}
|
||||
prodGroupRelationMapper.insertBatch(prodGroupRelations);
|
||||
}
|
||||
|
||||
ProdConsBindDTO prodConsBindDTO = new ProdConsBindDTO();
|
||||
prodConsBindDTO.setId(dto.getId());
|
||||
prodConsBindDTO.setConsList(dto.getConsList());
|
||||
|
||||
Reference in New Issue
Block a user