Skip to content

Commit

Permalink
Merge pull request #48 from YNNiu623/master
Browse files Browse the repository at this point in the history
[fix]修复了多租户读取和修改用户信息的bug
  • Loading branch information
nnhy authored Oct 27, 2024
2 parents 5b90edb + 610fab6 commit 6c86acb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion XCode/Attributes/MapAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,14 @@ public virtual IDictionary<Object, String> 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
Expand Down
5 changes: 5 additions & 0 deletions XCode/Model/WhereBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 6c86acb

Please sign in to comment.