提交 fcfd6060 编写于 作者: X xiyunfei

调整用户查询角色逻辑

上级 e267c132
using System.ComponentModel;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Security.Principal;
using System.Web.Script.Serialization;
......@@ -607,6 +607,16 @@ public partial class User : LogEntity<User>, IUser, IAuthUser, IIdentity
/// <returns></returns>
public virtual Int32[] GetRoleIDs()
{
var tenantId = (TenantContext.Current?.TenantId).ToInt(-1);
if (tenantId > 0)
{
var tuEntity = TenantUser.FindByTenantIdAndUserId(tenantId, ID);
var idlist = RoleIds.SplitAsInt().OrderBy(e => e).ToList();
if (tuEntity != null && tuEntity.RoleId > 0) idlist.Insert(0, tuEntity.RoleId);
return idlist.Distinct().ToArray();
}
var ids = RoleIds.SplitAsInt().OrderBy(e => e).ToList();
if (RoleID > 0) ids.Insert(0, RoleID);
......
using System.Runtime.Serialization;
using System.Runtime.Serialization;
using System.Web.Script.Serialization;
using System.Xml.Serialization;
using NewLife;
......@@ -113,7 +113,6 @@ public partial class TenantUser : Entity<TenantUser>
/// <returns>实体对象</returns>
public static TenantUser FindByTenantIdAndUserId(Int32 tenantId, Int32 userId)
{
// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.TenantId == tenantId && e.UserId == userId);
......@@ -150,6 +149,18 @@ public partial class TenantUser : Entity<TenantUser>
return FindAll(_.UserId == userId);
}
/// <summary>根据租户查询用户id</summary>
/// <param name="tenantId"></param>
/// <returns></returns>
public static IList<TenantUser> FindAllByTenantId(Int32 tenantId)
{
if (tenantId <= 0) return new List<TenantUser>();
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.TenantId == tenantId);
return FindAll(_.TenantId == tenantId);
}
#endregion
#region 高级查询
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册