feat(后台管理): 添加商品

添加规格默选中字段
master
wayn 4 years ago
parent dc5493c4e5
commit bfa5bbab07

@ -95,9 +95,15 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
save(goods);
goods.setGoodsSn(goods.getId().toString());
updateById(goods);
List<Boolean> defaultSelectList = new ArrayList<>();
for (GoodsSpecification specification : specifications) {
specification.setGoodsId(goods.getId());
specification.setCreateTime(new Date());
defaultSelectList.add(specification.getDefaultSelected());
}
// 判断启用默认选中的规格是否超过一个
if (defaultSelectList.size() > 1) {
return R.error("商品规格只能选择一个启用默认选中");
}
for (GoodsAttribute goodsAttribute : attributes) {
goodsAttribute.setGoodsId(goods.getId());

Loading…
Cancel
Save