本文主要是介绍五十九.修改SPU规格,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
AttrController添加如下接口:
@PostMapping("/update/{spuId}")public R updateSpuAttr(@PathVariable("spuId") Long spuId,@RequestBody List<ProductAttrValueEntity> entities) {productAttrValueService.updateSpuAttr(spuId, entities);return R.ok();}
ProductAttrValueService添加如下方法:
/*** 更新规格参数** @param spuId* @param entities*/void updateSpuAttr(Long spuId, List<ProductAttrValueEntity> entities);
ProductAttrValueServiceImpl添加以上方法的实现,如下:
@Transactional@Overridepublic void updateSpuAttr(Long spuId, List<ProductAttrValueEntity> entities) {//全增全删this.baseMapper.delete(new QueryWrapper<ProductAttrValueEntity>().eq("spu_id", spuId));List<ProductAttrValueEntity> collect = entities.stream().map(item -> {item.setSpuId(spuId);return item;}).collect(Collectors.toList());this.saveBatch(collect);}
测试效果:
原来是快速展示的选项,如下:
去掉快速选项,确认修改,如下:
重新进去看效果,如下:
可以发现快速展示属性修改成功了。
这篇关于五十九.修改SPU规格的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!