Infrastructure/OpenAuth.Auth/AuthStrategies/SystemAuthStrategy.cs

84 lines
2.1 KiB
C#
Raw Normal View History

2024-11-13 09:19:06 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using Infrastructure;
2025-05-13 15:18:14 +08:00
using OpenAuth.Auth.Interface;
using OpenAuth.Auth.Model;
2024-11-13 09:19:06 +08:00
using OpenAuth.Repository;
using OpenAuth.Repository.Domain;
using SqlSugar;
2025-05-13 15:18:14 +08:00
namespace OpenAuth.Auth.AuthStrategies
2024-11-13 09:19:06 +08:00
{
/// <summary>
/// 领域服务
/// <para>超级管理员权限</para>
/// <para>超级管理员使用-1可以根据需要修改</para>
/// </summary>
2025-05-13 15:18:14 +08:00
public class SystemAuthStrategy : IAuthStrategy
2024-11-13 09:19:06 +08:00
{
2025-05-13 15:18:14 +08:00
ISqlSugarClient client;
public SystemAuthStrategy(ISqlSugarClient client)
{
this.client = client;
_user = new SysUser
{
Account = Define.SYSTEM_USERNAME,
Name = "超级管理员",
Id = -1
};
}
2024-11-13 09:19:06 +08:00
protected SysUser _user;
public List<ModuleView> Modules
{
get
{
2025-05-13 15:18:14 +08:00
return client.Queryable<SysModule>()
2024-11-13 09:19:06 +08:00
.Includes(a => a.Elements)
.Select(a => new ModuleView
{
Elements = a.Elements
}, true)
.ToList();
}
}
public List<SysRole> Roles
{
2025-05-13 15:18:14 +08:00
get { return client.Queryable<SysRole>().ToList(); }
2024-11-13 09:19:06 +08:00
}
public List<SysModuleElement> ModuleElements
{
2025-05-13 15:18:14 +08:00
get { return client.Queryable<SysModuleElement>().ToList(); }
2024-11-13 09:19:06 +08:00
}
public List<SysResource> Resources
{
2025-05-13 15:18:14 +08:00
get { return client.Queryable < SysResource>().ToList(); }
2024-11-13 09:19:06 +08:00
}
public List<SysOrg> Orgs
{
2025-05-13 15:18:14 +08:00
get { return client.Queryable < SysOrg>().ToList(); }
2024-11-13 09:19:06 +08:00
}
public List<SysPosition> Positions
{
2025-05-13 15:18:14 +08:00
get { return client.Queryable < SysPosition>().ToList(); }
2024-11-13 09:19:06 +08:00
}
public SysUser User
{
get { return _user; }
set //禁止外部设置
{
throw new Exception("超级管理员,禁止设置用户");
}
}
}
}