From d53f70fd82dea8ee6365030b767daf4f201f5f46 Mon Sep 17 00:00:00 2001 From: youxilong Date: Fri, 8 Mar 2024 09:30:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=8D=E5=8A=A1=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E5=88=A0=E9=99=A4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ServiceWayContentServiceImpl.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/servicewaycontent/impl/ServiceWayContentServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/servicewaycontent/impl/ServiceWayContentServiceImpl.java index 463c3218..40db0773 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/servicewaycontent/impl/ServiceWayContentServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/servicewaycontent/impl/ServiceWayContentServiceImpl.java @@ -294,11 +294,16 @@ public class ServiceWayContentServiceImpl implements IServiceWayContentService { */ @Override public int deleteServiceWayById(Long id) { - // 判断该服务方式下是否是关联记录,如果有则不能删除 + // 判断该服务方式下是否有关联记录,如果有且数量不为0,则不能删除 List voList = serviceWayContentMapper.selectListNum(null, id); - if (voList.size() > 0) { + boolean hasAssociatedContent = voList.stream() + .anyMatch(vo -> vo.getServiceContentNum() != null && vo.getServiceContentNum() > 0); + + if (hasAssociatedContent) { throw new ServiceException("该服务方式下有服务内容,请先删除服务内容"); } + + // 如果没有关联记录或数量为0,则可以删除服务方式 return serviceWayContentMapper.deleteServiceWayById(id); }