新版
This commit is contained in:
@@ -34,8 +34,12 @@ public class ShopProductController {
|
|||||||
private BuyOrderDetailService buyOrderDetailService;
|
private BuyOrderDetailService buyOrderDetailService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private BookService bookService;
|
private BookService bookService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShopProudictBookService shopProudictBookService;
|
private ShopProudictBookService shopProudictBookService;
|
||||||
|
@Autowired
|
||||||
|
private ShopProductToLabelService shopProductToLabelService;
|
||||||
|
@Autowired
|
||||||
|
private ShopProductLabelService shopProductLabelService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 精选商品 列表
|
* 精选商品 列表
|
||||||
@@ -275,11 +279,25 @@ public class ShopProductController {
|
|||||||
booklist.add(String.valueOf(bookId));
|
booklist.add(String.valueOf(bookId));
|
||||||
list.add(byId);
|
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.setBookidsimages(list);
|
||||||
shopProductEntity.setBookids(booklist);
|
shopProductEntity.setBookids(booklist);
|
||||||
shopProductEntity.setShoproudIds(bookIdlist);
|
shopProductEntity.setShoproudIds(bookIdlist);
|
||||||
return R.ok().put("shopProduct", shopProductEntity);
|
return R.ok().put("shopProduct", shopProductEntity).put("labels",labelList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据传入商品id反向查询图书id,然后查询图书id下包含的商品
|
* 根据传入商品id反向查询图书id,然后查询图书id下包含的商品
|
||||||
* @param productId
|
* @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);
|
shopProductService.updateById(shopProduct);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,6 +163,9 @@ public class ShopProductEntity implements Serializable {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private List<Object> shoproudIds;
|
private List<Object> shoproudIds;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<String> shoproudLabels;
|
||||||
|
|
||||||
|
|
||||||
// private Object bookidsimages;
|
// private Object bookidsimages;
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user