mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-11-08 10:24:44 +08:00
更改PDM文件
删除为用户分配可见机构(本身有机构功能) 删除为角色分配机构(本身有机构多对多功能)
This commit is contained in:
@@ -43,18 +43,6 @@ namespace OpenAuth.Repository.Models.Mapping
|
||||
.HasColumnName("CreateId")
|
||||
.HasMaxLength(64)
|
||||
.IsRequired();
|
||||
Property(t => t.OrgCascadeId)
|
||||
.HasColumnName("OrgCascadeId")
|
||||
.HasMaxLength(255)
|
||||
.IsRequired();
|
||||
Property(t => t.OrgName)
|
||||
.HasColumnName("OrgName")
|
||||
.HasMaxLength(255)
|
||||
.IsRequired();
|
||||
Property(t => t.OrgId)
|
||||
.HasColumnName("OrgId")
|
||||
.IsOptional();
|
||||
|
||||
// Relationships
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ namespace OpenAuth.Repository
|
||||
return Find();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载用户的所有机构
|
||||
/// </summary>
|
||||
public IEnumerable<Org> LoadByUser(Guid userId)
|
||||
{
|
||||
var result = from userorg in Context.Relevances
|
||||
@@ -25,6 +28,19 @@ namespace OpenAuth.Repository
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载角色的所有机构
|
||||
/// </summary>
|
||||
public IEnumerable<Org> LoadByRole(Guid roleId)
|
||||
{
|
||||
var result = from userorg in Context.Relevances
|
||||
join org in Context.Orgs on userorg.SecondId equals org.Id
|
||||
where userorg.FirstId == roleId && userorg.Key == "RoleOrg"
|
||||
select org;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<Org> GetSubOrgs(Guid orgId)
|
||||
{
|
||||
string cascadeId = "0.";
|
||||
|
||||
@@ -32,7 +32,10 @@ namespace OpenAuth.Repository
|
||||
|
||||
public IEnumerable<Role> LoadInOrgs(params Guid[] orgId)
|
||||
{
|
||||
var result = from role in Context.Roles.Where(u =>u.OrgId != null && orgId.Contains(u.OrgId.Value)) select role;
|
||||
var roles = Context.Relevances.Where(u => u.Key == "RoleOrg"
|
||||
&& orgId.Contains(u.SecondId)).Select(u => u.FirstId); //机构关联的角色
|
||||
|
||||
var result = from role in Context.Roles.Where(u =>roles.Contains(u.Id)) select role;
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user