You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.4 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using Infrastructure;
using OpenAuth.App.Base;
using OpenAuth.App.BaseApp.Base;
using OpenAuth.App.Response;
using OpenAuth.Repository;
using OpenAuth.Repository.Domain;
using SqlSugar;
namespace OpenAuth.App
{
/// <summary>
/// 领域服务
/// <para>超级管理员权限</para>
/// <para>超级管理员使用-1可以根据需要修改</para>
/// </summary>
public class SystemAuthStrategy : SqlSugarBaseApp<SysUser, SugarDbContext>, IAuthStrategy
{
protected SysUser _user;
public List<ModuleView> Modules
{
get
{
return Repository.ChangeRepository<SugarRepositiry<SysModule>>().AsQueryable()
.Includes(a => a.Elements)
.Select(a => new ModuleView
{
Elements = a.Elements
}, true)
.ToList();
}
}
public List<SysRole> Roles
{
get { return Repository.ChangeRepository<SugarRepositiry<SysRole>>().GetList(); }
}
public List<SysModuleElement> ModuleElements
{
get { return Repository.ChangeRepository<SugarRepositiry<SysModuleElement>>().GetList(); }
}
public List<SysResource> Resources
{
get { return Repository.ChangeRepository<SugarRepositiry<SysResource>>().GetList(); }
}
public List<SysOrg> Orgs
{
get { return Repository.ChangeRepository<SugarRepositiry<SysOrg>>().GetList(); }
}
public List<SysPosition> Positions
{
get { return Repository.ChangeRepository<SugarRepositiry<SysPosition>>().GetList(); }
}
public SysUser User
{
get { return _user; }
set //禁止外部设置
{
throw new Exception("超级管理员,禁止设置用户");
}
}
public SystemAuthStrategy(ISugarUnitOfWork<SugarDbContext> unitWork, ISimpleClient<SysUser> repository) : base(unitWork, repository, null)
{
_user = new SysUser
{
Account = Define.SYSTEM_USERNAME,
Name = "超级管理员",
Id = -1
};
}
}
}