This commit is contained in:
sxu 2025-04-29 11:02:22 +08:00
parent 466f2454e8
commit 75c74bedcb
3 changed files with 22 additions and 3 deletions

View File

@ -20,6 +20,8 @@ public interface AllocStallMapper {
*/ */
public AllocStall selectAllocStallByStallId(Long stallId); public AllocStall selectAllocStallByStallId(Long stallId);
public AllocStall selectAllocStallByStallName(AllocStall allocStall);
/** /**
* 查询档口信息列表 * 查询档口信息列表
* *

View File

@ -1,7 +1,8 @@
package com.bonus.canteen.core.alloc.service.impl; package com.bonus.canteen.core.alloc.service.impl;
import java.util.List; 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.AllocStall;
import com.bonus.canteen.core.alloc.domain.AllocStallMealtime; import com.bonus.canteen.core.alloc.domain.AllocStallMealtime;
import com.bonus.canteen.core.alloc.mapper.AllocStallMapper; import com.bonus.canteen.core.alloc.mapper.AllocStallMapper;
@ -60,6 +61,10 @@ public class AllocStallServiceImpl implements IAllocStallService {
allocStall.setCreateTime(DateUtils.getNowDate()); allocStall.setCreateTime(DateUtils.getNowDate());
allocStall.setIfReserve(BnsConstants.COMMON_YES); //默认开启预订餐 allocStall.setIfReserve(BnsConstants.COMMON_YES); //默认开启预订餐
try { try {
AllocStall checkResult = allocStallMapper.selectAllocStallByStallName(allocStall);
if (Objects.nonNull(checkResult)) {
throw new ServiceException("档口名称已存在");
}
int stallCount = allocStallMapper.insertAllocStall(allocStall); int stallCount = allocStallMapper.insertAllocStall(allocStall);
if (stallCount > 0 && !CollectionUtils.isEmpty(allocStall.getAllocStallMealtimeList())) { if (stallCount > 0 && !CollectionUtils.isEmpty(allocStall.getAllocStallMealtimeList())) {
allocStallMapper.deleteMealtimeByStallId(allocStall.getStallId()); allocStallMapper.deleteMealtimeByStallId(allocStall.getStallId());
@ -69,7 +74,7 @@ public class AllocStallServiceImpl implements IAllocStallService {
} }
return stallCount; return stallCount;
} catch (Exception e) { } 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) { public int updateAllocStall(AllocStall allocStall) {
allocStall.setUpdateTime(DateUtils.getNowDate()); allocStall.setUpdateTime(DateUtils.getNowDate());
try { try {
List<AllocStall> allStallList = allocStallMapper.selectAllocStallList(new AllocStall());
List<String> 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); int stallCount = allocStallMapper.updateAllocStall(allocStall);
if (stallCount > 0 && !CollectionUtils.isEmpty(allocStall.getAllocStallMealtimeList())) { if (stallCount > 0 && !CollectionUtils.isEmpty(allocStall.getAllocStallMealtimeList())) {
allocStallMapper.deleteMealtimeByStallId(allocStall.getStallId()); allocStallMapper.deleteMealtimeByStallId(allocStall.getStallId());
@ -90,7 +102,7 @@ public class AllocStallServiceImpl implements IAllocStallService {
} }
return stallCount; return stallCount;
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("错误信息描述"); throw new ServiceException("更新档口异常," + e.getMessage());
} }
} }

View File

@ -79,6 +79,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where ast.stall_id = #{stallId} where ast.stall_id = #{stallId}
</select> </select>
<select id="selectAllocStallByStallName" parameterType="com.bonus.canteen.core.alloc.domain.AllocStall" resultMap="AllocStallResult">
<include refid="selectAllocStallVo"/>
where ast.stall_name = #{stallName} and ac.canteen_id = #{canteenId}
</select>
<insert id="insertAllocStall" parameterType="com.bonus.canteen.core.alloc.domain.AllocStall" useGeneratedKeys="true" keyProperty="stallId"> <insert id="insertAllocStall" parameterType="com.bonus.canteen.core.alloc.domain.AllocStall" useGeneratedKeys="true" keyProperty="stallId">
insert into alloc_stall insert into alloc_stall
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">