bug 5806
This commit is contained in:
parent
466f2454e8
commit
75c74bedcb
|
|
@ -20,6 +20,8 @@ public interface AllocStallMapper {
|
|||
*/
|
||||
public AllocStall selectAllocStallByStallId(Long stallId);
|
||||
|
||||
public AllocStall selectAllocStallByStallName(AllocStall allocStall);
|
||||
|
||||
/**
|
||||
* 查询档口信息列表
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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<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);
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectAllocStallVo"/>
|
||||
where ast.stall_id = #{stallId}
|
||||
</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 into alloc_stall
|
||||
|
|
|
|||
Loading…
Reference in New Issue