完成用户模块/用户角色分配

This commit is contained in:
yubaolee
2015-11-30 00:12:42 +08:00
parent fda4186350
commit 92ead80909
19 changed files with 297 additions and 68 deletions

View File

@@ -73,6 +73,7 @@
<Compile Include="RoleRepository.cs" />
<Compile Include="UserModuleRepository.cs" />
<Compile Include="UserRepository.cs" />
<Compile Include="UserRoleRepository.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj">

View File

@@ -0,0 +1,34 @@
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 UserRoleRepository :BaseRepository<UserRole>, IUserRoleRepository
{
public void DeleteByUser(params int[] userIds)
{
Delete(u =>userIds.Contains(u.UserId));
}
public void AddUserRole(int userId, params int[] roleIds)
{
foreach (var roleid in roleIds)
{
Add(new UserRole
{
UserId = userId,
RoleId = roleid,
OperateTime = DateTime.Now
});
}
Save();
}
}
}