SystemAuthStrategy.cs
2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// ***********************************************************************
// <summary>
// 超级管理员授权策略
// </summary>
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using WebRepository;
namespace WebApp
{
/// <summary>
/// 领域服务
/// <para>超级管理员权限</para>
/// <para>超级管理员使用guid.empty为ID,可以根据需要修改</para>
/// </summary>
public class SystemAuthStrategy : WebApp<SysUser>, IAuthStrategy
{
protected SysUser _user;
public List<SysModuleView> Modules
{
get {
var modules = (from module in UnitWork.Find<SysModule>(null)
select new SysModuleView
{
Name = module.Name,
Id = module.Id.Value,
CascadeId = module.CascadeId,
Code = module.Code,
IconName = module.IconName,
Url = module.Url,
ParentId = module.ParentId,
ParentName = module.ParentName,
SortNo = module.SortNo.Value,
IsShow = module.IsShow.Value,
CreateBy = module.CreateBy,
CreateTime = module.CreateTime,
UpdateBy = module.UpdateBy,
UpdateTime = module.UpdateTime
}).OrderBy(u => u.SortNo).ToList();
foreach (var module in modules)
{
module.Elements = UnitWork.Find<SysModuleElement>(u => u.ModuleId == module.Id).OrderBy(u => u.Sort).ToList();
}
return modules;
}
}
public List<SysRole> Roles
{
get { return UnitWork.Find<SysRole>(null).ToList(); }
}
public List<SysDept> Orgs
{
get { return UnitWork.Find<SysDept>(null).ToList(); }
}
public SysUser User
{
get { return _user; }
set //禁止外部设置
{
throw new Exception("超级管理员,禁止设置用户");
}
}
public SystemAuthStrategy(IUnitWork unitWork, IRepository<SysUser> repository) : base(unitWork, repository)
{
_user = unitWork.FindSingle<SysUser>(u => u.Account.Equals("System"));
}
}
}