This commit is contained in:
wangjinlei
2023-09-20 17:37:10 +08:00
parent a57aef3c54
commit 1b3d3358a8
2 changed files with 48 additions and 3 deletions

View File

@@ -34,8 +34,12 @@ public class ShopProductController {
private BuyOrderDetailService buyOrderDetailService;
@Autowired
private BookService bookService;
@Autowired
private ShopProudictBookService shopProudictBookService;
@Autowired
private ShopProudictBookService shopProudictBookService;
@Autowired
private ShopProductToLabelService shopProductToLabelService;
@Autowired
private ShopProductLabelService shopProductLabelService;
/**
* 精选商品 列表
@@ -275,11 +279,25 @@ public class ShopProductController {
booklist.add(String.valueOf(bookId));
list.add(byId);
}
//添加获取标签逻辑
List<ShopProductToLabelEntity> shopProductToLabelEntities = shopProductToLabelService.getBaseMapper().selectList(new QueryWrapper<ShopProductToLabelEntity>()
.eq("product_id",productId).eq("del_flag",0));
List labelList = new ArrayList();
for (ShopProductToLabelEntity sp : shopProductToLabelEntities){
labelList.add(sp.getSplId());
}
shopProductEntity.setBookidsimages(list);
shopProductEntity.setBookids(booklist);
shopProductEntity.setShoproudIds(bookIdlist);
return R.ok().put("shopProduct", shopProductEntity);
return R.ok().put("shopProduct", shopProductEntity).put("labels",labelList);
}
/**
* 根据传入商品id反向查询图书id然后查询图书id下包含的商品
* @param productId
@@ -380,6 +398,30 @@ public class ShopProductController {
}
}
//对于标签的增和删
List<ShopProductToLabelEntity> shopProductToLabelEntities_now = shopProductToLabelService.getBaseMapper().selectList(new QueryWrapper<ShopProductToLabelEntity>()
.eq("product_id", productId));
List<String> m_spl_ids = shopProduct.getShoproudLabels();
//删除
for (ShopProductToLabelEntity sn:shopProductToLabelEntities_now){
if(!m_spl_ids.contains(sn.getSplId())){
shopProductToLabelService.removeById(sn.getPtlId());
}
}
//添加
for (String m:m_spl_ids){
Integer spl_id = Integer.valueOf(m);
ShopProductToLabelEntity byId = shopProductToLabelService.getBaseMapper().selectOne(new QueryWrapper<ShopProductToLabelEntity>()
.eq("spl_id",spl_id).eq("product_id",productId));
if(byId==null){
ShopProductToLabelEntity shopProductToLabelEntity = new ShopProductToLabelEntity();
shopProductToLabelEntity.setProductId(productId);
shopProductToLabelEntity.setSplId(spl_id);
shopProductToLabelService.save(shopProductToLabelEntity);
}
}
shopProductService.updateById(shopProduct);
return R.ok();
}

View File

@@ -163,6 +163,9 @@ public class ShopProductEntity implements Serializable {
@TableField(exist = false)
private List<Object> shoproudIds;
@TableField(exist = false)
private List<String> shoproudLabels;
// private Object bookidsimages;
//