2020-10-22 14:59:36 +08:00
|
|
|
|
// ***********************************************************************
|
|
|
|
|
// Assembly : OpenAuth.App
|
|
|
|
|
// Author : Yubao Li
|
|
|
|
|
// Created : 12-01-2015
|
|
|
|
|
//
|
|
|
|
|
// Last Modified By : Yubao Li
|
|
|
|
|
// Last Modified On : 12-01-2015
|
|
|
|
|
// ***********************************************************************
|
|
|
|
|
// <copyright file="LoginUserVM.cs" company="">
|
|
|
|
|
// Copyright (c) . All rights reserved.
|
|
|
|
|
// </copyright>
|
|
|
|
|
// <summary>
|
|
|
|
|
// 授权策略上下文,一个典型的策略模式
|
|
|
|
|
// 根据用户账号的不同,采用不同的授权模式,以后可以扩展更多的授权方式
|
|
|
|
|
// </summary>
|
|
|
|
|
// ***********************************************************************
|
|
|
|
|
|
2021-08-25 01:42:37 +08:00
|
|
|
|
using System;
|
2020-10-22 14:59:36 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Infrastructure;
|
|
|
|
|
using OpenAuth.App.Response;
|
|
|
|
|
using OpenAuth.Repository.Domain;
|
|
|
|
|
|
|
|
|
|
namespace OpenAuth.App
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 授权策略上下文,一个典型的策略模式
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class AuthStrategyContext
|
|
|
|
|
{
|
|
|
|
|
private readonly IAuthStrategy _strategy;
|
|
|
|
|
public AuthStrategyContext(IAuthStrategy strategy)
|
|
|
|
|
{
|
|
|
|
|
this._strategy = strategy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public User User
|
|
|
|
|
{
|
|
|
|
|
get { return _strategy.User; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ModuleView> Modules
|
|
|
|
|
{
|
|
|
|
|
get { return _strategy.Modules; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ModuleElement> ModuleElements
|
|
|
|
|
{
|
|
|
|
|
get { return _strategy.ModuleElements; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Role> Roles
|
|
|
|
|
{
|
|
|
|
|
get { return _strategy.Roles; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Resource> Resources
|
|
|
|
|
{
|
|
|
|
|
get { return _strategy.Resources; }
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-23 15:42:50 +08:00
|
|
|
|
public List<OrgView> Orgs
|
2020-10-22 14:59:36 +08:00
|
|
|
|
{
|
|
|
|
|
get { return _strategy.Orgs; }
|
|
|
|
|
}
|
2021-10-18 00:42:29 +08:00
|
|
|
|
|
2021-08-25 01:42:37 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取角色可以访问的字段信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="moduleCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<BuilderTableColumn> GetTableColumns(string moduleCode)
|
|
|
|
|
{
|
|
|
|
|
return _strategy.GetTableColumns(moduleCode);
|
|
|
|
|
}
|
2022-02-21 00:39:55 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取角色可访问的字段信息,因为MVC版本没有代码生成器,所以只能通过直接读取数据库表结构的方式
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="moduleCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[Obsolete("获取角色可访问的字段信息,因为MVC版本没有代码生成器,所以只能通过直接读取数据库表结构的方式")]
|
|
|
|
|
public List<BuilderTableColumn> GetTableColumnsFromDb(string moduleCode)
|
|
|
|
|
{
|
|
|
|
|
return _strategy.GetTableColumnsFromDb(moduleCode);
|
|
|
|
|
}
|
2020-10-22 14:59:36 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|