using System;
using System.Collections.Generic;
using LeaRun.Util.Extension;
using System.Linq;
using System.Linq.Expressions;
namespace LeaRun.Application.Code
{
///
/// 版 本
/// Copyright (c) 2013-2016 上海力软信息技术有限公司
/// 创建人:刘晓雷
/// 日 期:2016.03.29 22:35
/// 描 述:授权认证
///
public static class AuthorizeExtensions
{
#region 带权限的数据源查询
///
/// 获取授权数据
///
///
///
///
public static IEnumerable ToAuthorizeData(this IEnumerable data)
{
if (data != null)
{
if (OperatorProvider.Provider.Current().IsSystem)
return data;
string dataAutor = OperatorProvider.Provider.Current().DataAuthorize.ReadAutorizeUserId;
var parameter = Expression.Parameter(typeof(T), "t");
var authorConditon = Expression.Constant(dataAutor).Call("Contains", parameter.Property("CreateUserId"));
var lambda = authorConditon.ToLambda>(parameter);
return data.Where(lambda.Compile());
}
else
{
return null;
}
}
#endregion
}
}