diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/mapper/AllocCanteenMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/mapper/AllocCanteenMapper.java index 40ba2b6..daa92bc 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/mapper/AllocCanteenMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/mapper/AllocCanteenMapper.java @@ -59,4 +59,6 @@ public interface AllocCanteenMapper { * @return 结果 */ public int deleteAllocCanteenByCanteenIds(Long[] canteenIds); + + public int selectAllocCanteenCountByAreaIds(Long[] areaIds); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocAreaServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocAreaServiceImpl.java index ba220b8..4b147cc 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocAreaServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocAreaServiceImpl.java @@ -5,6 +5,8 @@ import java.util.Iterator; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; + +import com.bonus.canteen.core.alloc.mapper.AllocCanteenMapper; import com.bonus.canteen.core.common.domain.TreeSelect; import com.bonus.canteen.core.alloc.mapper.AllocAreaMapper; import com.bonus.common.core.exception.ServiceException; @@ -25,6 +27,8 @@ import com.bonus.canteen.core.alloc.service.IAllocAreaService; public class AllocAreaServiceImpl implements IAllocAreaService { @Autowired private AllocAreaMapper allocAreaMapper; + @Autowired + private AllocCanteenMapper allocCanteenMapper; @Override public List selectAreaTreeList(AllocArea area) { @@ -104,6 +108,10 @@ public class AllocAreaServiceImpl implements IAllocAreaService { */ @Override public int deleteAllocAreaByAreaIds(Long[] areaIds) { + int count = allocCanteenMapper.selectAllocCanteenCountByAreaIds(areaIds); + if (count > 0) { + throw new ServiceException("区域含有食堂信息,不能删除"); + } return allocAreaMapper.deleteAllocAreaByAreaIds(areaIds); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocCanteenMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocCanteenMapper.xml index 81b7277..4fb3f70 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocCanteenMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocCanteenMapper.xml @@ -172,4 +172,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{canteenId} + + diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocStallMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocStallMapper.xml index 15d181b..f32277d 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocStallMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocStallMapper.xml @@ -194,7 +194,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"