mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-18 17:48:01 +08:00
完成用户模块/用户角色分配
This commit is contained in:
@@ -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">
|
||||
|
34
OpenAuth.Repository/UserRoleRepository.cs
Normal file
34
OpenAuth.Repository/UserRoleRepository.cs
Normal 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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user