mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 18:22:11 +08:00
完成直接为用户分配模块
This commit is contained in:
@@ -71,6 +71,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ModuleRepository.cs" />
|
||||
<Compile Include="RoleRepository.cs" />
|
||||
<Compile Include="UserModuleRepository.cs" />
|
||||
<Compile Include="UserRepository.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
51
OpenAuth.Repository/UserModuleRepository.cs
Normal file
51
OpenAuth.Repository/UserModuleRepository.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : OpenAuth.Repository
|
||||
// Author : yubaolee
|
||||
// Created : 11-26-2015
|
||||
//
|
||||
// Last Modified By : yubaolee
|
||||
// Last Modified On : 11-26-2015
|
||||
// ***********************************************************************
|
||||
// <copyright file="UserModuleRepository.cs" company="www.cnblogs.com/yubaolee">
|
||||
// Copyright (c) www.cnblogs.com/yubaolee. All rights reserved.
|
||||
// </copyright>
|
||||
// <summary>用户菜单分配操作</summary>
|
||||
// ***********************************************************************
|
||||
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
|
||||
namespace OpenAuth.Repository
|
||||
{
|
||||
public class UserModuleRepository : BaseRepository<UserModule>, IUserModuleRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 删除指定用户关联的模块
|
||||
/// </summary>
|
||||
/// <param name="userIds">The user ids.</param>
|
||||
public void DeleteByUser(params int[] userIds)
|
||||
{
|
||||
Delete(u =>userIds.Contains(u.UserId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为指定的用户分配模块
|
||||
/// </summary>
|
||||
public void AddUserModule(int userId, params int[] moduleIds)
|
||||
{
|
||||
foreach (var moduleId in moduleIds)
|
||||
{
|
||||
Add(new UserModule
|
||||
{
|
||||
UserId = userId,
|
||||
ModuleId = moduleId,
|
||||
OperateTime = DateTime.Now
|
||||
});
|
||||
}
|
||||
Save();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user