提交 603b5d6a authored 作者: zjm's avatar zjm

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

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