diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/mapper/AllocStallMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/mapper/AllocStallMapper.java index 922d0b4..7a42ef1 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/mapper/AllocStallMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/mapper/AllocStallMapper.java @@ -62,6 +62,8 @@ public interface AllocStallMapper { */ public int deleteAllocStallByStallIds(Long[] stallIds); + public int selectAllocStallCountByCanteenIds(Long[] canteenIds); + public int deleteMealtimeByStallId(Long stallId); public List selectMealtimeByStallId(Long stallId); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocCanteenServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocCanteenServiceImpl.java index 40a912d..51dd96b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocCanteenServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocCanteenServiceImpl.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.bonus.canteen.core.alloc.domain.*; import com.bonus.canteen.core.alloc.mapper.AllocCanteenMapper; +import com.bonus.canteen.core.alloc.mapper.AllocStallMapper; import com.bonus.canteen.core.utils.BnsConstants; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; @@ -28,6 +29,8 @@ import com.bonus.canteen.core.alloc.service.IAllocCanteenService; public class AllocCanteenServiceImpl implements IAllocCanteenService { @Autowired private AllocCanteenMapper allocCanteenMapper; + @Autowired + private AllocStallMapper allocStallMapper; /** * 查询食堂信息 @@ -103,6 +106,10 @@ public class AllocCanteenServiceImpl implements IAllocCanteenService { */ @Override public int deleteAllocCanteenByCanteenIds(Long[] canteenIds) { + int count = allocStallMapper.selectAllocStallCountByCanteenIds(canteenIds); + if (count > 0) { + throw new ServiceException("食堂含有档口信息,不能删除"); + } return allocCanteenMapper.deleteAllocCanteenByCanteenIds(canteenIds); } 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 0c9da8d..15d181b 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 @@ -191,6 +191,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + delete from alloc_stall_mealtime where stall_id = #{stallId}