From bb2d95709c6d9368f062978edc4ce983453a3e35 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Thu, 15 May 2025 10:10:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E8=B6=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/supermarket/mapper/SupermarketProductMapper.java | 2 ++ .../service/impl/SupermarketInfoServiceImpl.java | 8 ++++++++ .../mapper/supermarket/SupermarketProductMapper.xml | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/mapper/SupermarketProductMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/mapper/SupermarketProductMapper.java index 5fda026..4603f07 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/mapper/SupermarketProductMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/mapper/SupermarketProductMapper.java @@ -57,4 +57,6 @@ public interface SupermarketProductMapper { * @return 结果 */ public int deleteSupermarketProductByProductIds(Long[] productIds); + + public int getProductCountOfSupermarket(Long[] supermarketIds); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/service/impl/SupermarketInfoServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/service/impl/SupermarketInfoServiceImpl.java index cb72651..055c89c 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/service/impl/SupermarketInfoServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/service/impl/SupermarketInfoServiceImpl.java @@ -1,6 +1,8 @@ package com.bonus.canteen.core.supermarket.service.impl; import java.util.List; + +import com.bonus.canteen.core.supermarket.mapper.SupermarketProductMapper; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; import com.bonus.common.security.utils.SecurityUtils; @@ -20,6 +22,8 @@ import com.bonus.canteen.core.supermarket.service.ISupermarketInfoService; public class SupermarketInfoServiceImpl implements ISupermarketInfoService { @Autowired private SupermarketInfoMapper supermarketInfoMapper; + @Autowired + SupermarketProductMapper supermarketProductMapper; /** * 查询超市 @@ -85,6 +89,10 @@ public class SupermarketInfoServiceImpl implements ISupermarketInfoService { */ @Override public int deleteSupermarketInfoBySupermarketIds(Long[] supermarketIds) { + int count = supermarketProductMapper.getProductCountOfSupermarket(supermarketIds); + if (count > 0) { + throw new ServiceException("该超市含有商品,不能删除"); + } return supermarketInfoMapper.deleteSupermarketInfoBySupermarketIds(supermarketIds); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/supermarket/SupermarketProductMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/supermarket/SupermarketProductMapper.xml index fa4e16e..cb5349b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/supermarket/SupermarketProductMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/supermarket/SupermarketProductMapper.xml @@ -173,4 +173,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{productId} + + \ No newline at end of file