Commit a6198896 by zxw

仓库重名检测

parent 55f78cab
......@@ -833,21 +833,30 @@ namespace JunmpPoliceStation.Controllers
}
string id = entity?.id ?? "";
string name = entity?.name ?? "";
string orgId = entity?.orgizationId ?? "";
if (entity == null)
{
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED);
}
else if (string.IsNullOrEmpty(entity.name ?? ""))
else if (string.IsNullOrEmpty(name))
{
return JsonManager.SimpleCustResponse($"Name is require");
}
else if (string.IsNullOrEmpty(entity.orgizationId ?? ""))
else if (string.IsNullOrEmpty(orgId))
{
return JsonManager.SimpleCustResponse($"OrgizationId is require");
}
else if (!string.IsNullOrEmpty(id))
{
//检查重名
var old = _unitOfWork.WarehouseRepository.Get(x => x.Name == name && x.OrgizationId == orgId && x.Id != id);
if (old != null)
{
return JsonManager.SimpleCustResponse($"仓库名称重复");
}
Expression<Func<BaseJpWarehouse, bool>> expression = t => t.Id.Equals(id);
BaseJpWarehouse updateObject = _unitOfWork.WarehouseRepository.Get(expression);
if (updateObject != null)
......@@ -855,7 +864,7 @@ namespace JunmpPoliceStation.Controllers
updateObject.Name = entity.name;
updateObject.Location = entity.location;
updateObject.LocationDetail = entity.locationDetail;
updateObject.OrgizationId = entity.orgizationId;
updateObject.OrgizationId = orgId;
updateObject.Phone = entity.phone;
updateObject.UpdateTime = System.DateTime.Now;
updateObject.UpdateUser = entity.updateUser;
......@@ -887,6 +896,12 @@ namespace JunmpPoliceStation.Controllers
}
else
{
//检查重名
var old = _unitOfWork.WarehouseRepository.Get(x => x.Name == name && x.OrgizationId == orgId);
if (old != null)
{
return JsonManager.SimpleCustResponse($"仓库名称重复");
}
//新增数据
BaseJpWarehouse addObject = new BaseJpWarehouse()
{
......@@ -895,7 +910,7 @@ namespace JunmpPoliceStation.Controllers
Name = entity.name,
Location = entity.location,
LocationDetail = entity.locationDetail,
OrgizationId = entity.orgizationId,
OrgizationId = orgId,
Phone = entity.phone,
CreateTime = System.DateTime.Now,
UpdateTime = System.DateTime.Now,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论