This commit is contained in:
wangjinlei
2024-05-08 17:52:21 +08:00
parent 4db86fadde
commit e749b9d9b2
3 changed files with 154 additions and 4 deletions

View File

@@ -80,6 +80,65 @@ public class ShopProductController {
return R.ok();
}
@RequestMapping("/bindProductAndSociologyLabel")
public R bindProductAndSociologyLabel(@RequestBody Map<String,String> 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<String,Integer> map){
shopProductService.unbindProductAndSociologyLabel(map.get("productId"),map.get("labelId"));
return R.ok();
}
@RequestMapping("/bindProductAndSociologyMarket")
public R bindProductAndSociologyMarket(@RequestBody Map<String,String> 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<String,Integer> map){
shopProductService.unbindProductAndSociologyMarket(map.get("productId"),map.get("marketId"));
return R.ok();
}
@RequestMapping("/bindProductAndMedicineLabel")
public R bindProductAndMedicineLabel(@RequestBody Map<String,String> 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<String,Integer> map){
shopProductService.unbindProductAndMedicineLabel(map.get("productId"),map.get("labelId"));
return R.ok();
}
@RequestMapping("/bindProductAndMedicineMarket")
public R bindProductAndMedicineMarket(@RequestBody Map<String,String> 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<String,Integer> map){
shopProductService.unbindProductAndMedicineMarket(map.get("productId"),map.get("marketId"));
return R.ok();
}
@RequestMapping("/getProductToLabel")
public R getProductToLabel(@RequestBody Map<String,Integer> map){

View File

@@ -18,4 +18,20 @@ public interface ShopProductService extends IService<ShopProduct> {
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);
}

View File

@@ -69,8 +69,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
@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);
shopProductToBookLabelDao.delete(new LambdaQueryWrapper<ShopProductToBookLabel>().eq(ShopProductToBookLabel::getBookLabelId, labelId).eq(ShopProductToBookLabel::getProductId, productId));
}
@Override
@@ -89,8 +88,84 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
@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);
shopProductToBookMarketDao.delete(new LambdaQueryWrapper<ShopProductToBookMarket>().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<ShopProductToSociologyLabel>().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<ShopProductToSociologyLabel>().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<ShopProductToSociologyMarket>().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<ShopProductToSociologyMarket>().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<ShopProductToMedicineLabel>().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<ShopProductToMedicineLabel>().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<ShopProductToMedicineMarket>().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<ShopProductToMedicineMarket>().eq(ShopProductToMedicineMarket::getMedicineMarketId,marketId).eq(ShopProductToMedicineMarket::getProductId,productId));
}
@Override