2016-09-02 18:05:17 +08:00
|
|
|
|
using System;
|
|
|
|
|
using Infrastructure;
|
2015-11-21 23:56:39 +08:00
|
|
|
|
using OpenAuth.Domain;
|
|
|
|
|
using System.Collections.Generic;
|
2016-05-27 12:39:14 +08:00
|
|
|
|
using System.Web;
|
2016-07-08 18:51:48 +08:00
|
|
|
|
using OpenAuth.App.SSO;
|
2016-05-27 12:39:14 +08:00
|
|
|
|
using OpenAuth.Domain.Service;
|
2015-11-21 23:56:39 +08:00
|
|
|
|
|
|
|
|
|
namespace OpenAuth.App
|
|
|
|
|
{
|
|
|
|
|
public class ModuleManagerApp
|
|
|
|
|
{
|
2016-05-27 12:39:14 +08:00
|
|
|
|
private ModuleManService _moduleManService;
|
2015-11-21 23:56:39 +08:00
|
|
|
|
|
2016-05-27 12:39:14 +08:00
|
|
|
|
public ModuleManagerApp(ModuleManService moduleManService)
|
2015-11-21 23:56:39 +08:00
|
|
|
|
{
|
2016-05-27 12:39:14 +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>
|
2016-09-02 18:05:17 +08:00
|
|
|
|
public dynamic Load(Guid parentId, int pageindex, int pagesize)
|
2015-11-21 23:56:39 +08:00
|
|
|
|
{
|
2016-07-14 00:14:24 +08:00
|
|
|
|
return _moduleManService.Load(AuthUtil.GetUserName(), parentId, pageindex, pagesize);
|
2015-11-21 23:56:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-02 18:05:17 +08:00
|
|
|
|
public void Delete(Guid id)
|
2015-11-21 23:56:39 +08:00
|
|
|
|
{
|
2016-05-27 12:39:14 +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的情况
|
2016-05-27 12:39:14 +08:00
|
|
|
|
_moduleManService.AddOrUpdate(model);
|
2015-11-21 23:56:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-30 14:54:38 +08:00
|
|
|
|
#region 用户/角色分配模块
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载特定用户的模块
|
2015-12-07 15:22:01 +08:00
|
|
|
|
/// TODO:这里会加载用户及用户角色的所有模块,“为用户分配模块”功能会给人一种混乱的感觉,但可以接受
|
2015-11-30 14:54:38 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="userId">The user unique identifier.</param>
|
2016-09-02 18:05:17 +08:00
|
|
|
|
public List<Module> LoadForUser(Guid userId)
|
2015-11-30 00:12:42 +08:00
|
|
|
|
{
|
2016-05-27 12:39:14 +08:00
|
|
|
|
return _moduleManService.LoadForUser(userId);
|
2015-11-30 14:54:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载特定角色的模块
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="roleId">The role unique identifier.</param>
|
2016-09-02 18:05:17 +08:00
|
|
|
|
public List<Module> LoadForRole(Guid roleId)
|
2015-11-30 14:54:38 +08:00
|
|
|
|
{
|
2016-05-27 12:39:14 +08:00
|
|
|
|
return _moduleManService.LoadForRole(roleId);
|
2015-11-30 14:54:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion 用户/角色分配模块
|
|
|
|
|
|
2015-11-21 23:56:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|