SystemAuthStrategy.cs
3.59 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// ***********************************************************************
// <summary>
// 超级管理员授权策略
// </summary>
// ***********************************************************************
using Hh.Mes.Pojo.System;
using Hh.Mes.POJO.Entity;
using Hh.Mes.Service.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Hh.Mes.Service.SystemAuth
{
/// <summary>
/// 领域服务
/// <para>超级管理员权限</para>
/// <para>超级管理员使用guid.empty为ID,可以根据需要修改</para>
/// </summary>
public class SystemAuthStrategy : RepositorySqlSugar<SysUser>
{
protected SysUser _user;
public List<SysModuleView> Modules
{
get
{
List<SysModuleView> modules = null;
List<SysModuleElement> elements = null;
//if (SystemCache.GetInstance.SysModuleViewCache.Count > 0)
//{
// modules = SystemCache.GetInstance.SysModuleViewCache;
//}
//else
//{
//根据用户的模块ID来获取具体模块信息
var moduleList = Context.Queryable<SysModule>().Where(t => true).ToList();
//组合成页面展示需要的SysModuleView格式
modules = new List<SysModuleView>();
foreach (var item in moduleList.OrderBy(u => u.SortNo))
{
SysModuleView sysModuleView = new SysModuleView();
sysModuleView.Id = item.Id;
sysModuleView.Code = item.Code;
sysModuleView.Name = item.Name;
sysModuleView.CascadeId = item.CascadeId;
sysModuleView.IconName = item.IconName;
sysModuleView.Url = item.Url;
sysModuleView.ParentId = item.ParentId;
sysModuleView.ParentName = item.ParentName;
sysModuleView.SortNo = item.SortNo;
sysModuleView.IsShow = item.IsShow.Value;
modules.Add(sysModuleView);
}
// SystemCache.GetInstance.SysModuleViewCache = modules;
//}
//if (SystemCache.GetInstance.SysModuleElementCache.Count > 0)
//{
// elements = SystemCache.GetInstance.SysModuleElementCache;
//}
//else
//{
//根据模块内元素ID
elements = Context.Queryable<SysModuleElement>().Where(t => true).ToList();
//SystemCache.GetInstance.SysModuleElementCache = elements;
//}
foreach (var module in modules)
{
module.Elements = elements.Where(t => t.ModuleId == module.Id).OrderBy(t => t.Sort).ToList();
}
return modules;
}
}
public List<SysRole> Roles
{
get
{
return Context.Queryable<SysRole>().Where(t => true).ToList();
}
}
public List<SysDept> Orgs
{
get
{
return Context.Queryable<SysDept>().Where(t => true).ToList();
}
}
public SysUser User
{
get
{
return _user;
}
set
{
_user = value;
}
}
}
}