This commit is contained in:
wangjinlei
2024-05-08 16:59:49 +08:00
parent 9ff79cede2
commit 4db86fadde
3 changed files with 79 additions and 0 deletions

View File

@@ -51,6 +51,48 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
return flag;
}
@Override
public void bindProductAndBookLabel(String[] productIds, Integer labelId) {
for (String id:productIds){
//check
Integer integer = shopProductToBookLabelDao.selectCount(new LambdaQueryWrapper<ShopProductToBookLabel>().eq(ShopProductToBookLabel::getProductId, Integer.valueOf(id)).eq(ShopProductToBookLabel::getBookLabelId, labelId));
if(integer>0){
continue;
}
ShopProductToBookLabel shopProductToBookLabel = new ShopProductToBookLabel();
shopProductToBookLabel.setBookLabelId(labelId);
shopProductToBookLabel.setProductId(Integer.valueOf(id));
shopProductToBookLabelDao.insert(shopProductToBookLabel);
}
}
@Override
public void unbindProductAndBookLabel(Integer productId, Integer labelId) {
ShopProductToBookLabel shopProductToBookLabel = shopProductToBookLabelDao.selectOne(new LambdaQueryWrapper<ShopProductToBookLabel>().eq(ShopProductToBookLabel::getBookLabelId, labelId).eq(ShopProductToBookLabel::getProductId, productId));
shopProductToBookLabelDao.deleteById(shopProductToBookLabel);
}
@Override
public void bindProductAndBookMarket(String[] productIds, Integer marketId) {
for (String p:productIds){
Integer integer = shopProductToBookMarketDao.selectCount(new LambdaQueryWrapper<ShopProductToBookMarket>().eq(ShopProductToBookMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToBookMarket::getBookMarketId, marketId));
if(integer>0){
continue;
}
ShopProductToBookMarket shopProductToBookMarket = new ShopProductToBookMarket();
shopProductToBookMarket.setProductId(Integer.valueOf(p));
shopProductToBookMarket.setBookMarketId(marketId);
shopProductToBookMarketDao.insert(shopProductToBookMarket);
}
}
@Override
public void unbindProductAndBookMarket(int productId, int marketId) {
ShopProductToBookMarket shopProductToBookMarket = shopProductToBookMarketDao.selectOne(new LambdaQueryWrapper<ShopProductToBookMarket>().eq(ShopProductToBookMarket::getBookMarketId, marketId).eq(ShopProductToBookMarket::getProductId, productId));
shopProductToBookMarketDao.deleteById(shopProductToBookMarket);
}
@Override
public Map<String, Object> getProductToLabel(Integer productId) {
HashMap<String, Object> flag = new HashMap<>();