From e749b9d9b265a815da0fb3482c6eed2f1c34e0d7 Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Wed, 8 May 2024 17:52:21 +0800 Subject: [PATCH] bug --- .../controller/ShopProductController.java | 59 +++++++++++++ .../master/service/ShopProductService.java | 16 ++++ .../service/impl/ShopProductServiceImpl.java | 83 ++++++++++++++++++- 3 files changed, 154 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/peanut/modules/master/controller/ShopProductController.java b/src/main/java/com/peanut/modules/master/controller/ShopProductController.java index ad8ae566..712fb2b1 100644 --- a/src/main/java/com/peanut/modules/master/controller/ShopProductController.java +++ b/src/main/java/com/peanut/modules/master/controller/ShopProductController.java @@ -80,6 +80,65 @@ public class ShopProductController { return R.ok(); } + @RequestMapping("/bindProductAndSociologyLabel") + public R bindProductAndSociologyLabel(@RequestBody Map map){ + String[] productIds = map.get("productId").split(","); + Integer labelId = Integer.valueOf(map.get("labelId")); + shopProductService.bindProductAndSociologyLabel(productIds,labelId); + return R.ok(); + } + + @RequestMapping("/unbindProductAndSociologyLabel") + public R unbindProductAndSociologyLabel(@RequestBody Map map){ + shopProductService.unbindProductAndSociologyLabel(map.get("productId"),map.get("labelId")); + return R.ok(); + } + + @RequestMapping("/bindProductAndSociologyMarket") + public R bindProductAndSociologyMarket(@RequestBody Map map){ + String[] productIds = map.get("productId").split(","); + Integer marketId = Integer.valueOf(map.get("marketId")); + shopProductService.bindProductAndSociologyMarket(productIds,marketId); + return R.ok(); + } + + @RequestMapping("/unbindProductAndSociologyMarket") + public R unbindProductAndSociologyMarket(@RequestBody Map map){ + shopProductService.unbindProductAndSociologyMarket(map.get("productId"),map.get("marketId")); + return R.ok(); + } + + @RequestMapping("/bindProductAndMedicineLabel") + public R bindProductAndMedicineLabel(@RequestBody Map map){ + String[] productIds = map.get("productId").split(","); + Integer labelId = Integer.valueOf(map.get("labelId")); + shopProductService.bindProductAndMedicineLabel(productIds,labelId); + return R.ok(); + } + + @RequestMapping("/unbindProductAndMedicineLabel") + public R unbindProductAndMedicineLabel(@RequestBody Map map){ + shopProductService.unbindProductAndMedicineLabel(map.get("productId"),map.get("labelId")); + return R.ok(); + } + + + @RequestMapping("/bindProductAndMedicineMarket") + public R bindProductAndMedicineMarket(@RequestBody Map map){ + String[] productIds = map.get("productId").split(","); + Integer marketId = Integer.valueOf(map.get("marketId")); + shopProductService.bindProductAndMedicineMarket(productIds,marketId); + return R.ok(); + } + + @RequestMapping("/unbindProductAndMedicineMarket") + public R unbindProductAndMedicineMarket(@RequestBody Map map){ + shopProductService.unbindProductAndMedicineMarket(map.get("productId"),map.get("marketId")); + return R.ok(); + } + + + @RequestMapping("/getProductToLabel") public R getProductToLabel(@RequestBody Map map){ diff --git a/src/main/java/com/peanut/modules/master/service/ShopProductService.java b/src/main/java/com/peanut/modules/master/service/ShopProductService.java index cd01614c..b517b6a8 100644 --- a/src/main/java/com/peanut/modules/master/service/ShopProductService.java +++ b/src/main/java/com/peanut/modules/master/service/ShopProductService.java @@ -18,4 +18,20 @@ public interface ShopProductService extends IService { void bindProductAndBookMarket(String[] productIds,Integer marketId); void unbindProductAndBookMarket(int productId,int marketId); + + void bindProductAndSociologyLabel(String[] productIds,Integer labelId); + + void unbindProductAndSociologyLabel(int productId,int labelId); + + void bindProductAndSociologyMarket(String[] productId,int marketId); + + void unbindProductAndSociologyMarket(int product,int marketId); + + void bindProductAndMedicineLabel(String[] productId,int labelId); + + void unbindProductAndMedicineLabel(int productId,int labelId); + + void bindProductAndMedicineMarket(String[] productId,int marketId); + + void unbindProductAndMedicineMarket(int productId,int marketId); } diff --git a/src/main/java/com/peanut/modules/master/service/impl/ShopProductServiceImpl.java b/src/main/java/com/peanut/modules/master/service/impl/ShopProductServiceImpl.java index 414aedd5..07013508 100644 --- a/src/main/java/com/peanut/modules/master/service/impl/ShopProductServiceImpl.java +++ b/src/main/java/com/peanut/modules/master/service/impl/ShopProductServiceImpl.java @@ -69,8 +69,7 @@ public class ShopProductServiceImpl extends ServiceImpl().eq(ShopProductToBookLabel::getBookLabelId, labelId).eq(ShopProductToBookLabel::getProductId, productId)); - shopProductToBookLabelDao.deleteById(shopProductToBookLabel); + shopProductToBookLabelDao.delete(new LambdaQueryWrapper().eq(ShopProductToBookLabel::getBookLabelId, labelId).eq(ShopProductToBookLabel::getProductId, productId)); } @Override @@ -89,8 +88,84 @@ public class ShopProductServiceImpl extends ServiceImpl().eq(ShopProductToBookMarket::getBookMarketId, marketId).eq(ShopProductToBookMarket::getProductId, productId)); - shopProductToBookMarketDao.deleteById(shopProductToBookMarket); + shopProductToBookMarketDao.delete(new LambdaQueryWrapper().eq(ShopProductToBookMarket::getBookMarketId, marketId).eq(ShopProductToBookMarket::getProductId, productId)); + } + + @Override + public void bindProductAndSociologyLabel(String[] productIds, Integer labelId) { + for (String p : productIds){ + Integer integer = shopProductToSociologyLabelDao.selectCount(new LambdaQueryWrapper().eq(ShopProductToSociologyLabel::getProductId, Integer.valueOf(p)).eq(ShopProductToSociologyLabel::getSociologyLabelId, labelId)); + if(integer>0){ + continue; + } + ShopProductToSociologyLabel shopProductToSociologyLabel = new ShopProductToSociologyLabel(); + shopProductToSociologyLabel.setProductId(Integer.valueOf(p)); + shopProductToSociologyLabel.setSociologyLabelId(labelId); + shopProductToSociologyLabelDao.insert(shopProductToSociologyLabel); + } + } + + @Override + public void unbindProductAndSociologyLabel(int productId, int labelId) { + shopProductToSociologyLabelDao.delete(new LambdaQueryWrapper().eq(ShopProductToSociologyLabel::getProductId, productId).eq(ShopProductToSociologyLabel::getSociologyLabelId, labelId)); + } + + @Override + public void bindProductAndSociologyMarket(String[] productId, int marketId) { + for (String p:productId){ + Integer integer = shopProductToSociologyMarketDao.selectCount(new LambdaQueryWrapper().eq(ShopProductToSociologyMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToSociologyMarket::getSociologyMarketId, marketId)); + if(integer>0){ + continue; + } + ShopProductToSociologyMarket shopProductToSociologyMarket = new ShopProductToSociologyMarket(); + shopProductToSociologyMarket.setProductId(Integer.valueOf(p)); + shopProductToSociologyMarket.setSociologyMarketId(marketId); + shopProductToSociologyMarketDao.insert(shopProductToSociologyMarket); + } + + } + + @Override + public void unbindProductAndSociologyMarket(int product, int marketId) { + shopProductToSociologyMarketDao.delete(new LambdaQueryWrapper().eq(ShopProductToSociologyMarket::getProductId,product).eq(ShopProductToSociologyMarket::getSociologyMarketId,marketId)); + } + + @Override + public void bindProductAndMedicineLabel(String[] productId, int labelId) { + for (String p : productId){ + Integer integer = shopProductToMedicineLabelDao.selectCount(new LambdaQueryWrapper().eq(ShopProductToMedicineLabel::getProductId, Integer.valueOf(p)).eq(ShopProductToMedicineLabel::getMedicineLabelId, labelId)); + if(integer>0){ + continue; + } + ShopProductToMedicineLabel shopProductToMedicineLabel = new ShopProductToMedicineLabel(); + shopProductToMedicineLabel.setProductId(Integer.valueOf(p)); + shopProductToMedicineLabel.setMedicineLabelId(labelId); + shopProductToMedicineLabelDao.insert(shopProductToMedicineLabel); + } + } + + @Override + public void unbindProductAndMedicineLabel(int productId, int labelId) { + shopProductToMedicineLabelDao.delete(new LambdaQueryWrapper().eq(ShopProductToMedicineLabel::getMedicineLabelId,labelId).eq(ShopProductToMedicineLabel::getProductId,productId)); + } + + @Override + public void bindProductAndMedicineMarket(String[] productId, int marketId) { + for (String p:productId){ + Integer integer = shopProductToMedicineMarketDao.selectCount(new LambdaQueryWrapper().eq(ShopProductToMedicineMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToMedicineMarket::getMedicineMarketId, marketId)); + if(integer>0){ + continue; + } + ShopProductToMedicineMarket shopProductToMedicineMarket = new ShopProductToMedicineMarket(); + shopProductToMedicineMarket.setProductId(Integer.valueOf(p)); + shopProductToMedicineMarket.setMedicineMarketId(marketId); + shopProductToMedicineMarketDao.insert(shopProductToMedicineMarket); + } + } + + @Override + public void unbindProductAndMedicineMarket(int productId, int marketId) { + shopProductToMedicineMarketDao.delete(new LambdaQueryWrapper().eq(ShopProductToMedicineMarket::getMedicineMarketId,marketId).eq(ShopProductToMedicineMarket::getProductId,productId)); } @Override