diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/AbpDataProtectionOptions.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/AbpDataProtectionOptions.cs
index 9beede4f8..a27a4f65d 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/AbpDataProtectionOptions.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/AbpDataProtectionOptions.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq.Expressions;
using Volo.Abp.Auditing;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities;
@@ -16,15 +17,19 @@ public class AbpDataProtectionOptions
///
/// 权限主体
///
- public IList SubjectContributors { get; set; }
+ public IList SubjectContributors { get; }
///
/// 过滤字段关键字
///
- public IDictionary KeywordContributors { get; set; }
+ public IDictionary KeywordContributors { get; }
///
/// 数据操作
///
- public IDictionary OperateContributors { get; set; }
+ public IDictionary OperateContributors { get; }
+ ///
+ /// 默认实体过滤
+ ///
+ public IDictionary> DefaultEntityFilters { get; }
///
/// 忽略审计字段列表
///
@@ -35,6 +40,7 @@ public class AbpDataProtectionOptions
SubjectContributors = new List();
KeywordContributors = new Dictionary();
OperateContributors = new Dictionary();
+ DefaultEntityFilters = new Dictionary>();
IgnoreAuditedProperties = new List
{
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/EntityTypeFilterBuilder.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/EntityTypeFilterBuilder.cs
index f5f3cd4f9..0d5e358ff 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/EntityTypeFilterBuilder.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/EntityTypeFilterBuilder.cs
@@ -61,6 +61,13 @@ public class EntityTypeFilterBuilder : IEntityTypeFilterBuilder, ITransientDepen
}
LambdaExpression subExp = null;
+
+ if (subjectFilterGroups.Count == 0 &&
+ _options.DefaultEntityFilters.TryGetValue(entityType, out var filterFunc))
+ {
+ subExp = filterFunc(_serviceProvider, entityType, operation);
+ }
+
foreach (var subGroup in subjectFilterGroups)
{
subExp = subExp == null ? GetExpression(entityType, subGroup) : subExp.OrElse(func, GetExpression(entityType, subGroup));