From e3517ec21c9e255ddd36b43da6abc414f9c023aa 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: Fri, 2 Jun 2023 20:08:47 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=A0=B9=E6=8D=AE=E9=83=A8=E9=97=A8=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZR.Service/System/SysUserService.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ZR.Service/System/SysUserService.cs b/ZR.Service/System/SysUserService.cs index 959bfbe..c8d8175 100644 --- a/ZR.Service/System/SysUserService.cs +++ b/ZR.Service/System/SysUserService.cs @@ -51,15 +51,9 @@ namespace ZR.Service if (user.DeptId != 0) { - List depts = Context.Queryable().ToList(); + var allChildDepts = Context.Queryable().ToChildList(it => it.ParentId, user.DeptId); - var newDepts = depts.FindAll(delegate (SysDept dept) - { - string[] parentDeptId = dept.Ancestors.Split(",", StringSplitOptions.RemoveEmptyEntries); - return parentDeptId.Contains(user.DeptId.ToString()); - }); - string[] deptArr = newDepts.Select(x => x.DeptId.ToString()).ToArray(); - exp.AndIF(user.DeptId != 0, u => u.DeptId == user.DeptId || deptArr.Contains(u.DeptId.ToString())); + exp.And(u => allChildDepts.Select(f => f.DeptId).ToList().Contains(u.DeptId)); } var query = Queryable() .LeftJoin((u, dept) => u.DeptId == dept.DeptId)