From 610fab6bf9eb13463830395f93a42bf14d3fb905 Mon Sep 17 00:00:00 2001 From: niu Date: Sat, 26 Oct 2024 14:14:25 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=A4=9A?= =?UTF-8?q?=E7=A7=9F=E6=88=B7=E8=AF=BB=E5=8F=96=E5=92=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XCode/Attributes/MapAttribute.cs | 8 +++++++- XCode/Model/WhereBuilder.cs | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/XCode/Attributes/MapAttribute.cs b/XCode/Attributes/MapAttribute.cs index 4c0f3cdda..5693fc83b 100644 --- a/XCode/Attributes/MapAttribute.cs +++ b/XCode/Attributes/MapAttribute.cs @@ -89,8 +89,14 @@ public virtual IDictionary GetDataSource() key = fi.Name; } + var where = new WhereExpression(); + if (Membership.TenantContext.CurrentId > 0 && fact.FieldNames.Contains("TenantId")) + { + where &= Membership.TenantUser._.TenantId == Membership.TenantContext.CurrentId; + } + // 数据较少时,从缓存读取 - var list = fact.Session.Count < 1000 ? fact.FindAllWithCache() : fact.FindAll("", null, null, 0, 100); + var list = fact.Session.Count < 1000 && Membership.TenantContext.CurrentId == 0 ? fact.FindAllWithCache() : fact.FindAll(where, null, null, 0, 100); //return list.Where(e => e[key] != null).ToDictionary(e => e[key], e => e[mst] + ""); return list.Where(e => e[key] != null).ToDictionary(e => e[key]!, e => e.ToString());//用ToString()可以显示更多信息 2023-08-11 diff --git a/XCode/Model/WhereBuilder.cs b/XCode/Model/WhereBuilder.cs index af23c82ea..62801ced8 100644 --- a/XCode/Model/WhereBuilder.cs +++ b/XCode/Model/WhereBuilder.cs @@ -176,6 +176,11 @@ public Boolean Eval(IEntity entity) if (ctx == null || ctx.TenantId != source.TenantId) return false; } + if (TenantContext.CurrentId > 0 && entity is User)//如果租户修改用户可以通过 + { + return true; + } + return EvalParse(Expression, entity); }