From 75c74bedcb607dd3b5273ecfe5d3a2da2593ebc6 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Tue, 29 Apr 2025 11:02:22 +0800 Subject: [PATCH] bug 5806 --- .../core/alloc/mapper/AllocStallMapper.java | 2 ++ .../service/impl/AllocStallServiceImpl.java | 18 +++++++++++++++--- .../mapper/alloc/AllocStallMapper.xml | 5 +++++ 3 files changed, 22 insertions(+), 3 deletions(-) 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 88611f4..922d0b4 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 @@ -20,6 +20,8 @@ public interface AllocStallMapper { */ public AllocStall selectAllocStallByStallId(Long stallId); + public AllocStall selectAllocStallByStallName(AllocStall allocStall); + /** * 查询档口信息列表 * diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocStallServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocStallServiceImpl.java index cc78a85..2e1e9af 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocStallServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocStallServiceImpl.java @@ -1,7 +1,8 @@ package com.bonus.canteen.core.alloc.service.impl; import java.util.List; - +import java.util.Objects; +import java.util.stream.Collectors; import com.bonus.canteen.core.alloc.domain.AllocStall; import com.bonus.canteen.core.alloc.domain.AllocStallMealtime; import com.bonus.canteen.core.alloc.mapper.AllocStallMapper; @@ -60,6 +61,10 @@ public class AllocStallServiceImpl implements IAllocStallService { allocStall.setCreateTime(DateUtils.getNowDate()); allocStall.setIfReserve(BnsConstants.COMMON_YES); //默认开启预订餐 try { + AllocStall checkResult = allocStallMapper.selectAllocStallByStallName(allocStall); + if (Objects.nonNull(checkResult)) { + throw new ServiceException("档口名称已存在"); + } int stallCount = allocStallMapper.insertAllocStall(allocStall); if (stallCount > 0 && !CollectionUtils.isEmpty(allocStall.getAllocStallMealtimeList())) { allocStallMapper.deleteMealtimeByStallId(allocStall.getStallId()); @@ -69,7 +74,7 @@ public class AllocStallServiceImpl implements IAllocStallService { } return stallCount; } catch (Exception e) { - throw new ServiceException("错误信息描述"); + throw new ServiceException("新增档口异常," + e.getMessage()); } } @@ -83,6 +88,13 @@ public class AllocStallServiceImpl implements IAllocStallService { public int updateAllocStall(AllocStall allocStall) { allocStall.setUpdateTime(DateUtils.getNowDate()); try { + List allStallList = allocStallMapper.selectAllocStallList(new AllocStall()); + List otherStallNameList = allStallList.stream().filter(item -> !item.getStallId().equals(allocStall.getStallId())) + .filter(item -> item.getCanteenId().equals(allocStall.getCanteenId())) + .map(AllocStall::getStallName).collect(Collectors.toList()); + if (otherStallNameList.contains(allocStall.getStallName())) { + throw new ServiceException("档口名称已存在"); + } int stallCount = allocStallMapper.updateAllocStall(allocStall); if (stallCount > 0 && !CollectionUtils.isEmpty(allocStall.getAllocStallMealtimeList())) { allocStallMapper.deleteMealtimeByStallId(allocStall.getStallId()); @@ -90,7 +102,7 @@ public class AllocStallServiceImpl implements IAllocStallService { } return stallCount; } catch (Exception e) { - throw new ServiceException("错误信息描述"); + throw new ServiceException("更新档口异常," + e.getMessage()); } } 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 5700041..0c9da8d 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 @@ -78,6 +78,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where ast.stall_id = #{stallId} + + insert into alloc_stall