修改服务方式删除接口

This commit is contained in:
youxilong 2024-03-08 09:30:26 +08:00
parent 2b8385b1aa
commit d53f70fd82

View File

@ -294,11 +294,16 @@ public class ServiceWayContentServiceImpl implements IServiceWayContentService {
*/ */
@Override @Override
public int deleteServiceWayById(Long id) { public int deleteServiceWayById(Long id) {
// 判断该服务方式下是否是关联记录如果有则不能删除 // 判断该服务方式下是否有关联记录如果有且数量不为0则不能删除
List<ServiceWayContentAndNumVO> voList = serviceWayContentMapper.selectListNum(null, id); List<ServiceWayContentAndNumVO> 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("该服务方式下有服务内容,请先删除服务内容"); throw new ServiceException("该服务方式下有服务内容,请先删除服务内容");
} }
// 如果没有关联记录或数量为0则可以删除服务方式
return serviceWayContentMapper.deleteServiceWayById(id); return serviceWayContentMapper.deleteServiceWayById(id);
} }