mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
check issue #37
This commit is contained in:
parent
96a9ee6bd2
commit
f6cf9e5ee0
@ -79,8 +79,8 @@
|
|||||||
<Compile Include="OrgRepository.cs" />
|
<Compile Include="OrgRepository.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ModuleRepository.cs" />
|
<Compile Include="ModuleRepository.cs" />
|
||||||
<Compile Include="ResourceRepository.cs" />
|
|
||||||
<Compile Include="RoleRepository.cs" />
|
<Compile Include="RoleRepository.cs" />
|
||||||
|
<Compile Include="ResourceRepository.cs" />
|
||||||
<Compile Include="CategoryRepository.cs" />
|
<Compile Include="CategoryRepository.cs" />
|
||||||
<Compile Include="StockRepository.cs" />
|
<Compile Include="StockRepository.cs" />
|
||||||
<Compile Include="UserRepository.cs" />
|
<Compile Include="UserRepository.cs" />
|
||||||
|
@ -1,57 +1,40 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using OpenAuth.Domain;
|
||||||
using System.Linq;
|
using OpenAuth.Domain.Interface;
|
||||||
using System.Text;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Linq;
|
||||||
using OpenAuth.Domain;
|
|
||||||
using OpenAuth.Domain.Interface;
|
namespace OpenAuth.Repository
|
||||||
|
{
|
||||||
namespace OpenAuth.Repository
|
public class ResourceRepository : BaseRepository<Resource>, IResourceRepository
|
||||||
{
|
{
|
||||||
public class RoleRepository :BaseRepository<Role>, IRoleRepository
|
public IEnumerable<Resource> LoadInOrgs(int pageindex, int pagesize, params Guid[] orgIds)
|
||||||
{
|
{
|
||||||
public IEnumerable<Role> LoadRoles(int pageindex, int pagesize)
|
return LoadInOrgs(orgIds).OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
||||||
{
|
}
|
||||||
return Context.Roles.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
|
||||||
}
|
public void Delete(Guid id)
|
||||||
|
{
|
||||||
public int GetRoleCntInOrgs(params Guid[] orgIds)
|
Delete(u => u.Id == id);
|
||||||
{
|
}
|
||||||
return LoadInOrgs(orgIds).Count();
|
|
||||||
}
|
public IEnumerable<Resource> LoadInOrgs(params Guid[] orgId)
|
||||||
|
{
|
||||||
public IEnumerable<Role> LoadInOrgs(int pageindex, int pagesize, params Guid[] orgIds)
|
bool isZero = orgId.Length == 1 && orgId[0] == Guid.Empty; //判断传进来的是否为0
|
||||||
{
|
var result = from resource in Context.Resources.Where(u =>isZero
|
||||||
return LoadInOrgs(orgIds).OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
|| u.CascadeId != null &&orgId.Contains(u.CategoryId.Value)) select resource;
|
||||||
}
|
|
||||||
|
return result;
|
||||||
public void Delete(Guid id)
|
}
|
||||||
{
|
|
||||||
Delete(u =>u.Id == id);
|
public IEnumerable<Resource> LoadResources(int pageindex, int pagesize)
|
||||||
}
|
{
|
||||||
|
return Context.Resources.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
||||||
public IEnumerable<Role> LoadInOrgs(params Guid[] orgId)
|
}
|
||||||
{
|
|
||||||
var roles = Context.Relevances.Where(u => u.Key == "RoleOrg"
|
public int GetResourceCntInOrgs(params Guid[] orgIds)
|
||||||
&& orgId.Contains(u.SecondId)).Select(u => u.FirstId); //机构关联的角色
|
{
|
||||||
|
return LoadInOrgs(orgIds).Count();
|
||||||
var result = from role in Context.Roles.Where(u =>roles.Contains(u.Id)) select role;
|
}
|
||||||
|
}
|
||||||
return result;
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Role> LoadForUser(Guid userId)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (userId == Guid.Empty)
|
|
||||||
return Find(null);
|
|
||||||
|
|
||||||
var userRoleIds =
|
|
||||||
Context.Relevances.Where(u => u.FirstId == userId && u.Key == "UserRole")
|
|
||||||
.Select(u => u.SecondId).ToList();
|
|
||||||
|
|
||||||
return Find(u => userRoleIds.Contains(u.Id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +1,57 @@
|
|||||||
using System;
|
using System;
|
||||||
using OpenAuth.Domain;
|
|
||||||
using OpenAuth.Domain.Interface;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using OpenAuth.Domain;
|
||||||
|
using OpenAuth.Domain.Interface;
|
||||||
|
|
||||||
namespace OpenAuth.Repository
|
namespace OpenAuth.Repository
|
||||||
{
|
{
|
||||||
public class ResourceRepository : BaseRepository<Resource>, IResourceRepository
|
public class RoleRepository :BaseRepository<Role>, IRoleRepository
|
||||||
{
|
{
|
||||||
public IEnumerable<Resource> LoadInOrgs(int pageindex, int pagesize, params Guid[] orgIds)
|
public IEnumerable<Role> LoadRoles(int pageindex, int pagesize)
|
||||||
|
{
|
||||||
|
return Context.Roles.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetRoleCntInOrgs(params Guid[] orgIds)
|
||||||
|
{
|
||||||
|
return LoadInOrgs(orgIds).Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Role> LoadInOrgs(int pageindex, int pagesize, params Guid[] orgIds)
|
||||||
{
|
{
|
||||||
return LoadInOrgs(orgIds).OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
return LoadInOrgs(orgIds).OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete(Guid id)
|
public void Delete(Guid id)
|
||||||
{
|
{
|
||||||
Delete(u => u.Id == id);
|
Delete(u =>u.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Resource> LoadInOrgs(params Guid[] orgId)
|
public IEnumerable<Role> LoadInOrgs(params Guid[] orgId)
|
||||||
{
|
{
|
||||||
bool isZero = orgId.Length == 1 && orgId[0] == Guid.Empty; //判断传进来的是否为0
|
var roles = Context.Relevances.Where(u => u.Key == "RoleOrg"
|
||||||
var result = from resource in Context.Resources.Where(u =>isZero
|
&& orgId.Contains(u.SecondId)).Select(u => u.FirstId); //机构关联的角色
|
||||||
|| u.CascadeId != null &&orgId.Contains(u.CategoryId.Value)) select resource;
|
|
||||||
|
|
||||||
|
var result = from role in Context.Roles.Where(u =>roles.Contains(u.Id)) select role;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Resource> LoadResources(int pageindex, int pagesize)
|
public IEnumerable<Role> LoadForUser(Guid userId)
|
||||||
{
|
{
|
||||||
return Context.Resources.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetResourceCntInOrgs(params Guid[] orgIds)
|
if (userId == Guid.Empty)
|
||||||
{
|
return Find(null);
|
||||||
return LoadInOrgs(orgIds).Count();
|
|
||||||
|
var userRoleIds =
|
||||||
|
Context.Relevances.Where(u => u.FirstId == userId && u.Key == "UserRole")
|
||||||
|
.Select(u => u.SecondId).ToList();
|
||||||
|
|
||||||
|
return Find(u => userRoleIds.Contains(u.Id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user