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="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ModuleRepository.cs" />
|
||||
<Compile Include="ResourceRepository.cs" />
|
||||
<Compile Include="RoleRepository.cs" />
|
||||
<Compile Include="ResourceRepository.cs" />
|
||||
<Compile Include="CategoryRepository.cs" />
|
||||
<Compile Include="StockRepository.cs" />
|
||||
<Compile Include="UserRepository.cs" />
|
||||
|
@ -1,57 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
|
||||
namespace OpenAuth.Repository
|
||||
{
|
||||
public class RoleRepository :BaseRepository<Role>, IRoleRepository
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
public void Delete(Guid id)
|
||||
{
|
||||
Delete(u =>u.Id == id);
|
||||
}
|
||||
|
||||
public IEnumerable<Role> LoadInOrgs(params Guid[] orgId)
|
||||
{
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenAuth.Repository
|
||||
{
|
||||
public class ResourceRepository : BaseRepository<Resource>, IResourceRepository
|
||||
{
|
||||
public IEnumerable<Resource> LoadInOrgs(int pageindex, int pagesize, params Guid[] orgIds)
|
||||
{
|
||||
return LoadInOrgs(orgIds).OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
||||
}
|
||||
|
||||
public void Delete(Guid id)
|
||||
{
|
||||
Delete(u => u.Id == id);
|
||||
}
|
||||
|
||||
public IEnumerable<Resource> LoadInOrgs(params Guid[] orgId)
|
||||
{
|
||||
bool isZero = orgId.Length == 1 && orgId[0] == Guid.Empty; //判断传进来的是否为0
|
||||
var result = from resource in Context.Resources.Where(u =>isZero
|
||||
|| u.CascadeId != null &&orgId.Contains(u.CategoryId.Value)) select resource;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<Resource> LoadResources(int pageindex, int pagesize)
|
||||
{
|
||||
return Context.Resources.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
||||
}
|
||||
|
||||
public int GetResourceCntInOrgs(params Guid[] orgIds)
|
||||
{
|
||||
return LoadInOrgs(orgIds).Count();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +1,57 @@
|
||||
using System;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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 result = from resource in Context.Resources.Where(u =>isZero
|
||||
|| u.CascadeId != null &&orgId.Contains(u.CategoryId.Value)) select resource;
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return LoadInOrgs(orgIds).Count();
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user