添加角色处理

This commit is contained in:
yubaolee
2015-11-19 21:49:39 +08:00
parent 6906e969ac
commit 119948ccb7
24 changed files with 1763 additions and 899 deletions

View File

@@ -20,7 +20,11 @@ namespace OpenAuth.Repository.Models.Mapping
.IsRequired()
.HasMaxLength(64);
this.Property(t => t.CreateOrgCascadeId)
this.Property(t => t.OrgCascadeId)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.OrgName)
.IsRequired()
.HasMaxLength(255);
@@ -32,8 +36,9 @@ namespace OpenAuth.Repository.Models.Mapping
this.Property(t => t.Type).HasColumnName("Type");
this.Property(t => t.CreateTime).HasColumnName("CreateTime");
this.Property(t => t.CreateId).HasColumnName("CreateId");
this.Property(t => t.CreateOrgId).HasColumnName("CreateOrgId");
this.Property(t => t.CreateOrgCascadeId).HasColumnName("CreateOrgCascadeId");
this.Property(t => t.OrgId).HasColumnName("OrgId");
this.Property(t => t.OrgCascadeId).HasColumnName("OrgCascadeId");
this.Property(t => t.OrgName).HasColumnName("OrgName");
}
}
}

View File

@@ -69,6 +69,7 @@
<Compile Include="Models\OpenAuthDBContext.cs" />
<Compile Include="OrgRepository.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RoleRepository.cs" />
<Compile Include="UserRepository.cs" />
</ItemGroup>
<ItemGroup>

View File

@@ -0,0 +1,41 @@
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.Name).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public int GetRoleCntInOrgs(params int[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public IEnumerable<Role> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds)
{
return LoadInOrgs(orgIds).OrderBy(u => u.Name).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public void Delete(int id)
{
Delete(u =>u.Id == id);
}
public IEnumerable<Role> LoadInOrgs(params int[] orgId)
{
var result = from role in Context.Roles.Where(u => orgId.Contains(u.OrgId)) select role;
return result;
}
}
}