食堂含档口不能删

This commit is contained in:
sxu 2025-05-05 11:22:18 +08:00
parent 1050a759d4
commit 4873c9107b
3 changed files with 18 additions and 0 deletions

View File

@ -62,6 +62,8 @@ public interface AllocStallMapper {
*/
public int deleteAllocStallByStallIds(Long[] stallIds);
public int selectAllocStallCountByCanteenIds(Long[] canteenIds);
public int deleteMealtimeByStallId(Long stallId);
public List<AllocStallMealtime> selectMealtimeByStallId(Long stallId);

View File

@ -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);
}

View File

@ -191,6 +191,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<select id="selectAllocStallCountByCanteenIds" resultType="Integer">
select count(1)
from alloc_stall
where canteen_id in
<foreach item="canteenId" collection="array" open="(" separator="," close=")">
#{canteenId}
</foreach>
</select>
<delete id="deleteMealtimeByStallId" parameterType="Long">
delete from alloc_stall_mealtime where stall_id = #{stallId}
</delete>