修改部门添加可以多个父级

This commit is contained in:
不做码农 2022-04-28 20:21:56 +08:00
parent 2f132a33e1
commit 63cc2de9b9

View File

@ -71,12 +71,15 @@ namespace ZR.Service.System
{
SysDept info = DeptRepository.GetFirst(it => it.DeptId == dept.ParentId);
//如果父节点不为正常状态,则不允许新增子节点
if (!UserConstants.DEPT_NORMAL.Equals(info.Status))
if (info != null && !UserConstants.DEPT_NORMAL.Equals(info?.Status))
{
throw new CustomException("部门停用,不允许新增");
}
dept.Ancestors = info.Ancestors + "," + dept.ParentId;
dept.Ancestors = "";
if (info != null)
{
dept.Ancestors = info.Ancestors + "," + dept.ParentId;
}
return DeptRepository.Add(dept);
}