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