fix bug 6234

This commit is contained in:
sxu 2025-06-10 20:09:41 +08:00
parent aa035e3208
commit c870cd87bc
3 changed files with 21 additions and 1 deletions

View File

@ -28,6 +28,8 @@ public interface SupermarketInfoMapper {
*/ */
public List<SupermarketInfo> selectSupermarketInfoList(SupermarketInfo supermarketInfo); public List<SupermarketInfo> selectSupermarketInfoList(SupermarketInfo supermarketInfo);
public SupermarketInfo selectSupermarketInfoBySupermarketName(SupermarketInfo supermarketInfo);
/** /**
* 新增超市 * 新增超市
* *

View File

@ -1,8 +1,10 @@
package com.bonus.canteen.core.supermarket.service.impl; package com.bonus.canteen.core.supermarket.service.impl;
import java.util.List; import java.util.List;
import java.util.Objects;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.bonus.canteen.core.supermarket.mapper.SupermarketInfoMapper; import com.bonus.canteen.core.supermarket.mapper.SupermarketInfoMapper;
@ -51,8 +53,19 @@ public class SupermarketInfoServiceImpl implements ISupermarketInfoService {
@Override @Override
public int insertSupermarketInfo(SupermarketInfo supermarketInfo) { public int insertSupermarketInfo(SupermarketInfo supermarketInfo) {
supermarketInfo.setCreateTime(DateUtils.getNowDate()); supermarketInfo.setCreateTime(DateUtils.getNowDate());
supermarketInfo.setCreateBy(SecurityUtils.getUsername());
try { try {
return supermarketInfoMapper.insertSupermarketInfo(supermarketInfo); try {
SupermarketInfo checkResult = supermarketInfoMapper.selectSupermarketInfoBySupermarketName(supermarketInfo);
if (Objects.nonNull(checkResult)) {
throw new ServiceException("该区域超市名称已存在");
}
return supermarketInfoMapper.insertSupermarketInfo(supermarketInfo);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException(e.getMessage()); throw new ServiceException(e.getMessage());
} }

View File

@ -81,6 +81,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{areaId} #{areaId}
</foreach> </foreach>
</select> </select>
<select id="selectSupermarketInfoBySupermarketName" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketInfo" resultMap="SupermarketInfoResult">
<include refid="selectSupermarketInfoVo"/>
where si.supermarket_name = #{supermarketName} and si.area_id = #{areaId}
</select>
<insert id="insertSupermarketInfo" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketInfo" useGeneratedKeys="true" keyProperty="supermarketId"> <insert id="insertSupermarketInfo" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketInfo" useGeneratedKeys="true" keyProperty="supermarketId">
insert into supermarket_info insert into supermarket_info