仓库重名报错

This commit is contained in:
sxu 2024-10-16 18:56:51 +08:00
parent bf79dbb4df
commit 18013a2e0f
2 changed files with 11 additions and 2 deletions

View File

@ -94,7 +94,11 @@ public class WhHouseInfoController extends BaseController {
@SysLog(title = "仓库管理", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增仓库管理") @SysLog(title = "仓库管理", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增仓库管理")
@PostMapping @PostMapping
public AjaxResult add(@RequestBody WhHouseInfo whHouseInfo) { public AjaxResult add(@RequestBody WhHouseInfo whHouseInfo) {
return toAjax(whHouseInfoService.insertWhHouseInfo(whHouseInfo)); try {
return toAjax(whHouseInfoService.insertWhHouseInfo(whHouseInfo));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
} }
/** /**

View File

@ -1,6 +1,7 @@
package com.bonus.material.warehouse.service.impl; package com.bonus.material.warehouse.service.impl;
import java.util.List; import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -53,7 +54,11 @@ public class WhHouseInfoServiceImpl implements IWhHouseInfoService
public int insertWhHouseInfo(WhHouseInfo whHouseInfo) public int insertWhHouseInfo(WhHouseInfo whHouseInfo)
{ {
whHouseInfo.setCreateTime(DateUtils.getNowDate()); whHouseInfo.setCreateTime(DateUtils.getNowDate());
return whHouseInfoMapper.insertWhHouseInfo(whHouseInfo); try {
return whHouseInfoMapper.insertWhHouseInfo(whHouseInfo);
} catch (Exception e) {
throw new ServiceException("数据库错误或仓库重名");
}
} }
/** /**