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;
|
2023-12-23 15:42:50 +08:00
|
|
|
|
using SqlSugar;
|
2020-10-22 14:59:36 +08:00
|
|
|
|
|
|
|
|
|
namespace OpenAuth.App
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 领域服务
|
|
|
|
|
/// <para>超级管理员权限</para>
|
|
|
|
|
/// <para>超级管理员使用guid.empty为ID,可以根据需要修改</para>
|
|
|
|
|
/// </summary>
|
2023-12-23 15:42:50 +08:00
|
|
|
|
public class SystemAuthStrategy : SqlSugarBaseApp<User>, IAuthStrategy
|
2020-10-22 14:59:36 +08:00
|
|
|
|
{
|
|
|
|
|
protected User _user;
|
|
|
|
|
private DbExtension _dbExtension;
|
|
|
|
|
|
|
|
|
|
public List<ModuleView> Modules
|
|
|
|
|
{
|
2023-12-23 15:42:50 +08:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return SugarClient.Queryable<ModuleView>().Includes(x=>x.Elements).ToList();
|
2020-10-22 14:59:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Role> Roles
|
|
|
|
|
{
|
2023-12-23 15:42:50 +08:00
|
|
|
|
get { return SugarClient.Queryable<Role>().ToList(); }
|
2020-10-22 14:59:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ModuleElement> ModuleElements
|
|
|
|
|
{
|
2023-12-23 15:42:50 +08:00
|
|
|
|
get { return SugarClient.Queryable<ModuleElement>().ToList(); }
|
2020-10-22 14:59:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Resource> Resources
|
|
|
|
|
{
|
2023-12-23 15:42:50 +08:00
|
|
|
|
get { return SugarClient.Queryable<Resource>().ToList(); }
|
2020-10-22 14:59:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-23 15:42:50 +08:00
|
|
|
|
public List<OrgView> Orgs
|
2020-10-22 14:59:36 +08:00
|
|
|
|
{
|
2023-12-23 15:42:50 +08:00
|
|
|
|
get { return SugarClient.Queryable<SysOrg>()
|
|
|
|
|
.LeftJoin<User>((org, user) => org.ChairmanId ==user.Id)
|
|
|
|
|
.Select((org,user)=>new OrgView
|
|
|
|
|
{
|
|
|
|
|
Id = org.Id.SelectAll(),
|
|
|
|
|
ChairmanName = user.Name
|
|
|
|
|
}).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)
|
|
|
|
|
{
|
2023-12-23 15:42:50 +08:00
|
|
|
|
return SugarClient.Queryable<BuilderTableColumn>().Where(u => u.TableName.ToLower() == moduleCode.ToLower()).ToList();
|
2021-08-25 01:42:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-21 00:39:55 +08:00
|
|
|
|
public List<BuilderTableColumn> GetTableColumnsFromDb(string moduleCode)
|
|
|
|
|
{
|
|
|
|
|
return _dbExtension.GetTableColumnsFromDb(moduleCode);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-22 14:59:36 +08:00
|
|
|
|
|
2023-12-23 15:42:50 +08:00
|
|
|
|
public SystemAuthStrategy(ISqlSugarClient client,DbExtension dbExtension) : base(client, null)
|
2020-10-22 14:59:36 +08:00
|
|
|
|
{
|
|
|
|
|
_dbExtension = dbExtension;
|
|
|
|
|
_user = new User
|
|
|
|
|
{
|
|
|
|
|
Account = Define.SYSTEM_USERNAME,
|
|
|
|
|
Name = "超级管理员",
|
|
|
|
|
Id = Guid.Empty.ToString()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|