// ***********************************************************************
// Assembly : OpenAuth.App
// Author : Yubao Li
// Created : 12-01-2015
//
// Last Modified By : Yubao Li
// Last Modified On : 12-01-2015
// ***********************************************************************
//
// Copyright (c) . All rights reserved.
//
//
// 授权策略上下文,一个典型的策略模式
// 根据用户账号的不同,采用不同的授权模式,以后可以扩展更多的授权方式
//
// ***********************************************************************
using System;
using System.Collections.Generic;
using Infrastructure;
using OpenAuth.App.Response;
using OpenAuth.Repository.Domain;
namespace OpenAuth.App
{
///
/// 授权策略上下文,一个典型的策略模式
///
public class AuthStrategyContext
{
private readonly IAuthStrategy _strategy;
public AuthStrategyContext(IAuthStrategy strategy)
{
this._strategy = strategy;
}
public SysUser User
{
get { return _strategy.User; }
}
public List Modules
{
get { return _strategy.Modules; }
}
public List ModuleElements
{
get { return _strategy.ModuleElements; }
}
public List Roles
{
get { return _strategy.Roles; }
}
public List Resources
{
get { return _strategy.Resources; }
}
public List Orgs
{
get { return _strategy.Orgs; }
}
///
/// 获取角色可以访问的字段信息
///
///
///
public List GetTableColumns(string moduleCode)
{
return _strategy.GetTableColumns(moduleCode);
}
///
/// 获取角色可访问的字段信息,因为MVC版本没有代码生成器,所以只能通过直接读取数据库表结构的方式
///
///
///
[Obsolete("获取角色可访问的字段信息,因为MVC版本没有代码生成器,所以只能通过直接读取数据库表结构的方式")]
public List GetTableColumnsFromDb(string moduleCode)
{
return _strategy.GetTableColumnsFromDb(moduleCode);
}
}
}