2017-09-06 17:32:35 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web.Mvc;
|
2017-08-31 19:23:29 +08:00
|
|
|
|
using Infrastructure;
|
|
|
|
|
using OpenAuth.App.SSO;
|
2017-09-06 17:32:35 +08:00
|
|
|
|
using OpenAuth.App.ViewModel;
|
2017-08-31 19:23:29 +08:00
|
|
|
|
|
|
|
|
|
namespace OpenAuth.Mvc.Controllers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-10-12 16:38:46 +08:00
|
|
|
|
/// 获取登录用户的全部信息
|
2017-08-31 19:23:29 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
public class UserSessionController : BaseController
|
|
|
|
|
{
|
2017-09-06 17:32:35 +08:00
|
|
|
|
UserWithAccessedCtrls user = AuthUtil.GetCurrentUser();
|
2017-08-31 19:23:29 +08:00
|
|
|
|
/// <summary>
|
2017-10-12 16:38:46 +08:00
|
|
|
|
/// 获取登录用户可访问的所有模块,及模块的操作菜单
|
2017-08-31 19:23:29 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
public string GetModulesTree()
|
|
|
|
|
{
|
2017-10-11 16:19:34 +08:00
|
|
|
|
var moduleTree = user.Modules.GenerateTree(u => u.Id, u => u.ParentId);
|
|
|
|
|
return JsonHelper.Instance.Serialize(moduleTree);
|
2017-08-31 19:23:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 00:44:23 +08:00
|
|
|
|
public string GetModules(string pId)
|
|
|
|
|
{
|
|
|
|
|
var query = user.Modules;
|
|
|
|
|
if (!string.IsNullOrEmpty(pId))
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(u => u.ParentId == pId).ToList();
|
|
|
|
|
}
|
|
|
|
|
var data = new GridData
|
|
|
|
|
{
|
|
|
|
|
data = query,
|
|
|
|
|
count = query.Count(),
|
|
|
|
|
};
|
|
|
|
|
return JsonHelper.Instance.Serialize(data);
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-31 19:23:29 +08:00
|
|
|
|
/// <summary>
|
2017-10-12 16:38:46 +08:00
|
|
|
|
/// 获取登录用户可访问的所有部门
|
2017-08-31 19:23:29 +08:00
|
|
|
|
/// </summary>
|
2017-09-01 00:47:44 +08:00
|
|
|
|
public string GetOrgs()
|
2017-08-31 19:23:29 +08:00
|
|
|
|
{
|
2017-09-01 00:47:44 +08:00
|
|
|
|
return JsonHelper.Instance.Serialize(user.Orgs);
|
2017-08-31 19:23:29 +08:00
|
|
|
|
}
|
2017-09-06 17:32:35 +08:00
|
|
|
|
|
|
|
|
|
//获取当前页面菜单
|
|
|
|
|
public string GetButtonns()
|
|
|
|
|
{
|
|
|
|
|
var module = user.Modules.Single(u => u.Name.Contains(""));
|
|
|
|
|
return JsonHelper.Instance.Serialize(module.Elements);
|
|
|
|
|
}
|
2017-08-31 19:23:29 +08:00
|
|
|
|
}
|
|
|
|
|
}
|