From 63cc2de9b90b85dfa412cd459bf2a922c720bc64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Thu, 28 Apr 2022 20:21:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E9=97=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8F=AF=E4=BB=A5=E5=A4=9A=E4=B8=AA=E7=88=B6=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZR.Service/System/SysDeptService.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ZR.Service/System/SysDeptService.cs b/ZR.Service/System/SysDeptService.cs index 24a0cf1..5785b29 100644 --- a/ZR.Service/System/SysDeptService.cs +++ b/ZR.Service/System/SysDeptService.cs @@ -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); }