This commit is contained in:
sxu 2025-04-29 11:07:29 +08:00
parent 75c74bedcb
commit be09234259
3 changed files with 5 additions and 4 deletions

View File

@ -18,7 +18,7 @@ public interface AllocCanteenMapper {
*/
public AllocCanteen selectAllocCanteenByCanteenId(Long canteenId);
public AllocCanteen selectAllocCanteenByCanteenName(String canteenName);
public AllocCanteen selectAllocCanteenByCanteenName(AllocCanteen allocCanteen);
/**
* 查询食堂信息列表

View File

@ -62,7 +62,7 @@ public class AllocCanteenServiceImpl implements IAllocCanteenService {
allocCanteen.setCreateTime(DateUtils.getNowDate());
allocCanteen.setIfReserve(BnsConstants.COMMON_YES); //默认开启预订餐
try {
AllocCanteen checkResult = allocCanteenMapper.selectAllocCanteenByCanteenName(allocCanteen.getCanteenName());
AllocCanteen checkResult = allocCanteenMapper.selectAllocCanteenByCanteenName(allocCanteen);
if (Objects.nonNull(checkResult)) {
throw new ServiceException("食堂名称已存在");
}
@ -84,6 +84,7 @@ public class AllocCanteenServiceImpl implements IAllocCanteenService {
try {
List<AllocCanteen> allCanteenList = allocCanteenMapper.selectAllocCanteenList(new AllocCanteen());
List<String> otherCanteenNameList = allCanteenList.stream().filter(item -> !item.getCanteenId().equals(allocCanteen.getCanteenId()))
.filter(item -> item.getAreaId().equals(allocCanteen.getAreaId()))
.map(AllocCanteen::getCanteenName).collect(Collectors.toList());
if (otherCanteenNameList.contains(allocCanteen.getCanteenName())) {
throw new ServiceException("食堂名称已存在");

View File

@ -70,9 +70,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where ac.canteen_id = #{canteenId}
</select>
<select id="selectAllocCanteenByCanteenName" parameterType="String" resultMap="AllocCanteenResult">
<select id="selectAllocCanteenByCanteenName" parameterType="com.bonus.canteen.core.alloc.domain.AllocCanteen" resultMap="AllocCanteenResult">
<include refid="selectAllocCanteenVo"/>
where ac.canteen_name = #{canteenName}
where ac.canteen_name = #{canteenName} and ac.area_id = #{areaId}
</select>
<insert id="insertAllocCanteen" parameterType="com.bonus.canteen.core.alloc.domain.AllocCanteen" useGeneratedKeys="true" keyProperty="canteenId">