OpenAuth.Net/OpenAuth.App/ModuleManagerApp.cs

64 lines
1.9 KiB
C#
Raw Normal View History

using System;
using Infrastructure;
2015-11-21 23:56:39 +08:00
using OpenAuth.Domain;
using System.Collections.Generic;
using System.Web;
2016-07-08 18:51:48 +08:00
using OpenAuth.App.SSO;
using OpenAuth.Domain.Service;
2015-11-21 23:56:39 +08:00
namespace OpenAuth.App
{
public class ModuleManagerApp
{
private ModuleManService _moduleManService;
2015-11-21 23:56:39 +08:00
public ModuleManagerApp(ModuleManService moduleManService)
2015-11-21 23:56:39 +08:00
{
_moduleManService = moduleManService;
2015-11-21 23:56:39 +08:00
}
/// <summary>
2015-11-23 18:15:29 +08:00
/// 加载一个节点下面的所有
2015-11-21 23:56:39 +08:00
/// </summary>
public dynamic Load(Guid parentId, int pageindex, int pagesize)
2015-11-21 23:56:39 +08:00
{
return _moduleManService.Load(AuthUtil.GetUserName(), parentId, pageindex, pagesize);
2015-11-21 23:56:39 +08:00
}
public void Delete(Guid id)
2015-11-21 23:56:39 +08:00
{
_moduleManService.Delete(id);
2015-11-21 23:56:39 +08:00
}
2015-11-23 18:15:29 +08:00
public void AddOrUpdate(Module vm)
2015-11-21 23:56:39 +08:00
{
2015-11-23 18:15:29 +08:00
Module model = new Module();
vm.CopyTo(model); //copy一次防止成员为null的情况
_moduleManService.AddOrUpdate(model);
2015-11-21 23:56:39 +08:00
}
#region /
/// <summary>
/// 加载特定用户的模块
/// TODO:这里会加载用户及用户角色的所有模块,“为用户分配模块”功能会给人一种混乱的感觉,但可以接受
/// </summary>
/// <param name="userId">The user unique identifier.</param>
public List<Module> LoadForUser(Guid userId)
2015-11-30 00:12:42 +08:00
{
return _moduleManService.LoadForUser(userId);
}
/// <summary>
/// 加载特定角色的模块
/// </summary>
/// <param name="roleId">The role unique identifier.</param>
public List<Module> LoadForRole(Guid roleId)
{
return _moduleManService.LoadForRole(roleId);
}
#endregion /
2015-11-21 23:56:39 +08:00
}
}