OpenAuth.Net/OpenAuth.App/AuthorizeApp.cs

53 lines
1.7 KiB
C#
Raw Normal View History

2017-09-01 00:47:44 +08:00
using System.Linq;
using Infrastructure;
2017-11-30 17:47:41 +08:00
using OpenAuth.App.Response;
2017-11-29 20:49:14 +08:00
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;
2017-09-01 00:47:44 +08:00
namespace OpenAuth.App
{
/// <summary>
/// 加载用户所有可访问的资源/机构/模块
/// <para>李玉宝新增于2016-07-19 10:53:30</para>
/// </summary>
public class AuthorizeApp
{
2017-11-29 00:48:51 +08:00
public SystemAuthService AuthService { get; set; }
public AuthoriseService AuthoriseService { get; set; }
2017-09-01 00:47:44 +08:00
2017-11-29 00:48:51 +08:00
public IUnitWork _unitWork { get; set; }
public AuthoriseService Create(string loginuser)
2017-09-01 00:47:44 +08:00
{
2017-11-29 00:48:51 +08:00
if (loginuser == "System")
{
return AuthService;
}
else
{
AuthoriseService.User = _unitWork.FindSingle<User>(u => u.Account == loginuser);
return AuthoriseService;
}
2017-09-01 00:47:44 +08:00
}
public UserWithAccessedCtrls GetAccessedControls(string username)
{
2017-11-29 00:48:51 +08:00
var service = Create(username);
2017-09-01 00:47:44 +08:00
var user = new UserWithAccessedCtrls
{
User = service.User,
Orgs = service.Orgs,
Modules = service.Modules.OrderBy(u => u.SortNo).ToList().MapToList<ModuleView>(),
Resources = service.Resources,
Roles = service.Roles
};
foreach (var moduleView in user.Modules)
{
moduleView.Elements =
service.ModuleElements.Where(u => u.ModuleId == moduleView.Id).OrderBy(u => u.Sort).ToList();
}
return user;
}
}
2015-04-25 12:31:01 +08:00
}