2020-10-22 14:59:36 +08:00
|
|
|
|
// ***********************************************************************
|
|
|
|
|
// Assembly : OpenAuth.App
|
|
|
|
|
// Author : 李玉宝
|
|
|
|
|
// Created : 06-06-2018
|
|
|
|
|
//
|
|
|
|
|
// Last Modified By : 李玉宝
|
|
|
|
|
// Last Modified On : 07-05-2018
|
|
|
|
|
// ***********************************************************************
|
|
|
|
|
// <copyright file="SystemAuthStrategy.cs" company="OpenAuth.App">
|
2021-07-22 19:33:55 +08:00
|
|
|
|
// Copyright (c) http://www.openauth.net.cn. All rights reserved.
|
2020-10-22 14:59:36 +08:00
|
|
|
|
// </copyright>
|
|
|
|
|
// <summary>
|
|
|
|
|
// 超级管理员授权策略
|
|
|
|
|
// </summary>
|
|
|
|
|
// ***********************************************************************
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Infrastructure;
|
|
|
|
|
using OpenAuth.App.Response;
|
2020-12-29 23:52:06 +08:00
|
|
|
|
using OpenAuth.Repository;
|
2020-10-22 14:59:36 +08:00
|
|
|
|
using OpenAuth.Repository.Domain;
|
|
|
|
|
using OpenAuth.Repository.Interface;
|
|
|
|
|
|
|
|
|
|
namespace OpenAuth.App
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 领域服务
|
|
|
|
|
/// <para>超级管理员权限</para>
|
|
|
|
|
/// <para>超级管理员使用guid.empty为ID,可以根据需要修改</para>
|
|
|
|
|
/// </summary>
|
2021-03-13 23:45:10 +08:00
|
|
|
|
public class SystemAuthStrategy : BaseStringApp<User,OpenAuthDBContext>, IAuthStrategy
|
2020-10-22 14:59:36 +08:00
|
|
|
|
{
|
|
|
|
|
protected User _user;
|
|
|
|
|
private DbExtension _dbExtension;
|
|
|
|
|
|
|
|
|
|
public List<ModuleView> Modules
|
|
|
|
|
{
|
|
|
|
|
get {
|
|
|
|
|
var modules = (from module in UnitWork.Find<Module>(null)
|
|
|
|
|
select new ModuleView
|
|
|
|
|
{
|
|
|
|
|
SortNo = module.SortNo,
|
|
|
|
|
Name = module.Name,
|
|
|
|
|
Id = module.Id,
|
|
|
|
|
CascadeId = module.CascadeId,
|
|
|
|
|
Code = module.Code,
|
|
|
|
|
IconName = module.IconName,
|
|
|
|
|
Url = module.Url,
|
|
|
|
|
ParentId = module.ParentId,
|
|
|
|
|
ParentName = module.ParentName,
|
|
|
|
|
IsSys = module.IsSys,
|
|
|
|
|
Status = module.Status
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var module in modules)
|
|
|
|
|
{
|
|
|
|
|
module.Elements = UnitWork.Find<ModuleElement>(u => u.ModuleId == module.Id).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return modules;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Role> Roles
|
|
|
|
|
{
|
|
|
|
|
get { return UnitWork.Find<Role>(null).ToList(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ModuleElement> ModuleElements
|
|
|
|
|
{
|
|
|
|
|
get { return UnitWork.Find<ModuleElement>(null).ToList(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Resource> Resources
|
|
|
|
|
{
|
|
|
|
|
get { return UnitWork.Find<Resource>(null).ToList(); }
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-21 17:31:34 +08:00
|
|
|
|
public List<SysOrg> Orgs
|
2020-10-22 14:59:36 +08:00
|
|
|
|
{
|
2022-01-21 17:31:34 +08:00
|
|
|
|
get { return UnitWork.Find<SysOrg>(null).ToList(); }
|
2020-10-22 14:59:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public User User
|
|
|
|
|
{
|
|
|
|
|
get { return _user; }
|
|
|
|
|
set //禁止外部设置
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("超级管理员,禁止设置用户");
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-18 00:42:29 +08:00
|
|
|
|
|
2020-10-22 14:59:36 +08:00
|
|
|
|
|
2021-08-25 01:42:37 +08:00
|
|
|
|
public List<BuilderTableColumn> GetTableColumns(string moduleCode)
|
|
|
|
|
{
|
|
|
|
|
return UnitWork.Find<BuilderTableColumn>(u => u.TableName.ToLower() == moduleCode.ToLower()).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-22 14:59:36 +08:00
|
|
|
|
|
2020-12-29 23:52:06 +08:00
|
|
|
|
public SystemAuthStrategy(IUnitWork<OpenAuthDBContext> unitWork, IRepository<User,OpenAuthDBContext> repository, DbExtension dbExtension) : base(unitWork, repository, null)
|
2020-10-22 14:59:36 +08:00
|
|
|
|
{
|
|
|
|
|
_dbExtension = dbExtension;
|
|
|
|
|
_user = new User
|
|
|
|
|
{
|
|
|
|
|
Account = Define.SYSTEM_USERNAME,
|
|
|
|
|
Name = "超级管理员",
|
|
|
|
|
Id = Guid.Empty.ToString()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|