提交 b9a6423e authored 作者: zjm's avatar zjm

fix(单位模块): 修改区域对象提示名字重复

修改区域对象提示名字重复
上级 a3cbaef1
...@@ -51,8 +51,17 @@ public class UnitStoreLocationServiceImpl implements UnitStoreLocationService { ...@@ -51,8 +51,17 @@ public class UnitStoreLocationServiceImpl implements UnitStoreLocationService {
@Override @Override
public UnitStoreLocation save(UnitStoreLocation unitStoreLocation) { public UnitStoreLocation save(UnitStoreLocation unitStoreLocation) {
if (unitStoreLocationDao.existsByStoreNameAndUnitId(unitStoreLocation.getStoreName(),unitStoreLocation.getUnitId())){ if (unitStoreLocation.getId()!=null) {
throw new ApiException(ResponseEntity.status(20020).body("区域名称重复")); UnitStoreLocation unitStoreLocationOld=unitStoreLocationDao.findById(unitStoreLocation.getId()).get();
if (!unitStoreLocationOld.getStoreName().equals(unitStoreLocation.getStoreName())) {
if (unitStoreLocationDao.existsByStoreNameAndUnitId(unitStoreLocation.getStoreName(), unitStoreLocation.getUnitId())) {
throw new ApiException(ResponseEntity.status(20020).body("区域名称重复"));
}
}
}else {
if (unitStoreLocationDao.existsByStoreNameAndUnitId(unitStoreLocation.getStoreName(), unitStoreLocation.getUnitId())) {
throw new ApiException(ResponseEntity.status(20020).body("区域名称重复"));
}
} }
return unitStoreLocationDao.save(unitStoreLocation); return unitStoreLocationDao.save(unitStoreLocation);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论