diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessFilterGroup.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessFilterGroup.cs
index 31cbecc58..b7319930d 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessFilterGroup.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessFilterGroup.cs
@@ -32,8 +32,13 @@ public class DataAccessFilterGroup
return this;
}
- public DataAccessFilterGroup AddRule(string field, object value, DataAccessFilterOperate operate = DataAccessFilterOperate.Equal)
+ public DataAccessFilterGroup AddRule(
+ string field,
+ object value,
+ string typeFullName,
+ string javaScriptType,
+ DataAccessFilterOperate operate = DataAccessFilterOperate.Equal)
{
- return AddRule(new DataAccessFilterRule(field, value, operate));
+ return AddRule(new DataAccessFilterRule(field, value, typeFullName, javaScriptType, operate));
}
}
\ No newline at end of file
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessFilterRule.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessFilterRule.cs
index 868e72bb1..eddbffc76 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessFilterRule.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessFilterRule.cs
@@ -14,6 +14,14 @@ public class DataAccessFilterRule
///
public object Value { get; set; }
///
+ /// 类型全名
+ ///
+ public string TypeFullName { get; set; }
+ ///
+ /// Js类型
+ ///
+ public string JavaScriptType { get; set; }
+ ///
/// 操作类型
///
public DataAccessFilterOperate Operate { get; set; }
@@ -27,10 +35,18 @@ public class DataAccessFilterRule
}
- public DataAccessFilterRule(string field, object value, DataAccessFilterOperate operate = DataAccessFilterOperate.Equal, bool isLeft = false)
+ public DataAccessFilterRule(
+ string field,
+ object value,
+ string typeFullName,
+ string javaScriptType,
+ DataAccessFilterOperate operate = DataAccessFilterOperate.Equal,
+ bool isLeft = false)
{
Field = field;
Value = value;
+ TypeFullName = typeFullName;
+ JavaScriptType = javaScriptType;
Operate = operate;
IsLeft = isLeft;
}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessResource.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessResource.cs
index 27959a51b..786887299 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessResource.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessResource.cs
@@ -34,7 +34,7 @@ public class DataAccessResource
///
/// 允许操作的属性列表
///
- public List AllowProperties { get; set; }
+ public List AccessedProperties { get; set; }
public DataAccessResource()
{
@@ -53,6 +53,6 @@ public class DataAccessResource
EntityTypeFullName = entityTypeFullName;
Operation = operation;
FilterGroup = filterGroup;
- AllowProperties = new List();
+ AccessedProperties = new List();
}
}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessResourceChangeEvent.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessResourceChangeEvent.cs
new file mode 100644
index 000000000..c2df4141a
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DataAccessResourceChangeEvent.cs
@@ -0,0 +1,20 @@
+using System;
+using Volo.Abp.EventBus;
+
+namespace LINGYUN.Abp.DataProtection;
+
+[Serializable]
+[EventName("abp.data_protection.resource_changed")]
+public class DataAccessResourceChangeEvent
+{
+ public DataAccessResource Resource { get; set; }
+ public DataAccessResourceChangeEvent()
+ {
+
+ }
+
+ public DataAccessResourceChangeEvent(DataAccessResource resource)
+ {
+ Resource = resource;
+ }
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DisableDataProtectedAttribute.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DisableDataProtectedAttribute.cs
index 9c8731596..052d53fea 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DisableDataProtectedAttribute.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/DisableDataProtectedAttribute.cs
@@ -5,4 +5,13 @@ namespace LINGYUN.Abp.DataProtection;
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false)]
public class DisableDataProtectedAttribute : Attribute
{
+ public DataAccessOperation? Operation { get; }
+ public DisableDataProtectedAttribute()
+ {
+ }
+
+ public DisableDataProtectedAttribute(DataAccessOperation operation)
+ {
+ Operation = operation;
+ }
}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Localization/Resources/en.json b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Localization/Resources/en.json
index ff637aac0..a07a45eff 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Localization/Resources/en.json
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Localization/Resources/en.json
@@ -1,6 +1,10 @@
{
"culture": "en",
"texts": {
- "DataProtection:010001": "Data access permission not granted to protected resources!"
+ "DataProtection:010001": "Data access permission not granted to protected resources!",
+ "DisplayName:LastModifierId": "Last Modifier Id",
+ "DisplayName:LastModificationTime": "Last Modification Time",
+ "DisplayName:CreatorId": "Creator Id",
+ "DisplayName:CreationTime": "Creation Time"
}
}
\ No newline at end of file
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Localization/Resources/zh-Hans.json b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Localization/Resources/zh-Hans.json
index 964c7ab93..5e719bf94 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Localization/Resources/zh-Hans.json
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Localization/Resources/zh-Hans.json
@@ -1,6 +1,10 @@
{
"culture": "zh-Hans",
"texts": {
- "DataProtection:010001": "未授予受保护资源的数据访问权限!"
+ "DataProtection:010001": "未授予受保护资源的数据访问权限!",
+ "DisplayName:LastModifierId": "上次修改人",
+ "DisplayName:LastModificationTime": "上次修改时间",
+ "DisplayName:CreatorId": "创建人",
+ "DisplayName:CreationTime": "创建时间"
}
}
\ No newline at end of file
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Models/EntityEnumInfoModel.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Models/EntityEnumInfoModel.cs
new file mode 100644
index 000000000..efd2e2bc7
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Models/EntityEnumInfoModel.cs
@@ -0,0 +1,7 @@
+namespace LINGYUN.Abp.DataProtection.Models;
+
+public class EntityEnumInfoModel
+{
+ public string Key { get; set; }
+ public object Value { get; set; }
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Models/EntityPropertyInfoModel.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Models/EntityPropertyInfoModel.cs
new file mode 100644
index 000000000..522338a16
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Models/EntityPropertyInfoModel.cs
@@ -0,0 +1,33 @@
+namespace LINGYUN.Abp.DataProtection.Models;
+
+public class EntityPropertyInfoModel
+{
+ ///
+ /// 名称
+ ///
+ public string Name { get; set; }
+ ///
+ /// 显示名称
+ ///
+ public string DisplayName { get; set; }
+ ///
+ /// 类型全名
+ ///
+ public string TypeFullName { get; set; }
+ ///
+ /// JavaScript类型
+ ///
+ public string JavaScriptType { get; set; }
+ ///
+ /// JavaScript名称
+ ///
+ public string JavaScriptName { get; set; }
+ ///
+ /// 枚举列表
+ ///
+ public EntityEnumInfoModel[] Enums { get; set; }
+ ///
+ /// 允许的过滤操作列表
+ ///
+ public DataAccessFilterOperate[] Operates { get; set; }
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Models/EntityTypeInfoGetModel.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Models/EntityTypeInfoGetModel.cs
new file mode 100644
index 000000000..44c38a5a3
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Models/EntityTypeInfoGetModel.cs
@@ -0,0 +1,9 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace LINGYUN.Abp.DataProtection.Models;
+
+public class EntityTypeInfoGetModel
+{
+ [Required]
+ public DataAccessOperation Operation { get; set; }
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Models/EntityTypeInfoModel.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Models/EntityTypeInfoModel.cs
new file mode 100644
index 000000000..84d1f30c3
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/LINGYUN/Abp/DataProtection/Models/EntityTypeInfoModel.cs
@@ -0,0 +1,19 @@
+using System.Collections.Generic;
+
+namespace LINGYUN.Abp.DataProtection.Models;
+
+public class EntityTypeInfoModel
+{
+ ///
+ /// 实体名称
+ ///
+ public string Name { get; set; }
+ ///
+ /// 显示名称
+ ///
+ public string DisplayName { get; set; }
+ ///
+ /// 可访问属性列表
+ ///
+ public List Properties { get; set; } = new List();
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/FodyWeavers.xml b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/FodyWeavers.xml
new file mode 100644
index 000000000..1715698cc
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/FodyWeavers.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN.Abp.DataProtection.Application.Contracts.csproj b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN.Abp.DataProtection.Application.Contracts.csproj
new file mode 100644
index 000000000..5fb9d1dc9
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN.Abp.DataProtection.Application.Contracts.csproj
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+ netstandard2.0;netstandard2.1;net8.0;net9.0
+ LINGYUN.Abp.DataProtection.Application.Contracts
+ LINGYUN.Abp.DataProtection.Application.Contracts
+ false
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/AbpDataProtectionApplicationContractsModule.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/AbpDataProtectionApplicationContractsModule.cs
new file mode 100644
index 000000000..c15e35b94
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/AbpDataProtectionApplicationContractsModule.cs
@@ -0,0 +1,12 @@
+using Volo.Abp.Application;
+using Volo.Abp.Modularity;
+
+namespace LINGYUN.Abp.DataProtection;
+
+[DependsOn(
+ typeof(AbpDataProtectionAbstractionsModule),
+ typeof(AbpDddApplicationContractsModule))]
+public class AbpDataProtectionApplicationContractsModule : AbpModule
+{
+
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/EntityEnumInfoDto.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/EntityEnumInfoDto.cs
new file mode 100644
index 000000000..58d981ca3
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/EntityEnumInfoDto.cs
@@ -0,0 +1,7 @@
+namespace LINGYUN.Abp.DataProtection;
+
+public class EntityEnumInfoDto
+{
+ public string Key { get; set; }
+ public object Value { get; set; }
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/EntityPropertyInfoDto.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/EntityPropertyInfoDto.cs
new file mode 100644
index 000000000..74af75176
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/EntityPropertyInfoDto.cs
@@ -0,0 +1,29 @@
+namespace LINGYUN.Abp.DataProtection;
+
+public class EntityPropertyInfoDto
+{
+ ///
+ /// 名称
+ ///
+ public string Name { get; set; }
+ ///
+ /// 显示名称
+ ///
+ public string DisplayName { get; set; }
+ ///
+ /// 类型全名
+ ///
+ public string TypeFullName { get; set; }
+ ///
+ /// JavaScript类型
+ ///
+ public string JavaScriptType { get; set; }
+ ///
+ /// 枚举列表
+ ///
+ public EntityEnumInfoDto[] Enums { get; set; } = new EntityEnumInfoDto[0];
+ ///
+ /// 允许的过滤操作列表
+ ///
+ public DataAccessFilterOperate[] Operates { get; set; }
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/EntityTypeInfoDto.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/EntityTypeInfoDto.cs
new file mode 100644
index 000000000..faf3f2937
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/EntityTypeInfoDto.cs
@@ -0,0 +1,17 @@
+namespace LINGYUN.Abp.DataProtection;
+
+public class EntityTypeInfoDto
+{
+ ///
+ /// 实体名称
+ ///
+ public string Name { get; set; }
+ ///
+ /// 显示名称
+ ///
+ public string DisplayName { get; set; }
+ ///
+ /// 可访问属性列表
+ ///
+ public EntityPropertyInfoDto[] Properties { get; set; } = new EntityPropertyInfoDto[0];
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/EntityTypeInfoGetInput.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/EntityTypeInfoGetInput.cs
new file mode 100644
index 000000000..c6653682e
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/EntityTypeInfoGetInput.cs
@@ -0,0 +1,6 @@
+namespace LINGYUN.Abp.DataProtection;
+
+public class EntityTypeInfoGetInput
+{
+ public DataAccessOperation Operation { get; set; }
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/IEntityTypeInfoAppService.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/IEntityTypeInfoAppService.cs
new file mode 100644
index 000000000..4ac0b4fc5
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application.Contracts/LINGYUN/Abp/DataProtection/IEntityTypeInfoAppService.cs
@@ -0,0 +1,14 @@
+using System.Threading.Tasks;
+using Volo.Abp.Application.Services;
+
+namespace LINGYUN.Abp.DataProtection;
+
+public interface IEntityTypeInfoAppService : IApplicationService
+{
+ ///
+ /// 获取实体可访问规则
+ ///
+ ///
+ ///
+ Task GetEntityRuleAsync(EntityTypeInfoGetInput input);
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/FodyWeavers.xml b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/FodyWeavers.xml
new file mode 100644
index 000000000..1715698cc
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/FodyWeavers.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/LINGYUN.Abp.DataProtection.Application.csproj b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/LINGYUN.Abp.DataProtection.Application.csproj
new file mode 100644
index 000000000..632de70bd
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/LINGYUN.Abp.DataProtection.Application.csproj
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+ netstandard2.0;netstandard2.1;net8.0;net9.0
+ LINGYUN.Abp.DataProtection.Application
+ LINGYUN.Abp.DataProtection.Application
+ false
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/LINGYUN/Abp/DataProtection/AbpDataProtectionApplicationModule.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/LINGYUN/Abp/DataProtection/AbpDataProtectionApplicationModule.cs
new file mode 100644
index 000000000..f5bcff996
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/LINGYUN/Abp/DataProtection/AbpDataProtectionApplicationModule.cs
@@ -0,0 +1,13 @@
+using Volo.Abp.Application;
+using Volo.Abp.Modularity;
+
+namespace LINGYUN.Abp.DataProtection;
+
+[DependsOn(
+ typeof(AbpDataProtectionApplicationContractsModule),
+ typeof(AbpDataProtectionModule),
+ typeof(AbpDddApplicationModule))]
+public class AbpDataProtectionApplicationModule : AbpModule
+{
+
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/LINGYUN/Abp/DataProtection/EntityTypeInfoAppService.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/LINGYUN/Abp/DataProtection/EntityTypeInfoAppService.cs
new file mode 100644
index 000000000..393c9b345
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/LINGYUN/Abp/DataProtection/EntityTypeInfoAppService.cs
@@ -0,0 +1,47 @@
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.Extensions.DependencyInjection;
+using System.Linq;
+using System.Threading.Tasks;
+using Volo.Abp.Application.Services;
+using Volo.Abp.Localization;
+
+namespace LINGYUN.Abp.DataProtection;
+
+public abstract class EntityTypeInfoAppService : ApplicationService, IEntityTypeInfoAppService
+{
+ protected IDataAccessEntityTypeInfoProvider EntityTypeInfoProvider => LazyServiceProvider.GetRequiredService();
+
+ [Authorize]
+ public virtual async Task GetEntityRuleAsync(EntityTypeInfoGetInput input)
+ {
+ var entityType = typeof(TEntity);
+ var resourceType = LocalizationResource ?? typeof(DefaultResource);
+
+ var context = new DataAccessEntitTypeInfoContext(
+ entityType,
+ resourceType,
+ input.Operation,
+ LazyServiceProvider);
+
+ var model = await EntityTypeInfoProvider.GetEntitTypeInfoAsync(context);
+
+ return new EntityTypeInfoDto
+ {
+ Name = model.Name,
+ DisplayName = model.DisplayName,
+ Properties = model.Properties.Select(prop => new EntityPropertyInfoDto
+ {
+ Name = prop.Name,
+ DisplayName = prop.DisplayName,
+ TypeFullName = prop.TypeFullName,
+ JavaScriptType = prop.JavaScriptType,
+ Operates = prop.Operates,
+ Enums = prop.Enums.Select(em => new EntityEnumInfoDto
+ {
+ Key = em.Key,
+ Value = em.Value,
+ }).ToArray()
+ }).ToArray(),
+ };
+ }
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/System/NullableTypeExtensions.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/System/NullableTypeExtensions.cs
new file mode 100644
index 000000000..1d650f831
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Application/System/NullableTypeExtensions.cs
@@ -0,0 +1,10 @@
+namespace System;
+
+internal static class NullableTypeExtensions
+{
+ public static bool IsNullableType(this Type theType) =>
+ theType.IsGenericType(typeof(Nullable<>));
+
+ public static bool IsGenericType(this Type type, Type genericType) =>
+ type.IsGenericType && type.GetGenericTypeDefinition() == genericType;
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectedReadEntityInterceptor.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectedReadEntityInterceptor.cs
deleted file mode 100644
index b1f3e5b5f..000000000
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectedReadEntityInterceptor.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using Microsoft.EntityFrameworkCore.Diagnostics;
-using Microsoft.Extensions.Options;
-using System;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Reflection;
-using Volo.Abp.Data;
-using Volo.Abp.DependencyInjection;
-using Volo.Abp.Domain.Entities;
-using Volo.Abp.Users;
-
-namespace LINGYUN.Abp.DataProtection.EntityFrameworkCore;
-public class AbpDataProtectedReadEntityInterceptor : IQueryExpressionInterceptor, ITransientDependency
-{
- public IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!;
- public IOptions DataProtectionOptions => LazyServiceProvider.LazyGetRequiredService>();
- public ICurrentUser CurrentUser => LazyServiceProvider.LazyGetRequiredService();
- public IDataFilter DataFilter => LazyServiceProvider.LazyGetRequiredService();
- public IEntityTypeFilterBuilder EntityTypeFilterBuilder => LazyServiceProvider.LazyGetRequiredService();
-
- private static readonly MethodInfo WhereMethodInfo = typeof(Queryable).GetMethods().First(m => m.Name == nameof(Queryable.Where));
-
- public Expression QueryCompilationStarting(Expression queryExpression, QueryExpressionEventData eventData)
- {
- if (DataFilter.IsEnabled() && queryExpression.Type.GenericTypeArguments.Length > 0)
- {
- var entityType = queryExpression.Type.GenericTypeArguments[0];
- var exp = EntityTypeFilterBuilder.Build(entityType, DataAccessOperation.Read);
-
- return Expression.Call(
- method: WhereMethodInfo.MakeGenericMethod(entityType),
- arg0: queryExpression,
- arg1: exp);
- }
-
- return queryExpression;
- }
-
- public class DataProtectedExpressionVisitor : ExpressionVisitor
- {
- private readonly Type _entityType;
- private readonly IEntityTypeFilterBuilder _entityTypeFilterBuilder;
-
- public DataProtectedExpressionVisitor(Type entityType, IEntityTypeFilterBuilder entityTypeFilterBuilder)
- {
- _entityType = entityType;
- _entityTypeFilterBuilder = entityTypeFilterBuilder;
- }
-
- private static readonly MethodInfo WhereMethodInfo = typeof(Queryable).GetMethods().First(m => m.Name == nameof(Queryable.Where));
-
- protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression)
- {
- var method = WhereMethodInfo.MakeGenericMethod(_entityType);
- var args0 = base.VisitMethodCall(methodCallExpression);
- var args1 = _entityTypeFilterBuilder.Build(_entityType, DataAccessOperation.Read);
-
- return Expression.Call(
- method: method,
- arg0: args0,
- arg1: args1);
- }
- }
-}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectedWritePropertiesInterceptor.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectedWritePropertiesInterceptor.cs
index fd64ab0c5..b375afc9c 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectedWritePropertiesInterceptor.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectedWritePropertiesInterceptor.cs
@@ -28,14 +28,20 @@ public class AbpDataProtectedWritePropertiesInterceptor : SaveChangesInterceptor
{
var allowProperties = new List();
var entity = entry.Entity;
- var subjectContext = new DataAccessSubjectContributorContext(entity.GetType().FullName, DataAccessOperation.Write, LazyServiceProvider);
+ var entityType = entry.Entity.GetType();
+ var subjectContext = new DataAccessSubjectContributorContext(entityType.FullName, DataAccessOperation.Write, LazyServiceProvider);
foreach (var contributor in DataProtectionOptions.Value.SubjectContributors)
{
- var properties = contributor.GetAllowProperties(subjectContext);
+ var properties = await contributor.GetAccessdProperties(subjectContext);
allowProperties.AddIfNotContains(properties);
}
- allowProperties.AddIfNotContains(DataProtectionOptions.Value.IgnoreAuditedProperties);
+ if (DataProtectionOptions.Value.EntityIgnoreProperties.TryGetValue(entityType, out var entityIgnoreProps))
+ {
+ allowProperties.AddIfNotContains(entityIgnoreProps);
+ }
+
+ allowProperties.AddIfNotContains(DataProtectionOptions.Value.GlobalIgnoreProperties);
foreach (var property in entry.Properties)
{
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectionDbContext.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectionDbContext.cs
index 0a1517128..3b9d309a6 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectionDbContext.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectionDbContext.cs
@@ -27,7 +27,6 @@ public abstract class AbpDataProtectionDbContext : AbpDbContext());
//optionsBuilder.AddInterceptors(LazyServiceProvider.GetRequiredService());
optionsBuilder.AddInterceptors(LazyServiceProvider.GetRequiredService());
}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/EfCoreDataProtectionRepository.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/EfCoreDataProtectionRepository.cs
index b8617070c..7a002be8c 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/EfCoreDataProtectionRepository.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/EfCoreDataProtectionRepository.cs
@@ -21,23 +21,28 @@ public abstract class EfCoreDataProtectionRepository
{
private readonly IDataAuthorizationService _dataAuthorizationService;
private readonly IEntityTypeFilterBuilder _entityTypeFilterBuilder;
+ private readonly IEntityPropertyResultBuilder _entityPropertyResultBuilder;
protected EfCoreDataProtectionRepository(
[NotNull] IDbContextProvider dbContextProvider,
[NotNull] IDataAuthorizationService dataAuthorizationService,
- [NotNull] IEntityTypeFilterBuilder entityTypeFilterBuilder)
+ [NotNull] IEntityTypeFilterBuilder entityTypeFilterBuilder,
+ [NotNull] IEntityPropertyResultBuilder entityPropertyResultBuilder)
: base(dbContextProvider)
{
_dataAuthorizationService = dataAuthorizationService;
_entityTypeFilterBuilder = entityTypeFilterBuilder;
+ _entityPropertyResultBuilder = entityPropertyResultBuilder;
}
public async override Task> GetQueryableAsync()
{
var queryable = await base.GetQueryableAsync();
- var dataAccessFilterExp = _entityTypeFilterBuilder.Build(DataAccessOperation.Read);
- queryable = queryable.Where(dataAccessFilterExp);
+ var dataAccessFilterExp = await _entityTypeFilterBuilder.Build(DataAccessOperation.Read);
+ var accessFieldExp = await _entityPropertyResultBuilder.Build(DataAccessOperation.Read);
+
+ queryable = queryable.Where(dataAccessFilterExp).Select(accessFieldExp);
return queryable;
}
@@ -91,23 +96,28 @@ public abstract class EfCoreDataProtectionRepository : EfCo
{
private readonly IDataAuthorizationService _dataAuthorizationService;
private readonly IEntityTypeFilterBuilder _entityTypeFilterBuilder;
+ private readonly IEntityPropertyResultBuilder _entityPropertyResultBuilder;
protected EfCoreDataProtectionRepository(
[NotNull] IDbContextProvider dbContextProvider,
[NotNull] IDataAuthorizationService dataAuthorizationService,
- [NotNull] IEntityTypeFilterBuilder entityTypeFilterBuilder)
+ [NotNull] IEntityTypeFilterBuilder entityTypeFilterBuilder,
+ [NotNull] IEntityPropertyResultBuilder entityPropertyResultBuilder)
: base(dbContextProvider)
{
_dataAuthorizationService = dataAuthorizationService;
_entityTypeFilterBuilder = entityTypeFilterBuilder;
+ _entityPropertyResultBuilder = entityPropertyResultBuilder;
}
public async override Task> GetQueryableAsync()
{
var queryable = await base.GetQueryableAsync();
- var dataAccessFilterExp = _entityTypeFilterBuilder.Build(DataAccessOperation.Read);
- queryable = queryable.Where(dataAccessFilterExp);
+ var dataAccessFilterExp = await _entityTypeFilterBuilder.Build(DataAccessOperation.Read);
+ var accessFieldExp = await _entityPropertyResultBuilder.Build(DataAccessOperation.Read);
+
+ queryable = queryable.Where(dataAccessFilterExp).Select(accessFieldExp);
return queryable;
}
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 a27a4f65d..90bd5c877 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
@@ -31,9 +31,17 @@ public class AbpDataProtectionOptions
///
public IDictionary> DefaultEntityFilters { get; }
///
- /// 忽略审计字段列表
+ /// 实体忽略字段
///
- public IList IgnoreAuditedProperties { get; set; }
+ public IDictionary EntityIgnoreProperties { get; }
+ ///
+ /// 全局忽略字段列表(不参与字段级权限校验)
+ ///
+ public IList GlobalIgnoreProperties { get; set; }
+ ///
+ /// 审计字段列表(这些字段写入受保护实体的属性列表中,用于前端过滤)
+ ///
+ public IList AuditedObjectProperties { get; set; }
public AbpDataProtectionOptions()
{
IsEnabled = true;
@@ -41,8 +49,9 @@ public class AbpDataProtectionOptions
KeywordContributors = new Dictionary();
OperateContributors = new Dictionary();
DefaultEntityFilters = new Dictionary>();
+ EntityIgnoreProperties = new Dictionary();
- IgnoreAuditedProperties = new List
+ GlobalIgnoreProperties = new List
{
nameof(IEntity.Id),
nameof(IAuditedObject.LastModifierId),
@@ -57,5 +66,13 @@ public class AbpDataProtectionOptions
nameof(IHasConcurrencyStamp.ConcurrencyStamp),
nameof(IHasExtraProperties.ExtraProperties),
};
+
+ AuditedObjectProperties = new List
+ {
+ nameof(IAuditedObject.LastModifierId),
+ nameof(IAuditedObject.LastModificationTime),
+ nameof(IAuditedObject.CreatorId),
+ nameof(IAuditedObject.CreationTime),
+ };
}
}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataAccessEntitTypeInfoContext.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataAccessEntitTypeInfoContext.cs
new file mode 100644
index 000000000..0b215563b
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataAccessEntitTypeInfoContext.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace LINGYUN.Abp.DataProtection;
+
+public class DataAccessEntitTypeInfoContext
+{
+ public Type EntityType { get; }
+ public Type ResourceType { get; }
+ public DataAccessOperation Operation { get; }
+ public IServiceProvider ServiceProvider { get; }
+ public DataAccessEntitTypeInfoContext(
+ Type entityType,
+ Type resourceType,
+ DataAccessOperation operation,
+ IServiceProvider serviceProvider)
+ {
+ EntityType = entityType;
+ ResourceType = resourceType;
+ Operation = operation;
+ ServiceProvider = serviceProvider;
+ }
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataAccessEntityTypeInfoProvider.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataAccessEntityTypeInfoProvider.cs
new file mode 100644
index 000000000..7d283e80c
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataAccessEntityTypeInfoProvider.cs
@@ -0,0 +1,103 @@
+using LINGYUN.Abp.DataProtection.Models;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Localization;
+using Microsoft.Extensions.Options;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Threading.Tasks;
+using Volo.Abp.DependencyInjection;
+
+namespace LINGYUN.Abp.DataProtection;
+
+public class DataAccessEntityTypeInfoProvider : IDataAccessEntityTypeInfoProvider, ISingletonDependency
+{
+ public async virtual Task GetEntitTypeInfoAsync(DataAccessEntitTypeInfoContext context)
+ {
+ var allowProperties = new List();
+
+ var dataProtectionOptions = context.ServiceProvider.GetRequiredService>().Value;
+ var javaScriptTypeConvert = context.ServiceProvider.GetRequiredService();
+ var localizerFactory = context.ServiceProvider.GetRequiredService();
+ var stringLozalizer = localizerFactory.Create(context.ResourceType);
+
+ var entityTypeRuleModel = new EntityTypeInfoModel
+ {
+ Name = context.EntityType.Name,
+ DisplayName = stringLozalizer[$"DisplayName:{context.EntityType.Name}"].Value ?? context.EntityType.Name
+ };
+
+ var subjectContext = new DataAccessSubjectContributorContext(
+ context.EntityType.FullName,
+ context.Operation,
+ context.ServiceProvider);
+
+ foreach (var subjectContributor in dataProtectionOptions.SubjectContributors)
+ {
+ var subjectAllowProperties = await subjectContributor.GetAccessdProperties(subjectContext);
+
+ allowProperties.AddIfNotContains(subjectAllowProperties);
+ }
+
+ IEnumerable entityPropeties = context.EntityType.GetProperties();
+
+ if (allowProperties.Count > 0)
+ {
+ if (dataProtectionOptions.EntityIgnoreProperties.TryGetValue(context.EntityType, out var entityIgnoreProps))
+ {
+ allowProperties.AddIfNotContains(entityIgnoreProps);
+ }
+
+ allowProperties.AddIfNotContains(dataProtectionOptions.GlobalIgnoreProperties);
+
+ entityPropeties = entityPropeties.Where(x => allowProperties.Contains(x.Name));
+ }
+
+ foreach (var propertyInfo in entityPropeties)
+ {
+ // 字段本地化描述规则
+ // 在本地化文件中定义 DisplayName:PropertyName
+ var localizedProp = stringLozalizer[$"DisplayName:{propertyInfo.Name}"];
+ var propertyInfoResult = javaScriptTypeConvert.Convert(propertyInfo.PropertyType);
+ var entityPropertyInfo = new EntityPropertyInfoModel
+ {
+ Name = propertyInfo.Name,
+ TypeFullName = propertyInfo.PropertyType.FullName,
+ DisplayName = localizedProp.Value ?? propertyInfo.Name,
+ JavaScriptType = propertyInfoResult.Type,
+ JavaScriptName = propertyInfo.Name.ToCamelCase(),
+ Operates = propertyInfoResult.AllowOperates
+ };
+
+ var propertyType = propertyInfo.PropertyType;
+ if (propertyType.IsNullableType())
+ {
+ propertyType = propertyType.GetGenericArguments().FirstOrDefault();
+ }
+
+ if (typeof(Enum).IsAssignableFrom(propertyType))
+ {
+ var enumNames = Enum.GetNames(propertyType);
+ var enumValues = Enum.GetValues(propertyType);
+ var paramterOptions = new EntityEnumInfoModel[enumNames.Length];
+ for (var index = 0; index < enumNames.Length; index++)
+ {
+ var enumName = enumNames[index];
+ var localizerEnumKey = $"{propertyInfo.Name}:{enumName}";
+ var localizerEnumName = stringLozalizer[localizerEnumKey];
+ paramterOptions[index] = new EntityEnumInfoModel
+ {
+ Key = localizerEnumName.ResourceNotFound ? enumName : localizerEnumName.Value,
+ Value = enumValues.GetValue(index),
+ };
+ }
+ entityPropertyInfo.Enums = paramterOptions;
+ }
+
+ entityTypeRuleModel.Properties.Add(entityPropertyInfo);
+ }
+
+ return entityTypeRuleModel;
+ }
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataAccessResourceCacheInvalidator.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataAccessResourceCacheInvalidator.cs
new file mode 100644
index 000000000..58050d9f9
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataAccessResourceCacheInvalidator.cs
@@ -0,0 +1,18 @@
+using System.Threading.Tasks;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.EventBus.Distributed;
+
+namespace LINGYUN.Abp.DataProtection;
+
+public class DataAccessResourceCacheInvalidator : IDistributedEventHandler, ITransientDependency
+{
+ private readonly IDataProtectedResourceStore _resourceStore;
+ public DataAccessResourceCacheInvalidator(IDataProtectedResourceStore resourceStore)
+ {
+ _resourceStore = resourceStore;
+ }
+ public async virtual Task HandleEventAsync(DataAccessResourceChangeEvent eventData)
+ {
+ await _resourceStore.SetAsync(eventData.Resource);
+ }
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataAuthorizationService.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataAuthorizationService.cs
index cda1d8878..15e9723c7 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataAuthorizationService.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataAuthorizationService.cs
@@ -17,15 +17,15 @@ public class DataAuthorizationService : IDataAuthorizationService, ITransientDep
_entityTypeFilterBuilder = entityTypeFilterBuilder;
}
- public virtual Task AuthorizeAsync(DataAccessOperation operation, IEnumerable entities)
+ public async virtual Task AuthorizeAsync(DataAccessOperation operation, IEnumerable entities)
{
if (!entities.Any())
{
- return Task.FromResult(AuthorizationResult.Success());
+ return AuthorizationResult.Success();
}
- var exp = _entityTypeFilterBuilder.Build(operation);
+ var exp = await _entityTypeFilterBuilder.Build(operation);
- return Task.FromResult(entities.All(exp.Compile()) ? AuthorizationResult.Success() : AuthorizationResult.Failed());
+ return entities.All(exp.Compile()) ? AuthorizationResult.Success() : AuthorizationResult.Failed();
}
}
\ No newline at end of file
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataProtectedInterceptor.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataProtectedInterceptor.cs
index 850796ee4..679e43a7a 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataProtectedInterceptor.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/DataProtectedInterceptor.cs
@@ -38,6 +38,7 @@ public class DataProtectedInterceptor : AbpInterceptor, ITransientDependency
return true;
}
+ // TODO: 使用一个范围标志来确定当前需要禁用的数据权限操作
if (invocation.Method.IsDefined(typeof(DisableDataProtectedAttribute), true))
{
return true;
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/EntityPropertyResultBuilder.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/EntityPropertyResultBuilder.cs
index 31fb45cdb..8689bcd3d 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/EntityPropertyResultBuilder.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/EntityPropertyResultBuilder.cs
@@ -5,12 +5,8 @@ using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;
-using Volo.Abp;
-using Volo.Abp.Auditing;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
-using Volo.Abp.Domain.Entities;
-using Volo.Abp.MultiTenancy;
namespace LINGYUN.Abp.DataProtection;
public class EntityPropertyResultBuilder : IEntityPropertyResultBuilder, ITransientDependency
@@ -29,7 +25,7 @@ public class EntityPropertyResultBuilder : IEntityPropertyResultBuilder, ITransi
_serviceProvider = serviceProvider;
}
- public virtual LambdaExpression Build(Type entityType, DataAccessOperation operation)
+ public async virtual Task Build(Type entityType, DataAccessOperation operation)
{
// Func
var func = typeof(Func<,>).MakeGenericType(entityType, entityType);
@@ -45,18 +41,23 @@ public class EntityPropertyResultBuilder : IEntityPropertyResultBuilder, ITransi
var subjectContext = new DataAccessSubjectContributorContext(typeName, operation, _serviceProvider);
foreach (var contributor in _options.SubjectContributors)
{
- var properties = contributor.GetAllowProperties(subjectContext);
+ var properties = await contributor.GetAccessdProperties(subjectContext);
allowProperties.AddIfNotContains(properties);
}
-
- // 默认实体相关标识需要带上, 否则无法返回查询结果
- allowProperties.AddIfNotContains(_options.IgnoreAuditedProperties);
-
+
if (!allowProperties.Any())
{
return selector;
}
+ if (_options.EntityIgnoreProperties.TryGetValue(entityType, out var entityIgnoreProps))
+ {
+ allowProperties.AddIfNotContains(entityIgnoreProps);
+ }
+
+ // 默认实体相关标识需要带上, 否则无法返回查询结果
+ allowProperties.AddIfNotContains(_options.GlobalIgnoreProperties);
+
var memberBindings = new List();
foreach (var propertyName in allowProperties)
{
@@ -73,7 +74,7 @@ public class EntityPropertyResultBuilder : IEntityPropertyResultBuilder, ITransi
return Expression.Lambda(func, memberInitExpression, param);
}
- public virtual Expression> Build(DataAccessOperation operation)
+ public async virtual Task>> Build(DataAccessOperation operation)
{
var entityType = typeof(TEntity);
Expression> selector = e => e;
@@ -88,18 +89,23 @@ public class EntityPropertyResultBuilder : IEntityPropertyResultBuilder, ITransi
var subjectContext = new DataAccessSubjectContributorContext(typeName, operation, _serviceProvider);
foreach (var contributor in _options.SubjectContributors)
{
- var properties = contributor.GetAllowProperties(subjectContext);
+ var properties = await contributor.GetAccessdProperties(subjectContext);
allowProperties.AddIfNotContains(properties);
}
-
- // 默认实体相关标识需要带上, 否则无法返回查询结果
- allowProperties.AddIfNotContains(_options.IgnoreAuditedProperties);
-
+
if (!allowProperties.Any())
{
return selector;
}
+ if (_options.EntityIgnoreProperties.TryGetValue(entityType, out var entityIgnoreProps))
+ {
+ allowProperties.AddIfNotContains(entityIgnoreProps);
+ }
+
+ // 默认实体相关标识需要带上, 否则无法返回查询结果
+ allowProperties.AddIfNotContains(_options.GlobalIgnoreProperties);
+
var param = Expression.Parameter(typeof(TEntity), "e");
var memberBindings = new List();
foreach (var propertyName in allowProperties)
@@ -119,13 +125,20 @@ public class EntityPropertyResultBuilder : IEntityPropertyResultBuilder, ITransi
private bool ShouldApplyFilter(Type entityType, DataAccessOperation operation)
{
+ // TODO: 使用一个范围标志来确定当前需要禁用的数据权限操作
if (!_dataFilter.IsEnabled())
{
return false;
}
- if (entityType.IsDefined(typeof(DisableDataProtectedAttribute), true))
+ var disableAttr = entityType.GetCustomAttribute();
+ if (disableAttr != null)
{
+ if (disableAttr.Operation.HasValue && disableAttr.Operation != operation)
+ {
+ return true;
+ }
+
return false;
}
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 0d5e358ff..1351f63a1 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
@@ -7,7 +7,7 @@ using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text.Json;
-using System.Text.Json.Nodes;
+using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
@@ -30,7 +30,7 @@ public class EntityTypeFilterBuilder : IEntityTypeFilterBuilder, ITransientDepen
_serviceProvider = serviceProvider;
}
- public virtual LambdaExpression Build(Type entityType, DataAccessOperation operation, DataAccessFilterGroup group = null)
+ public async virtual Task Build(Type entityType, DataAccessOperation operation, DataAccessFilterGroup group = null)
{
// Func
var func = typeof(Func<,>).MakeGenericType(entityType, typeof(bool));
@@ -56,7 +56,7 @@ public class EntityTypeFilterBuilder : IEntityTypeFilterBuilder, ITransientDepen
var subjectContext = new DataAccessSubjectContributorContext(typeName, operation, _serviceProvider);
foreach (var contributor in _options.SubjectContributors)
{
- var subjectFilterGroup = contributor.GetFilterGroups(subjectContext);
+ var subjectFilterGroup = await contributor.GetFilterGroups(subjectContext);
subjectFilterGroups.AddRange(subjectFilterGroup);
}
@@ -87,7 +87,7 @@ public class EntityTypeFilterBuilder : IEntityTypeFilterBuilder, ITransientDepen
return exp;
}
- public virtual Expression> Build(DataAccessOperation operation, DataAccessFilterGroup group = null)
+ public async virtual Task>> Build(DataAccessOperation operation, DataAccessFilterGroup group = null)
{
var entityType = typeof(TEntity);
Expression> exp = _ => true;
@@ -107,7 +107,7 @@ public class EntityTypeFilterBuilder : IEntityTypeFilterBuilder, ITransientDepen
var subjectContext = new DataAccessSubjectContributorContext(typeName, operation, _serviceProvider);
foreach (var contributor in _options.SubjectContributors)
{
- var subjectFilterGroup = contributor.GetFilterGroups(subjectContext);
+ var subjectFilterGroup = await contributor.GetFilterGroups(subjectContext);
subjectFilterGroups.AddRange(subjectFilterGroup);
}
@@ -284,13 +284,20 @@ public class EntityTypeFilterBuilder : IEntityTypeFilterBuilder, ITransientDepen
private bool ShouldApplyFilter(Type entityType, DataAccessOperation operation)
{
+ // TODO: 使用一个范围标志来确定当前需要禁用的数据权限操作
if (!_dataFilter.IsEnabled())
{
return false;
}
- if (entityType.IsDefined(typeof(DisableDataProtectedAttribute), true))
+ var disableAttr = entityType.GetCustomAttribute();
+ if (disableAttr != null)
{
+ if (disableAttr.Operation.HasValue && disableAttr.Operation != operation)
+ {
+ return true;
+ }
+
return false;
}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataAccessEntityTypeInfoProvider.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataAccessEntityTypeInfoProvider.cs
new file mode 100644
index 000000000..1fbcfbd45
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataAccessEntityTypeInfoProvider.cs
@@ -0,0 +1,9 @@
+using LINGYUN.Abp.DataProtection.Models;
+using System.Threading.Tasks;
+
+namespace LINGYUN.Abp.DataProtection;
+
+public interface IDataAccessEntityTypeInfoProvider
+{
+ Task GetEntitTypeInfoAsync(DataAccessEntitTypeInfoContext context);
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataAccessSubjectContributor.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataAccessSubjectContributor.cs
index 828c71cba..120141ee3 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataAccessSubjectContributor.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataAccessSubjectContributor.cs
@@ -1,9 +1,10 @@
using System.Collections.Generic;
+using System.Threading.Tasks;
namespace LINGYUN.Abp.DataProtection;
public interface IDataAccessSubjectContributor
{
string Name { get; }
- List GetFilterGroups(DataAccessSubjectContributorContext context);
- List GetAllowProperties(DataAccessSubjectContributorContext context);
+ Task> GetFilterGroups(DataAccessSubjectContributorContext context);
+ Task> GetAccessdProperties(DataAccessSubjectContributorContext context);
}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataProtectedResourceStore.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataProtectedResourceStore.cs
index b047482e9..b01b4f2c1 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataProtectedResourceStore.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataProtectedResourceStore.cs
@@ -1,9 +1,11 @@
-namespace LINGYUN.Abp.DataProtection;
+using System.Threading.Tasks;
+
+namespace LINGYUN.Abp.DataProtection;
public interface IDataProtectedResourceStore
{
- void Set(DataAccessResource resource);
+ Task SetAsync(DataAccessResource resource);
- void Remove(DataAccessResource resource);
+ Task RemoveAsync(DataAccessResource resource);
- DataAccessResource Get(string subjectName, string subjectId, string entityTypeFullName, DataAccessOperation operation);
+ Task GetAsync(string subjectName, string subjectId, string entityTypeFullName, DataAccessOperation operation);
}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IEntityPropertyResultBuilder.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IEntityPropertyResultBuilder.cs
index f80a72b30..2a4e4668c 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IEntityPropertyResultBuilder.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IEntityPropertyResultBuilder.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq.Expressions;
+using System.Threading.Tasks;
namespace LINGYUN.Abp.DataProtection;
///
@@ -13,12 +14,12 @@ public interface IEntityPropertyResultBuilder
/// 实体类型
/// 数据操作方式
///
- Expression> Build(DataAccessOperation operation);
+ Task>> Build(DataAccessOperation operation);
///
/// 获取实体的属性返回值过滤表达式
///
/// 实体类型
/// 数据操作方式
///
- LambdaExpression Build(Type entityType, DataAccessOperation operation);
+ Task Build(Type entityType, DataAccessOperation operation);
}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IEntityTypeFilterBuilder.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IEntityTypeFilterBuilder.cs
index 01b54a625..897554635 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IEntityTypeFilterBuilder.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IEntityTypeFilterBuilder.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq.Expressions;
+using System.Threading.Tasks;
namespace LINGYUN.Abp.DataProtection;
///
@@ -14,7 +15,7 @@ public interface IEntityTypeFilterBuilder
/// 查询条件组
/// 实体类型
///
- Expression> Build(DataAccessOperation operation, DataAccessFilterGroup group = null);
+ Task>> Build(DataAccessOperation operation, DataAccessFilterGroup group = null);
- LambdaExpression Build(Type entityType, DataAccessOperation operation, DataAccessFilterGroup group = null);
+ Task Build(Type entityType, DataAccessOperation operation, DataAccessFilterGroup group = null);
}
\ No newline at end of file
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IJavaScriptTypeConvert.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IJavaScriptTypeConvert.cs
new file mode 100644
index 000000000..23d4866ba
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IJavaScriptTypeConvert.cs
@@ -0,0 +1,8 @@
+using System;
+
+namespace LINGYUN.Abp.DataProtection;
+
+public interface IJavaScriptTypeConvert
+{
+ JavaScriptTypeConvertResult Convert(Type propertyType);
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/InMemoryDataProtectedResourceStore.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/InMemoryDataProtectedResourceStore.cs
index 91ad394dc..39b1c3149 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/InMemoryDataProtectedResourceStore.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/InMemoryDataProtectedResourceStore.cs
@@ -1,5 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Concurrent;
+using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
namespace LINGYUN.Abp.DataProtection;
@@ -34,4 +35,23 @@ public class InMemoryDataProtectedResourceStore : IDataProtectedResourceStore
{
return $"{subjectName}_{subjectId}_{entityTypeFullName}_{operation}";
}
+
+ public Task SetAsync(DataAccessResource resource)
+ {
+ Set(resource);
+
+ return Task.CompletedTask;
+ }
+
+ public Task RemoveAsync(DataAccessResource resource)
+ {
+ Remove(resource);
+
+ return Task.CompletedTask;
+ }
+
+ public Task GetAsync(string subjectName, string subjectId, string entityTypeFullName, DataAccessOperation operation)
+ {
+ return Task.FromResult(Get(subjectName, subjectId, entityTypeFullName, operation));
+ }
}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/JavaScriptTypeConvert.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/JavaScriptTypeConvert.cs
new file mode 100644
index 000000000..f95b44fbf
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/JavaScriptTypeConvert.cs
@@ -0,0 +1,132 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using Volo.Abp.DependencyInjection;
+
+namespace LINGYUN.Abp.DataProtection;
+
+public class JavaScriptTypeConvert : IJavaScriptTypeConvert, ISingletonDependency
+{
+ public JavaScriptTypeConvertResult Convert(Type propertyType)
+ {
+ var (JavaScriptType, AccessOperates) = InnerConvert(propertyType);
+
+ return new JavaScriptTypeConvertResult(JavaScriptType, AccessOperates);
+ }
+
+ protected virtual (string JavaScriptType, DataAccessFilterOperate[] AccessFilterOperates) InnerConvert(Type propertyType)
+ {
+ var availableComparator = new List();
+ if (propertyType.IsNullableType())
+ {
+ propertyType = propertyType.GetGenericArguments().FirstOrDefault();
+ }
+
+ if (typeof(Enum).IsAssignableFrom(propertyType))
+ {
+ // 枚举类型只支持如下操作符
+ // 小于、小于等于、大于、大于等于、等于、不等于、空、非空
+ availableComparator.AddRange(new[]
+ {
+ DataAccessFilterOperate.Greater,
+ DataAccessFilterOperate.GreaterOrEqual,
+ DataAccessFilterOperate.Less,
+ DataAccessFilterOperate.LessOrEqual,
+ DataAccessFilterOperate.Equal,
+ DataAccessFilterOperate.NotEqual,
+ });
+ return ("number", availableComparator.ToArray());
+ }
+
+ var typeFullName = propertyType.FullName;
+
+ switch (typeFullName)
+ {
+ case "System.Int16":
+ case "System.Int32":
+ case "System.Int64":
+ case "System.UInt16":
+ case "System.UInt32":
+ case "System.UInt64":
+ case "System.Single":
+ case "System.Double":
+ case "System.Byte":
+ case "System.SByte":
+ case "System.Decimal":
+ // 数值类型只支持如下操作符
+ // 小于、小于等于、大于、大于等于、等于、不等于、空、非空
+ availableComparator.AddRange(new[]
+ {
+ DataAccessFilterOperate.Greater,
+ DataAccessFilterOperate.GreaterOrEqual,
+ DataAccessFilterOperate.Less,
+ DataAccessFilterOperate.LessOrEqual,
+ DataAccessFilterOperate.Equal,
+ DataAccessFilterOperate.NotEqual,
+ });
+ return ("number", availableComparator.ToArray());
+ case "System.Boolean":
+ // 布尔类型只支持如下操作符
+ // 等于、不等于、空、非空
+ availableComparator.AddRange(new[]
+ {
+ DataAccessFilterOperate.Equal,
+ DataAccessFilterOperate.NotEqual,
+ });
+ return ("boolean", availableComparator.ToArray());
+ case "System.Guid":
+ // Guid类型只支持如下操作符
+ // 等于、不等于、空、非空
+ availableComparator.AddRange(new[]
+ {
+ DataAccessFilterOperate.Equal,
+ DataAccessFilterOperate.NotEqual,
+ });
+ return ("string", availableComparator.ToArray());
+ case "System.Char":
+ case "System.String":
+ // 字符类型支持所有操作符
+ return ("string", availableComparator.ToArray());
+ case "System.DateTime":
+ // 时间类型只支持如下操作符
+ // 小于、小于等于、大于、大于等于、等于、不等于、空、非空
+ availableComparator.AddRange(new[]
+ {
+ DataAccessFilterOperate.Greater,
+ DataAccessFilterOperate.GreaterOrEqual,
+ DataAccessFilterOperate.Less,
+ DataAccessFilterOperate.LessOrEqual,
+ DataAccessFilterOperate.Equal,
+ DataAccessFilterOperate.NotEqual,
+ });
+ return ("Date", availableComparator.ToArray());
+ default:
+ case "System.Object":
+ case "System.DBNull":
+ if (propertyType.IsArray)
+ {
+ // 数组类型只支持如下操作符
+ // 包含、不包含、空、非空
+ availableComparator.AddRange(new[]
+ {
+ DataAccessFilterOperate.Contains,
+ DataAccessFilterOperate.NotContains,
+ });
+
+ return ("array", availableComparator.ToArray());
+ }
+ else
+ {
+ // 未知对象类型只支持如下操作符
+ // 等于、不等于、空、非空
+ availableComparator.AddRange(new[]
+ {
+ DataAccessFilterOperate.Equal,
+ DataAccessFilterOperate.NotEqual,
+ });
+ return ("object", availableComparator.ToArray());
+ }
+ }
+ }
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/JavaScriptTypeConvertResult.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/JavaScriptTypeConvertResult.cs
new file mode 100644
index 000000000..e93a71107
--- /dev/null
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/JavaScriptTypeConvertResult.cs
@@ -0,0 +1,12 @@
+namespace LINGYUN.Abp.DataProtection;
+
+public class JavaScriptTypeConvertResult
+{
+ public string Type { get; }
+ public DataAccessFilterOperate[] AllowOperates { get; }
+ public JavaScriptTypeConvertResult(string type, DataAccessFilterOperate[] allowOperates)
+ {
+ Type = type;
+ AllowOperates = allowOperates;
+ }
+}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessClientIdContributor.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessClientIdContributor.cs
index 2c566076d..c63992adf 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessClientIdContributor.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessClientIdContributor.cs
@@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Clients;
@@ -9,30 +10,30 @@ public class DataAccessClientIdContributor : IDataAccessSubjectContributor
{
public string Name => ClientPermissionValueProvider.ProviderName;
- public virtual List GetAllowProperties(DataAccessSubjectContributorContext context)
+ public async virtual Task> GetAccessdProperties(DataAccessSubjectContributorContext context)
{
var allowProperties = new List();
var currentClient = context.ServiceProvider.GetRequiredService();
if (currentClient.IsAuthenticated)
{
var resourceStore = context.ServiceProvider.GetRequiredService();
- var resource = resourceStore.Get(Name, currentClient.Id, context.EntityTypeFullName, context.Operation);
- if (resource?.AllowProperties.Any() == true)
+ var resource = await resourceStore.GetAsync(Name, currentClient.Id, context.EntityTypeFullName, context.Operation);
+ if (resource?.AccessedProperties.Any() == true)
{
- allowProperties.AddIfNotContains(resource.AllowProperties);
+ allowProperties.AddIfNotContains(resource.AccessedProperties);
}
}
return allowProperties;
}
- public virtual List GetFilterGroups(DataAccessSubjectContributorContext context)
+ public async virtual Task> GetFilterGroups(DataAccessSubjectContributorContext context)
{
var groups = new List();
var currentClient = context.ServiceProvider.GetRequiredService();
if (currentClient.IsAuthenticated)
{
var resourceStore = context.ServiceProvider.GetRequiredService();
- var resource = resourceStore.Get(Name, currentClient.Id, context.EntityTypeFullName, context.Operation);
+ var resource = await resourceStore.GetAsync(Name, currentClient.Id, context.EntityTypeFullName, context.Operation);
if (resource?.FilterGroup != null)
{
groups.Add(resource.FilterGroup);
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessOrganizationUnitContributor.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessOrganizationUnitContributor.cs
index 202012f76..82ecf6d81 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessOrganizationUnitContributor.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessOrganizationUnitContributor.cs
@@ -2,6 +2,7 @@
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
using Volo.Abp.Users;
namespace LINGYUN.Abp.DataProtection.Subjects;
@@ -10,7 +11,7 @@ public class DataAccessOrganizationUnitContributor : IDataAccessSubjectContribut
{
public string Name => OrganizationUnitPermissionValueProvider.ProviderName;
- public virtual List GetFilterGroups(DataAccessSubjectContributorContext context)
+ public async virtual Task> GetFilterGroups(DataAccessSubjectContributorContext context)
{
var groups = new List();
var currentUser = context.ServiceProvider.GetRequiredService();
@@ -20,7 +21,7 @@ public class DataAccessOrganizationUnitContributor : IDataAccessSubjectContribut
var orgCodes = currentUser.FindOrganizationUnits();
foreach (var orgCode in orgCodes)
{
- var resource = resourceStore.Get(Name, orgCode, context.EntityTypeFullName, context.Operation);
+ var resource = await resourceStore.GetAsync(Name, orgCode, context.EntityTypeFullName, context.Operation);
if (resource?.FilterGroup != null)
{
groups.Add(resource.FilterGroup);
@@ -30,7 +31,7 @@ public class DataAccessOrganizationUnitContributor : IDataAccessSubjectContribut
return groups;
}
- public virtual List GetAllowProperties(DataAccessSubjectContributorContext context)
+ public async virtual Task> GetAccessdProperties(DataAccessSubjectContributorContext context)
{
var allowProperties = new List();
var currentUser = context.ServiceProvider.GetRequiredService();
@@ -40,10 +41,10 @@ public class DataAccessOrganizationUnitContributor : IDataAccessSubjectContribut
var orgCodes = currentUser.FindOrganizationUnits();
foreach (var orgCode in orgCodes)
{
- var resource = resourceStore.Get(Name, orgCode, context.EntityTypeFullName, context.Operation);
- if (resource?.AllowProperties.Any() == true)
+ var resource = await resourceStore.GetAsync(Name, orgCode, context.EntityTypeFullName, context.Operation);
+ if (resource?.AccessedProperties.Any() == true)
{
- allowProperties.AddIfNotContains(resource.AllowProperties);
+ allowProperties.AddIfNotContains(resource.AccessedProperties);
}
}
}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessRoleNameContributor.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessRoleNameContributor.cs
index e2ab6e523..89712396b 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessRoleNameContributor.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessRoleNameContributor.cs
@@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Users;
@@ -10,7 +11,7 @@ public class DataAccessRoleNameContributor : IDataAccessSubjectContributor
{
public string Name => RolePermissionValueProvider.ProviderName;
- public virtual List GetFilterGroups(DataAccessSubjectContributorContext context)
+ public async virtual Task> GetFilterGroups(DataAccessSubjectContributorContext context)
{
var groups = new List();
var currentUser = context.ServiceProvider.GetRequiredService();
@@ -20,7 +21,7 @@ public class DataAccessRoleNameContributor : IDataAccessSubjectContributor
var roles = currentUser.Roles;
foreach (var role in roles)
{
- var resource = resourceStore.Get(Name, role, context.EntityTypeFullName, context.Operation);
+ var resource = await resourceStore.GetAsync(Name, role, context.EntityTypeFullName, context.Operation);
if (resource?.FilterGroup != null)
{
groups.Add(resource.FilterGroup);
@@ -30,7 +31,7 @@ public class DataAccessRoleNameContributor : IDataAccessSubjectContributor
return groups;
}
- public virtual List GetAllowProperties(DataAccessSubjectContributorContext context)
+ public async virtual Task> GetAccessdProperties(DataAccessSubjectContributorContext context)
{
var allowProperties = new List();
var currentUser = context.ServiceProvider.GetRequiredService();
@@ -40,10 +41,10 @@ public class DataAccessRoleNameContributor : IDataAccessSubjectContributor
var roles = currentUser.Roles;
foreach (var role in roles)
{
- var resource = resourceStore.Get(Name, role, context.EntityTypeFullName, context.Operation);
- if (resource?.AllowProperties.Any() == true)
+ var resource = await resourceStore.GetAsync(Name, role, context.EntityTypeFullName, context.Operation);
+ if (resource?.AccessedProperties.Any() == true)
{
- allowProperties.AddIfNotContains(resource.AllowProperties);
+ allowProperties.AddIfNotContains(resource.AccessedProperties);
}
}
}
diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessUserIdContributor.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessUserIdContributor.cs
index ff0219f53..834d682ff 100644
--- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessUserIdContributor.cs
+++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/Subjects/DataAccessUserIdContributor.cs
@@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Users;
@@ -10,14 +11,14 @@ public class DataAccessUserIdContributor : IDataAccessSubjectContributor
{
public string Name => UserPermissionValueProvider.ProviderName;
- public virtual List GetFilterGroups(DataAccessSubjectContributorContext context)
+ public async virtual Task> GetFilterGroups(DataAccessSubjectContributorContext context)
{
var groups = new List();
var currentUser = context.ServiceProvider.GetRequiredService();
if (currentUser.IsAuthenticated)
{
var resourceStore = context.ServiceProvider.GetRequiredService();
- var resource = resourceStore.Get(Name, currentUser.Id.ToString(), context.EntityTypeFullName, context.Operation);
+ var resource = await resourceStore.GetAsync(Name, currentUser.Id.ToString(), context.EntityTypeFullName, context.Operation);
if (resource?.FilterGroup != null)
{
groups.Add(resource.FilterGroup);
@@ -26,17 +27,17 @@ public class DataAccessUserIdContributor : IDataAccessSubjectContributor
return groups;
}
- public virtual List GetAllowProperties(DataAccessSubjectContributorContext context)
+ public async virtual Task> GetAccessdProperties(DataAccessSubjectContributorContext context)
{
var allowProperties = new List();
var currentUser = context.ServiceProvider.GetRequiredService();
if (currentUser.IsAuthenticated)
{
var resourceStore = context.ServiceProvider.GetRequiredService();
- var resource = resourceStore.Get(Name, currentUser.Id.ToString(), context.EntityTypeFullName, context.Operation);
- if (resource?.AllowProperties.Any() == true)
+ var resource = await resourceStore.GetAsync(Name, currentUser.Id.ToString(), context.EntityTypeFullName, context.Operation);
+ if (resource?.AccessedProperties.Any() == true)
{
- allowProperties.AddIfNotContains(resource.AllowProperties);
+ allowProperties.AddIfNotContains(resource.AccessedProperties);
}
}
return allowProperties;
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityEnumInfoDto.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityEnumInfoDto.cs
new file mode 100644
index 000000000..697b0e743
--- /dev/null
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityEnumInfoDto.cs
@@ -0,0 +1,20 @@
+using System;
+using Volo.Abp.Application.Dtos;
+
+namespace LINGYUN.Abp.DataProtectionManagement;
+
+public class EntityEnumInfoDto : EntityDto
+{
+ ///
+ /// 名称
+ ///
+ public string Name { get; set; }
+ ///
+ /// 显示名称
+ ///
+ public string DisplayName { get; set; }
+ ///
+ /// 枚举值
+ ///
+ public string Value { get; set; }
+}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityPropertyInfoDto.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityPropertyInfoDto.cs
index a5c4d7b38..f4be8a3fb 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityPropertyInfoDto.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityPropertyInfoDto.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using Volo.Abp.Application.Dtos;
namespace LINGYUN.Abp.DataProtectionManagement;
@@ -17,7 +18,11 @@ public class EntityPropertyInfoDto : EntityDto
///
public string TypeFullName { get; set; }
///
- /// 数据值范围集合(主要针对枚举类型)
+ /// Js类型
///
- public string[] ValueRange { get; set; }
+ public string JavaScriptType { get; set; }
+ ///
+ /// 枚举列表
+ ///
+ public virtual List Enums { get; set; } = new List();
}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityRuleCreateOrUpdateDto.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityRuleCreateOrUpdateDto.cs
index c5c60a281..71ad9a999 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityRuleCreateOrUpdateDto.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityRuleCreateOrUpdateDto.cs
@@ -13,5 +13,5 @@ public abstract class EntityRuleCreateOrUpdateDto
[Required]
public DataAccessFilterGroup FilterGroup { get; set; }
- public string[] AllowProperties { get; set; }
+ public string[] AccessedProperties { get; set; }
}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityRuleDtoBase.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityRuleDtoBase.cs
index ee4262f48..5450858a3 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityRuleDtoBase.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application.Contracts/LINGYUN/Abp/DataProtectionManagement/Dto/EntityRuleDtoBase.cs
@@ -11,5 +11,5 @@ public abstract class EntityRuleDtoBase : AuditedEntityDto
public DataAccessFilterGroup FilterGroup { get; set; }
public Guid EntityTypeId { get; set; }
public string EntityTypeFullName { get; set; }
- public string[] AllowProperties { get; set; }
+ public string[] AccessedProperties { get; set; }
}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application/LINGYUN/Abp/DataProtectionManagement/DataProtectionManagementApplicationMappingProfile.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application/LINGYUN/Abp/DataProtectionManagement/DataProtectionManagementApplicationMappingProfile.cs
index 84efe897e..36a1b6f06 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application/LINGYUN/Abp/DataProtectionManagement/DataProtectionManagementApplicationMappingProfile.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application/LINGYUN/Abp/DataProtectionManagement/DataProtectionManagementApplicationMappingProfile.cs
@@ -7,13 +7,13 @@ public class DataProtectionManagementApplicationMappingProfile :Profile
{
public DataProtectionManagementApplicationMappingProfile()
{
- CreateMap()
- .ForMember(dto => dto.ValueRange, map => map.MapFrom(src => MapToArray(src.ValueRange)));
+ CreateMap();
+ CreateMap();
CreateMap();
CreateMap()
- .ForMember(dto => dto.AllowProperties, map => map.MapFrom(src => MapToArray(src.AllowProperties)));
+ .ForMember(dto => dto.AccessedProperties, map => map.MapFrom(src => MapToArray(src.AccessedProperties)));
CreateMap()
- .ForMember(dto => dto.AllowProperties, map => map.MapFrom(src => MapToArray(src.AllowProperties)));
+ .ForMember(dto => dto.AccessedProperties, map => map.MapFrom(src => MapToArray(src.AccessedProperties)));
}
private string[] MapToArray(string val)
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application/LINGYUN/Abp/DataProtectionManagement/OrganizationUnitEntityRuleAppService.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application/LINGYUN/Abp/DataProtectionManagement/OrganizationUnitEntityRuleAppService.cs
index ef4d5cab8..7dca87e83 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application/LINGYUN/Abp/DataProtectionManagement/OrganizationUnitEntityRuleAppService.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application/LINGYUN/Abp/DataProtectionManagement/OrganizationUnitEntityRuleAppService.cs
@@ -1,15 +1,21 @@
-using LINGYUN.Abp.DataProtectionManagement.Permissions;
+using LINGYUN.Abp.Authorization.Permissions;
+using LINGYUN.Abp.DataProtection;
+using LINGYUN.Abp.DataProtectionManagement.Permissions;
using Microsoft.AspNetCore.Authorization;
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Threading.Tasks;
using Volo.Abp;
+using Volo.Abp.EventBus.Distributed;
namespace LINGYUN.Abp.DataProtectionManagement;
[Authorize(DataProtectionManagementPermissionNames.OrganizationUnitEntityRule.Default)]
public class OrganizationUnitEntityRuleAppService : DataProtectionManagementApplicationServiceBase, IOrganizationUnitEntityRuleAppService
{
+ protected IDistributedEventBus EventBus => LazyServiceProvider.LazyGetRequiredService();
+
private readonly IEntityTypeInfoRepository _entityTypeInfoRepository;
private readonly IOrganizationUnitEntityRuleRepository _organizationUnitEntityRuleRepository;
@@ -47,7 +53,7 @@ public class OrganizationUnitEntityRuleAppService : DataProtectionManagementAppl
entityTypeInfo.Id,
entityTypeInfo.TypeFullName,
input.Operation,
- input.AllowProperties?.JoinAsString(","),
+ input.AccessedProperties?.JoinAsString(","),
input.FilterGroup,
CurrentTenant.Id)
{
@@ -56,6 +62,18 @@ public class OrganizationUnitEntityRuleAppService : DataProtectionManagementAppl
entityRule = await _organizationUnitEntityRuleRepository.InsertAsync(entityRule);
+ await EventBus.PublishAsync(
+ new DataAccessResourceChangeEvent(
+ new DataAccessResource(
+ OrganizationUnitPermissionValueProvider.ProviderName,
+ entityRule.OrgCode,
+ entityRule.EntityTypeFullName,
+ entityRule.Operation,
+ entityRule.FilterGroup)
+ {
+ AccessedProperties = input.AccessedProperties.ToList()
+ }));
+
await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map(entityRule);
@@ -73,15 +91,27 @@ public class OrganizationUnitEntityRuleAppService : DataProtectionManagementAppl
{
entityRule.Operation = input.Operation;
}
- var allowPropertites = input.AllowProperties?.JoinAsString(",");
- if (!string.Equals(entityRule.AllowProperties, allowPropertites, StringComparison.InvariantCultureIgnoreCase))
+ var allowPropertites = input.AccessedProperties?.JoinAsString(",");
+ if (!string.Equals(entityRule.AccessedProperties, allowPropertites, StringComparison.InvariantCultureIgnoreCase))
{
- entityRule.AllowProperties = allowPropertites;
+ entityRule.AccessedProperties = allowPropertites;
}
entityRule.FilterGroup = input.FilterGroup;
entityRule = await _organizationUnitEntityRuleRepository.UpdateAsync(entityRule);
+ await EventBus.PublishAsync(
+ new DataAccessResourceChangeEvent(
+ new DataAccessResource(
+ OrganizationUnitPermissionValueProvider.ProviderName,
+ entityRule.OrgCode,
+ entityRule.EntityTypeFullName,
+ entityRule.Operation,
+ entityRule.FilterGroup)
+ {
+ AccessedProperties = input.AccessedProperties.ToList()
+ }));
+
await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map(entityRule);
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application/LINGYUN/Abp/DataProtectionManagement/RoleEntityRuleAppService.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application/LINGYUN/Abp/DataProtectionManagement/RoleEntityRuleAppService.cs
index f77ce9ef4..0ff1a0f77 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application/LINGYUN/Abp/DataProtectionManagement/RoleEntityRuleAppService.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Application/LINGYUN/Abp/DataProtectionManagement/RoleEntityRuleAppService.cs
@@ -1,15 +1,21 @@
-using LINGYUN.Abp.DataProtectionManagement.Permissions;
+using LINGYUN.Abp.DataProtection;
+using LINGYUN.Abp.DataProtectionManagement.Permissions;
using Microsoft.AspNetCore.Authorization;
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Threading.Tasks;
using Volo.Abp;
+using Volo.Abp.Authorization.Permissions;
+using Volo.Abp.EventBus.Distributed;
namespace LINGYUN.Abp.DataProtectionManagement;
[Authorize(DataProtectionManagementPermissionNames.RoleEntityRule.Default)]
public class RoleEntityRuleAppService : DataProtectionManagementApplicationServiceBase, IRoleEntityRuleAppService
{
+ protected IDistributedEventBus EventBus => LazyServiceProvider.LazyGetRequiredService();
+
private readonly IEntityTypeInfoRepository _entityTypeInfoRepository;
private readonly IRoleEntityRuleRepository _roleEntityRuleRepository;
@@ -47,7 +53,7 @@ public class RoleEntityRuleAppService : DataProtectionManagementApplicationServi
entityTypeInfo.Id,
entityTypeInfo.TypeFullName,
input.Operation,
- input.AllowProperties?.JoinAsString(","),
+ input.AccessedProperties?.JoinAsString(","),
input.FilterGroup,
CurrentTenant.Id)
{
@@ -56,6 +62,18 @@ public class RoleEntityRuleAppService : DataProtectionManagementApplicationServi
entityRule = await _roleEntityRuleRepository.InsertAsync(entityRule);
+ await EventBus.PublishAsync(
+ new DataAccessResourceChangeEvent(
+ new DataAccessResource(
+ RolePermissionValueProvider.ProviderName,
+ entityRule.RoleName,
+ entityRule.EntityTypeFullName,
+ entityRule.Operation,
+ entityRule.FilterGroup)
+ {
+ AccessedProperties = input.AccessedProperties?.ToList()
+ }));
+
await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map(entityRule);
@@ -73,16 +91,28 @@ public class RoleEntityRuleAppService : DataProtectionManagementApplicationServi
{
entityRule.Operation = input.Operation;
}
- var allowPropertites = input.AllowProperties?.JoinAsString(",");
- if (!string.Equals(entityRule.AllowProperties, allowPropertites, StringComparison.InvariantCultureIgnoreCase))
+ var allowPropertites = input.AccessedProperties?.JoinAsString(",");
+ if (!string.Equals(entityRule.AccessedProperties, allowPropertites, StringComparison.InvariantCultureIgnoreCase))
{
- entityRule.AllowProperties = allowPropertites;
+ entityRule.AccessedProperties = allowPropertites;
}
entityRule.FilterGroup = input.FilterGroup;
entityRule = await _roleEntityRuleRepository.UpdateAsync(entityRule);
+ await EventBus.PublishAsync(
+ new DataAccessResourceChangeEvent(
+ new DataAccessResource(
+ RolePermissionValueProvider.ProviderName,
+ entityRule.RoleName,
+ entityRule.EntityTypeFullName,
+ entityRule.Operation,
+ entityRule.FilterGroup)
+ {
+ AccessedProperties = input.AccessedProperties?.ToList()
+ }));
+
await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map(entityRule);
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/DataProtectionManagementErrorCodes.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/DataProtectionManagementErrorCodes.cs
index 1f57aba4b..37fde4e91 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/DataProtectionManagementErrorCodes.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/DataProtectionManagementErrorCodes.cs
@@ -15,6 +15,10 @@ public static class DataProtectionManagementErrorCodes
/// 实体类型已经存在名为 {Name} 的属性定义
///
public const string DuplicateProperty = Prefix + "200";
+ ///
+ /// 实体属性已经存在名为 {Name} 的枚举定义
+ ///
+ public const string DuplicateEnum = Prefix + "300";
}
public static class RoleEntityRule
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/EntityEnumInfoConsts.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/EntityEnumInfoConsts.cs
new file mode 100644
index 000000000..5d790ff84
--- /dev/null
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/EntityEnumInfoConsts.cs
@@ -0,0 +1,8 @@
+namespace LINGYUN.Abp.DataProtectionManagement;
+
+public static class EntityEnumInfoConsts
+{
+ public static int MaxNameLength { get; set; } = EntityTypeInfoConsts.MaxNameLength;
+ public static int MaxDisplayNameLength { get; set; } = EntityTypeInfoConsts.MaxDisplayNameLength;
+ public static int MaxValueLength { get; set; } = 10;
+}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/EntityRuleBaseEto.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/EntityRuleBaseEto.cs
index f376ea22f..55cc6e75b 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/EntityRuleBaseEto.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/EntityRuleBaseEto.cs
@@ -13,4 +13,5 @@ public abstract class EntityRuleBaseEto : EntityEto, IMultiTenant
public DataAccessOperation Operation { get; set; }
public Guid EntityTypeId { get; set; }
public string EntityTypeFullName { get; set; }
+ public DataAccessFilterGroup FilterGroup { get; set; }
}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/EntityRuleConsts.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/EntityRuleConsts.cs
index 4d73ae535..876c36c46 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/EntityRuleConsts.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain.Shared/LINGYUN/Abp/DataProtectionManagement/EntityRuleConsts.cs
@@ -2,5 +2,5 @@
public static class EntityRuleConsts
{
public static int MaxEntityTypeFullNameLength { get; set; } = EntityPropertyInfoConsts.MaxTypeFullNameLength;
- public static int MaxAllowPropertiesLength { get; set; } = 512;
+ public static int MaxAccessedPropertiesLength { get; set; } = 512;
}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/AbpDataProtectionManagementDomainModule.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/AbpDataProtectionManagementDomainModule.cs
index 3691baad5..56c61eeed 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/AbpDataProtectionManagementDomainModule.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/AbpDataProtectionManagementDomainModule.cs
@@ -37,11 +37,6 @@ public class AbpDataProtectionManagementDomainModule : AbpModule
options.AutoEventSelectors.Add();
});
- Configure(options =>
- {
- options.ConfigureCache(new DistributedCacheEntryOptions());
- });
-
context.Services.AddHostedService();
}
}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCache.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCache.cs
index baf04fd94..56782fc79 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCache.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCache.cs
@@ -1,4 +1,6 @@
using LINGYUN.Abp.DataProtection;
+using Microsoft.Extensions.Caching.Distributed;
+using System.Threading.Tasks;
using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
@@ -19,12 +21,25 @@ public class DataProtectedResourceCache : IDataProtectedResourceCache, ITransien
return cacheItem;
}
+ public async virtual Task GetCacheAsync(string subjectName, string subjectId, string entityTypeFullName, DataAccessOperation operation)
+ {
+ var cacheKey = DataProtectedResourceCacheItem.CalculateCacheKey(subjectName, subjectId, entityTypeFullName, operation);
+ var cacheItem = await _cache.GetAsync(cacheKey);
+ return cacheItem;
+ }
+
public virtual void RemoveCache(DataAccessResource resource)
{
var cacheKey = DataProtectedResourceCacheItem.CalculateCacheKey(resource.SubjectName, resource.SubjectId, resource.EntityTypeFullName, resource.Operation);
_cache.Remove(cacheKey);
}
+ public async Task RemoveCacheAsync(DataAccessResource resource)
+ {
+ var cacheKey = DataProtectedResourceCacheItem.CalculateCacheKey(resource.SubjectName, resource.SubjectId, resource.EntityTypeFullName, resource.Operation);
+ await _cache.RemoveAsync(cacheKey);
+ }
+
public virtual void SetCache(DataAccessResource resource)
{
var cacheKey = DataProtectedResourceCacheItem.CalculateCacheKey(resource.SubjectName, resource.SubjectId, resource.EntityTypeFullName, resource.Operation);
@@ -35,8 +50,23 @@ public class DataProtectedResourceCache : IDataProtectedResourceCache, ITransien
resource.Operation,
resource.FilterGroup)
{
- AllowProperties = resource.AllowProperties,
+ AccessdProperties = resource.AccessedProperties,
+ };
+ _cache.Set(cacheKey, cacheItem, new DistributedCacheEntryOptions());
+ }
+
+ public async virtual Task SetCacheAsync(DataAccessResource resource)
+ {
+ var cacheKey = DataProtectedResourceCacheItem.CalculateCacheKey(resource.SubjectName, resource.SubjectId, resource.EntityTypeFullName, resource.Operation);
+ var cacheItem = new DataProtectedResourceCacheItem(
+ resource.SubjectName,
+ resource.SubjectId,
+ resource.EntityTypeFullName,
+ resource.Operation,
+ resource.FilterGroup)
+ {
+ AccessdProperties = resource.AccessedProperties,
};
- _cache.Set(cacheKey, cacheItem);
+ await _cache.SetAsync(cacheKey, cacheItem, new DistributedCacheEntryOptions());
}
}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCacheItem.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCacheItem.cs
index 78c358951..925b0610a 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCacheItem.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCacheItem.cs
@@ -36,7 +36,11 @@ public class DataProtectedResourceCacheItem
///
/// 允许操作的属性列表
///
- public List AllowProperties { get; set; }
+ public List AccessdProperties { get; set; }
+ public DataProtectedResourceCacheItem()
+ {
+
+ }
public DataProtectedResourceCacheItem(
string subjectName,
@@ -50,7 +54,7 @@ public class DataProtectedResourceCacheItem
EntityTypeFullName = entityTypeFullName;
Operation = operation;
FilterGroup = filterGroup;
- AllowProperties = new List();
+ AccessdProperties = new List();
}
public static string CalculateCacheKey(string subjectName, string subjectId, string entityTypeFullName, DataAccessOperation operation = DataAccessOperation.Read)
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCacheItemInvalidator.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCacheItemInvalidator.cs
deleted file mode 100644
index bfc205348..000000000
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCacheItemInvalidator.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using LINGYUN.Abp.Authorization.Permissions;
-using LINGYUN.Abp.DataProtection;
-using System.Linq;
-using System.Threading.Tasks;
-using Volo.Abp.Authorization.Permissions;
-using Volo.Abp.DependencyInjection;
-using Volo.Abp.Domain.Entities.Events;
-using Volo.Abp.EventBus;
-
-namespace LINGYUN.Abp.DataProtectionManagement;
-public class DataProtectedResourceCacheItemInvalidator :
- ILocalEventHandler>,
- ILocalEventHandler>,
- ITransientDependency
-{
- private readonly IDataProtectedResourceCache _resourceCache;
-
- public DataProtectedResourceCacheItemInvalidator(IDataProtectedResourceCache resourceCache)
- {
- _resourceCache = resourceCache;
- }
-
- public virtual Task HandleEventAsync(EntityChangedEventData eventData)
- {
- var dataResource = new DataAccessResource(
- RolePermissionValueProvider.ProviderName,
- eventData.Entity.RoleName,
- eventData.Entity.EntityTypeFullName,
- eventData.Entity.Operation,
- eventData.Entity.FilterGroup)
- {
- AllowProperties = eventData.Entity.AllowProperties?.Split(",").ToList(),
- };
-
- _resourceCache.SetCache(dataResource);
-
- return Task.CompletedTask;
- }
-
- public virtual Task HandleEventAsync(EntityChangedEventData eventData)
- {
- var dataResource = new DataAccessResource(
- OrganizationUnitPermissionValueProvider.ProviderName,
- eventData.Entity.OrgCode,
- eventData.Entity.EntityTypeFullName,
- eventData.Entity.Operation,
- eventData.Entity.FilterGroup)
- {
- AllowProperties = eventData.Entity.AllowProperties?.Split(",").ToList(),
- };
-
- _resourceCache.SetCache(dataResource);
-
- return Task.CompletedTask;
- }
-}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCacheStore.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCacheStore.cs
index b688a3a61..1e1a87eec 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCacheStore.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/DataProtectedResourceCacheStore.cs
@@ -1,5 +1,6 @@
using LINGYUN.Abp.DataProtection;
using Microsoft.Extensions.DependencyInjection;
+using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
namespace LINGYUN.Abp.DataProtectionManagement;
@@ -15,7 +16,7 @@ public class DataProtectedResourceCacheStore : IDataProtectedResourceStore, ITra
_cache = cache;
}
- public DataAccessResource Get(string subjectName, string subjectId, string entityTypeFullName, DataAccessOperation operation)
+ public virtual DataAccessResource Get(string subjectName, string subjectId, string entityTypeFullName, DataAccessOperation operation)
{
var cacheItem = _cache.GetCache(subjectName, subjectId, entityTypeFullName, operation);
if (cacheItem == null)
@@ -29,17 +30,45 @@ public class DataProtectedResourceCacheStore : IDataProtectedResourceStore, ITra
cacheItem.Operation,
cacheItem.FilterGroup)
{
- AllowProperties = cacheItem.AllowProperties,
+ AccessedProperties = cacheItem.AccessdProperties,
};
}
- public void Remove(DataAccessResource resource)
+ public async virtual Task GetAsync(string subjectName, string subjectId, string entityTypeFullName, DataAccessOperation operation)
+ {
+ var cacheItem = await _cache.GetCacheAsync(subjectName, subjectId, entityTypeFullName, operation);
+ if (cacheItem == null)
+ {
+ return null;
+ }
+ return new DataAccessResource(
+ cacheItem.SubjectName,
+ cacheItem.SubjectId,
+ cacheItem.EntityTypeFullName,
+ cacheItem.Operation,
+ cacheItem.FilterGroup)
+ {
+ AccessedProperties = cacheItem.AccessdProperties,
+ };
+ }
+
+ public virtual void Remove(DataAccessResource resource)
{
_cache.RemoveCache(resource);
}
+ public async virtual Task RemoveAsync(DataAccessResource resource)
+ {
+ await _cache.RemoveCacheAsync(resource);
+ }
+
public void Set(DataAccessResource resource)
{
_cache.SetCache(resource);
}
+
+ public async virtual Task SetAsync(DataAccessResource resource)
+ {
+ await _cache.SetCacheAsync(resource);
+ }
}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityEnumInfo.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityEnumInfo.cs
new file mode 100644
index 000000000..69f2cd80a
--- /dev/null
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityEnumInfo.cs
@@ -0,0 +1,47 @@
+using System;
+using Volo.Abp;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.Abp.DataProtectionManagement;
+
+public class EntityEnumInfo : Entity
+{
+ ///
+ /// 名称
+ ///
+ public virtual string Name { get; protected set; }
+ ///
+ /// 显示名称
+ ///
+ public virtual string DisplayName { get; protected set; }
+ ///
+ /// 枚举值
+ ///
+ public virtual string Value { get; protected set; }
+ ///
+ /// 所属属性
+ ///
+ public virtual EntityPropertyInfo PropertyInfo { get; protected set; }
+ ///
+ /// 所属属性标识
+ ///
+ public virtual Guid PropertyInfoId { get; protected set; }
+ protected EntityEnumInfo()
+ {
+
+ }
+
+ public EntityEnumInfo(
+ Guid id,
+ Guid propertyInfoId,
+ string name,
+ string displayName,
+ string value)
+ : base(id)
+ {
+ PropertyInfoId = propertyInfoId;
+ Name = Check.NotNullOrWhiteSpace(name, nameof(name), EntityEnumInfoConsts.MaxNameLength);
+ DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), EntityEnumInfoConsts.MaxDisplayNameLength);
+ Value = Check.NotNullOrWhiteSpace(value, nameof(value), EntityEnumInfoConsts.MaxValueLength);
+ }
+}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityPropertyInfo.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityPropertyInfo.cs
index d8f1f6c9a..b931b01f5 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityPropertyInfo.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityPropertyInfo.cs
@@ -1,6 +1,10 @@
using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
+using Volo.Abp.Guids;
namespace LINGYUN.Abp.DataProtectionManagement;
@@ -19,9 +23,9 @@ public class EntityPropertyInfo : Entity
///
public virtual string TypeFullName { get; protected set; }
///
- /// 数据值范围集合(主要针对枚举类型)
+ /// Js类型
///
- public virtual string ValueRange { get; protected set; }
+ public virtual string JavaScriptType { get; protected set; }
///
/// 所属类型
///
@@ -30,9 +34,14 @@ public class EntityPropertyInfo : Entity
/// 所属类型标识
///
public virtual Guid TypeInfoId { get; protected set; }
+ ///
+ /// 枚举列表
+ ///
+ public virtual ICollection Enums { get; protected set; }
protected EntityPropertyInfo()
{
+ Enums = new Collection();
}
public EntityPropertyInfo(
@@ -41,13 +50,54 @@ public class EntityPropertyInfo : Entity
string name,
string displayName,
string typeFullName,
- string valueRange = null)
+ string javaScriptType)
: base(id)
{
Name = Check.NotNullOrWhiteSpace(name, nameof(name), EntityPropertyInfoConsts.MaxNameLength);
DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), EntityPropertyInfoConsts.MaxDisplayNameLength);
TypeFullName = Check.NotNullOrWhiteSpace(typeFullName, nameof(typeFullName), EntityPropertyInfoConsts.MaxTypeFullNameLength);
- ValueRange = Check.Length(valueRange, nameof(valueRange), EntityPropertyInfoConsts.MaxValueRangeLength);
+ JavaScriptType = Check.NotNullOrWhiteSpace(javaScriptType, nameof(javaScriptType), EntityPropertyInfoConsts.MaxTypeFullNameLength);
TypeInfoId = typeInfoId;
+
+ Enums = new Collection();
+ }
+
+ public EntityEnumInfo FindEnum(string name)
+ {
+ return Enums.FirstOrDefault(x => x.Name == name);
+ }
+
+ public void RemoveEnum(string name)
+ {
+ Enums.RemoveAll(x => x.Name == name);
+ }
+
+ public EntityEnumInfo AddEnum(
+ IGuidGenerator guidGenerator,
+ string name,
+ string displayName,
+ string value)
+ {
+ if (HasExistsEnum(name))
+ {
+ throw new BusinessException(DataProtectionManagementErrorCodes.EntityTypeInfo.DuplicateEnum)
+ .WithData(nameof(EntityEnumInfo.Name), name);
+ }
+
+ var enumInfo = new EntityEnumInfo(
+ guidGenerator.Create(),
+ Id,
+ name,
+ displayName,
+ value);
+
+ Enums.Add(enumInfo);
+
+ return enumInfo;
+ }
+
+ public bool HasExistsEnum(string name)
+ {
+ return Enums.Any(x => x.Name == name);
}
}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityRuleBase.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityRuleBase.cs
index bd22f09cb..b6df5c821 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityRuleBase.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityRuleBase.cs
@@ -14,7 +14,7 @@ public abstract class EntityRuleBase : AuditedAggregateRoot, IMultiTenant
public virtual Guid EntityTypeId { get; protected set; }
public virtual string EntityTypeFullName { get; protected set; }
public virtual EntityTypeInfo EntityTypeInfo { get; protected set; }
- public virtual string AllowProperties { get; set; }
+ public virtual string AccessedProperties { get; set; }
protected EntityRuleBase()
{
}
@@ -24,7 +24,7 @@ public abstract class EntityRuleBase : AuditedAggregateRoot, IMultiTenant
Guid entityTypeId,
string enetityTypeFullName,
DataAccessOperation operation,
- string allowProperties = null,
+ string accessedProperties = null,
DataAccessFilterGroup filterGroup = null,
Guid? tenantId = null)
: base(id)
@@ -35,7 +35,7 @@ public abstract class EntityRuleBase : AuditedAggregateRoot, IMultiTenant
EntityTypeId = entityTypeId;
EntityTypeFullName = Check.NotNullOrWhiteSpace(enetityTypeFullName, nameof(enetityTypeFullName), EntityRuleConsts.MaxEntityTypeFullNameLength);
- AllowProperties = Check.Length(allowProperties, nameof(allowProperties), EntityRuleConsts.MaxAllowPropertiesLength);
+ AccessedProperties = Check.Length(accessedProperties, nameof(accessedProperties), EntityRuleConsts.MaxAccessedPropertiesLength);
}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityTypeInfo.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityTypeInfo.cs
index 18d38c3bc..d4b5cb230 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityTypeInfo.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/EntityTypeInfo.cs
@@ -64,7 +64,7 @@ public class EntityTypeInfo : AuditedAggregateRoot
string name,
string displayName,
string typeFullName,
- string valueRange = null)
+ string javaScriptType)
{
if (HasExistsProperty(name))
{
@@ -78,7 +78,7 @@ public class EntityTypeInfo : AuditedAggregateRoot
name,
displayName,
typeFullName,
- valueRange);
+ javaScriptType);
Properties.Add(propertyInfo);
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/IDataProtectedResourceCache.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/IDataProtectedResourceCache.cs
index 3469ceadd..2aeaf6c41 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/IDataProtectedResourceCache.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/IDataProtectedResourceCache.cs
@@ -1,4 +1,5 @@
using LINGYUN.Abp.DataProtection;
+using System.Threading.Tasks;
namespace LINGYUN.Abp.DataProtectionManagement;
public interface IDataProtectedResourceCache
@@ -9,11 +10,21 @@ public interface IDataProtectedResourceCache
/// 要更新的数据权限缓存项
void SetCache(DataAccessResource resource);
///
+ /// 设置指定数据权限的缓存
+ ///
+ /// 要更新的数据权限缓存项
+ Task SetCacheAsync(DataAccessResource resource);
+ ///
/// 移除指定主体与实体类型的缓存项
///
/// 要移除的数据权限缓存项信息
void RemoveCache(DataAccessResource resource);
///
+ /// 移除指定主体与实体类型的缓存项
+ ///
+ /// 要移除的数据权限缓存项信息
+ Task RemoveCacheAsync(DataAccessResource resource);
+ ///
/// 获取指定主体与实体类型的数据权限过滤规则
///
/// 权限主体
@@ -22,4 +33,13 @@ public interface IDataProtectedResourceCache
/// 数据权限操作
/// 数据过滤条件组
DataProtectedResourceCacheItem GetCache(string subjectName, string subjectId, string entityTypeFullName, DataAccessOperation operation);
+ ///
+ /// 获取指定主体与实体类型的数据权限过滤规则
+ ///
+ /// 权限主体
+ /// 权限主体标识
+ /// 实体类型名称
+ /// 数据权限操作
+ /// 数据过滤条件组
+ Task GetCacheAsync(string subjectName, string subjectId, string entityTypeFullName, DataAccessOperation operation);
}
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/ProtectedEntitiesSaver.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/ProtectedEntitiesSaver.cs
index a95b4825c..a97728a7f 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/ProtectedEntitiesSaver.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.Domain/LINGYUN/Abp/DataProtectionManagement/ProtectedEntitiesSaver.cs
@@ -24,6 +24,7 @@ public class ProtectedEntitiesSaver : IProtectedEntitiesSaver, ITransientDepende
protected DataProtectionManagementOptions ManagementOptions { get; }
protected IGuidGenerator GuidGenerator { get; }
protected IAbpDistributedLock DistributedLock { get; }
+ protected IJavaScriptTypeConvert JavaScriptTypeConvert { get; }
protected IEntityTypeInfoRepository EntityTypeInfoRepository { get; }
protected ILocalizableStringSerializer LocalizableStringSerializer { get; }
@@ -33,7 +34,8 @@ public class ProtectedEntitiesSaver : IProtectedEntitiesSaver, ITransientDepende
IOptions options,
IOptions managementOptions,
IGuidGenerator guidGenerator,
- IAbpDistributedLock distributedLock,
+ IAbpDistributedLock distributedLock,
+ IJavaScriptTypeConvert javaScriptTypeConvert,
IEntityTypeInfoRepository entityTypeInfoRepository,
ILocalizableStringSerializer localizableStringSerializer)
{
@@ -43,6 +45,7 @@ public class ProtectedEntitiesSaver : IProtectedEntitiesSaver, ITransientDepende
ManagementOptions = managementOptions.Value;
GuidGenerator = guidGenerator;
DistributedLock = distributedLock;
+ JavaScriptTypeConvert = javaScriptTypeConvert;
EntityTypeInfoRepository = entityTypeInfoRepository;
LocalizableStringSerializer = localizableStringSerializer;
}
@@ -81,7 +84,8 @@ public class ProtectedEntitiesSaver : IProtectedEntitiesSaver, ITransientDepende
var typeDisplayName = entityType.GetCustomAttribute()?.DisplayName;
if (typeDisplayName.IsNullOrWhiteSpace())
{
- var typeDisplayNameString = LocalizableString.Create($"DisplayName:{entityType.Name}", resourceName);
+ // 类型多语言表现形式为:LocalizationResource.TypeName
+ var typeDisplayNameString = LocalizableString.Create(entityType.Name, resourceName);
typeDisplayName = LocalizableStringSerializer.Serialize(typeDisplayNameString);
}
var isDataAudited = entityType.GetCustomAttribute() == null;
@@ -92,39 +96,65 @@ public class ProtectedEntitiesSaver : IProtectedEntitiesSaver, ITransientDepende
entityType.FullName,
isDataAudited);
+ var globalIgnoreProperties = Options.GlobalIgnoreProperties.Except(Options.AuditedObjectProperties);
+
var typeProperties = entityType.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty)
- .Where(x => !Options.IgnoreAuditedProperties.Contains(x.Name));
+ .Where(x => !globalIgnoreProperties.Contains(x.Name));
foreach (var typeProperty in typeProperties)
{
var propDisplayName = typeProperty.GetCustomAttribute()?.DisplayName;
if (propDisplayName.IsNullOrWhiteSpace())
{
- var propDisplayNameString = LocalizableString.Create($"DisplayName:{entityType.Name}", resourceName);
+ // 属性多语言表现形式为:LocalizationResource.DisplayName:PropertyName
+ var propDisplayNameString = LocalizableString.Create($"DisplayName:{typeProperty.Name}", resourceName);
propDisplayName = LocalizableStringSerializer.Serialize(propDisplayNameString);
}
- var propTypeFullName = typeProperty.PropertyType.FullName;
- string valueRange = null;
- if (typeProperty.PropertyType.IsEnum)
- {
- propTypeFullName = typeof(int).FullName;
- var enumType = typeProperty.PropertyType;
- var enumValues = enumType.GetEnumValues().Cast();
- valueRange = enumValues.JoinAsString(",");
- }
- entityTypeInfo.AddProperty(
+
+ var javaScriptTypeResult = JavaScriptTypeConvert.Convert(typeProperty.PropertyType);
+
+ var propertyInfo = entityTypeInfo.AddProperty(
GuidGenerator,
typeProperty.Name,
propDisplayName ?? typeProperty.Name,
typeProperty.PropertyType.FullName,
- valueRange);
+ javaScriptTypeResult.Type);
+
+ if (typeProperty.PropertyType.IsEnum)
+ {
+ var enumType = typeProperty.PropertyType;
+
+ var enumNames = enumType.GetEnumNames();
+ var enumValues = enumType.GetEnumValues().Cast().ToArray();
+
+ for (var index = 0; index < enumNames.Length; index++)
+ {
+ var enumName = enumNames[index];
+ var enumValue = enumValues[index];
+ var localizerEnumKey = $"{propertyInfo.Name}:{enumName}";
+
+ // 枚举多语言表现形式为:LocalizationResource.EnumName:EnumValue
+ var enumDisplayNameString = LocalizableString.Create($"{enumType.Name}:{enumName}", resourceName);
+ var enumDisplayName = LocalizableStringSerializer.Serialize(enumDisplayNameString);
+
+ propertyInfo.AddEnum(
+ GuidGenerator,
+ enumName,
+ enumDisplayName,
+ enumValue.ToString());
+ }
+ }
}
newRecords.Add(entityTypeInfo);
}
else
{
var hasChanged = false;
+
+ var globalIgnoreProperties = Options.GlobalIgnoreProperties.Except(Options.AuditedObjectProperties);
+
var typeProperties = entityType.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty)
- .Where(x => !Options.IgnoreAuditedProperties.Contains(x.Name));
+ .Where(x => !globalIgnoreProperties.Contains(x.Name));
+
entityTypeInfo.Properties.RemoveAll(x => !typeProperties.Any(p => p.Name == x.Name));
foreach (var typeProperty in typeProperties)
{
@@ -134,24 +164,42 @@ public class ProtectedEntitiesSaver : IProtectedEntitiesSaver, ITransientDepende
var propDisplayName = typeProperty.GetCustomAttribute()?.DisplayName;
if (propDisplayName.IsNullOrWhiteSpace())
{
+ // 属性多语言表现形式为:LocalizationResource.DisplayName:PropertyName
var propDisplayNameString = LocalizableString.Create($"DisplayName:{typeProperty.Name}", resourceName);
propDisplayName = LocalizableStringSerializer.Serialize(propDisplayNameString);
}
- var propTypeFullName = typeProperty.PropertyType.FullName;
- string valueRange = null;
+ var javaScriptTypeResult = JavaScriptTypeConvert.Convert(typeProperty.PropertyType);
+ var propertyInfo = entityTypeInfo.AddProperty(
+ GuidGenerator,
+ typeProperty.Name,
+ propDisplayName ?? typeProperty.Name,
+ typeProperty.PropertyType.FullName,
+ javaScriptTypeResult.Type);
+
if (typeProperty.PropertyType.IsEnum)
{
- propTypeFullName = typeof(int).FullName;
var enumType = typeProperty.PropertyType;
- var enumValues = enumType.GetEnumValues().Cast();
- valueRange = enumValues.JoinAsString(",");
+
+ var enumNames = enumType.GetEnumNames();
+ var enumValues = enumType.GetEnumValues().Cast().ToArray();
+
+ for (var index = 0; index < enumNames.Length; index++)
+ {
+ var enumName = enumNames[index];
+ var enumValue = enumValues[index];
+ var localizerEnumKey = $"{propertyInfo.Name}:{enumName}";
+
+ // 枚举多语言表现形式为:LocalizationResource.EnumName:EnumValue
+ var enumDisplayNameString = LocalizableString.Create($"{enumType.Name}:{enumName}", resourceName);
+ var enumDisplayName = LocalizableStringSerializer.Serialize(enumDisplayNameString);
+
+ propertyInfo.AddEnum(
+ GuidGenerator,
+ enumName,
+ enumDisplayName,
+ enumValue.ToString());
+ }
}
- entityTypeInfo.AddProperty(
- GuidGenerator,
- typeProperty.Name,
- propDisplayName ?? typeProperty.Name,
- typeProperty.PropertyType.FullName,
- valueRange);
}
}
if (hasChanged)
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore/LINGYUN/Abp/DataProtectionManagement/EntityFrameworkCore/AbpDataProtectionManagementDbContextModelCreatingExtensions.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore/LINGYUN/Abp/DataProtectionManagement/EntityFrameworkCore/AbpDataProtectionManagementDbContextModelCreatingExtensions.cs
index 1fd7f4bda..198f0e202 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore/LINGYUN/Abp/DataProtectionManagement/EntityFrameworkCore/AbpDataProtectionManagementDbContextModelCreatingExtensions.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore/LINGYUN/Abp/DataProtectionManagement/EntityFrameworkCore/AbpDataProtectionManagementDbContextModelCreatingExtensions.cs
@@ -64,16 +64,43 @@ namespace LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore
.HasColumnName(nameof(EntityPropertyInfo.TypeFullName))
.HasMaxLength(EntityPropertyInfoConsts.MaxTypeFullNameLength)
.IsRequired();
+ b.Property(p => p.JavaScriptType)
+ .HasColumnName(nameof(EntityPropertyInfo.JavaScriptType))
+ .HasMaxLength(EntityPropertyInfoConsts.MaxTypeFullNameLength)
+ .IsRequired();
- b.ConfigureByConvention();
+ b.HasMany(p => p.Enums)
+ .WithOne(p => p.PropertyInfo)
+ .HasForeignKey(f => f.PropertyInfoId)
+ .IsRequired();
- b.Property(p => p.ValueRange)
- .HasColumnName(nameof(EntityPropertyInfo.ValueRange))
- .HasMaxLength(EntityPropertyInfoConsts.MaxValueRangeLength);
+ b.ConfigureByConvention();
b.HasIndex(p => new { p.TypeInfoId, p.TypeFullName });
});
+ builder.Entity(b =>
+ {
+ b.ToTable(options.TablePrefix + "EntityEnums", options.Schema);
+
+ b.Property(p => p.Name)
+ .HasColumnName(nameof(EntityEnumInfo.Name))
+ .HasMaxLength(EntityEnumInfoConsts.MaxNameLength)
+ .IsRequired();
+ b.Property(p => p.DisplayName)
+ .HasColumnName(nameof(EntityEnumInfo.DisplayName))
+ .HasMaxLength(EntityEnumInfoConsts.MaxDisplayNameLength)
+ .IsRequired();
+ b.Property(p => p.Value)
+ .HasColumnName(nameof(EntityEnumInfo.Value))
+ .HasMaxLength(EntityEnumInfoConsts.MaxValueLength)
+ .IsRequired();
+
+ b.ConfigureByConvention();
+
+ b.HasIndex(p => new { p.PropertyInfoId, p.Name });
+ });
+
builder.Entity(b =>
{
b.ToTable(options.TablePrefix + "RoleEntityRules", options.Schema);
@@ -82,9 +109,9 @@ namespace LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore
.HasColumnName(nameof(RoleEntityRule.RoleName))
.HasMaxLength(RoleEntityRuleConsts.MaxRuletNameLength)
.IsRequired();
- b.Property(p => p.AllowProperties)
- .HasColumnName(nameof(RoleEntityRule.AllowProperties))
- .HasMaxLength(EntityRuleConsts.MaxAllowPropertiesLength);
+ b.Property(p => p.AccessedProperties)
+ .HasColumnName(nameof(RoleEntityRule.AccessedProperties))
+ .HasMaxLength(EntityRuleConsts.MaxAccessedPropertiesLength);
b.Property(p => p.FilterGroup)
.HasColumnName(nameof(RoleEntityRule.FilterGroup))
@@ -106,9 +133,9 @@ namespace LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore
.HasColumnName(nameof(OrganizationUnitEntityRule.OrgCode))
.HasMaxLength(OrganizationUnitEntityRuleConsts.MaxCodeLength)
.IsRequired();
- b.Property(p => p.AllowProperties)
- .HasColumnName(nameof(RoleEntityRule.AllowProperties))
- .HasMaxLength(EntityRuleConsts.MaxAllowPropertiesLength);
+ b.Property(p => p.AccessedProperties)
+ .HasColumnName(nameof(RoleEntityRule.AccessedProperties))
+ .HasMaxLength(EntityRuleConsts.MaxAccessedPropertiesLength);
b.Property(p => p.FilterGroup)
.HasColumnName(nameof(RoleEntityRule.FilterGroup))
diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore/LINGYUN/Abp/DataProtectionManagement/EntityFrameworkCore/EfCoreEntityTypeInfoRepository.cs b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore/LINGYUN/Abp/DataProtectionManagement/EntityFrameworkCore/EfCoreEntityTypeInfoRepository.cs
index 8d8191be9..5c64ab26a 100644
--- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore/LINGYUN/Abp/DataProtectionManagement/EntityFrameworkCore/EfCoreEntityTypeInfoRepository.cs
+++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore/LINGYUN/Abp/DataProtectionManagement/EntityFrameworkCore/EfCoreEntityTypeInfoRepository.cs
@@ -52,6 +52,8 @@ public class EfCoreEntityTypeInfoRepository : EfCoreRepository> WithDetailsAsync()
{
- return (await base.WithDetailsAsync()).Include(x => x.Properties);
+ return (await base.WithDetailsAsync())
+ .Include(x => x.Properties)
+ .ThenInclude(x => x.Enums);
}
}
diff --git a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application.Contracts/LINGYUN.Abp.Demo.Application.Contracts.csproj b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application.Contracts/LINGYUN.Abp.Demo.Application.Contracts.csproj
index 743dfccd6..6f9eee89b 100644
--- a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application.Contracts/LINGYUN.Abp.Demo.Application.Contracts.csproj
+++ b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application.Contracts/LINGYUN.Abp.Demo.Application.Contracts.csproj
@@ -20,6 +20,7 @@
+
diff --git a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application.Contracts/LINGYUN/Abp/Demo/AbpDemoApplicationContractsModule.cs b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application.Contracts/LINGYUN/Abp/Demo/AbpDemoApplicationContractsModule.cs
index 75a530f1d..9e6e27e19 100644
--- a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application.Contracts/LINGYUN/Abp/Demo/AbpDemoApplicationContractsModule.cs
+++ b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application.Contracts/LINGYUN/Abp/Demo/AbpDemoApplicationContractsModule.cs
@@ -1,4 +1,5 @@
-using LINGYUN.Abp.Exporter;
+using LINGYUN.Abp.DataProtection;
+using LINGYUN.Abp.Exporter;
using Volo.Abp.Application;
using Volo.Abp.Authorization;
using Volo.Abp.Modularity;
@@ -6,6 +7,7 @@ using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Demo;
[DependsOn(
+ typeof(AbpDataProtectionAbstractionsModule),
typeof(AbpExporterApplicationContractsModule),
typeof(AbpAuthorizationAbstractionsModule),
typeof(AbpDddApplicationContractsModule),
diff --git a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application.Contracts/LINGYUN/Abp/Demo/Books/IBookAppService.cs b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application.Contracts/LINGYUN/Abp/Demo/Books/IBookAppService.cs
index 044ac4aae..7a4dbeb19 100644
--- a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application.Contracts/LINGYUN/Abp/Demo/Books/IBookAppService.cs
+++ b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application.Contracts/LINGYUN/Abp/Demo/Books/IBookAppService.cs
@@ -1,4 +1,5 @@
-using LINGYUN.Abp.Exporter;
+using LINGYUN.Abp.DataProtection.Models;
+using LINGYUN.Abp.Exporter;
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
@@ -15,4 +16,10 @@ public interface IBookAppService :
IImporterAppService
{
Task> GetAuthorLookupAsync();
+ ///
+ /// 获取实体可访问规则
+ ///
+ ///
+ ///
+ Task GetEntityRuleAsync(EntityTypeInfoGetModel input);
}
\ No newline at end of file
diff --git a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application/LINGYUN/Abp/Demo/AbpDemoApplicationModule.cs b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application/LINGYUN/Abp/Demo/AbpDemoApplicationModule.cs
index 166a3e98e..b0eed876f 100644
--- a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application/LINGYUN/Abp/Demo/AbpDemoApplicationModule.cs
+++ b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application/LINGYUN/Abp/Demo/AbpDemoApplicationModule.cs
@@ -1,4 +1,5 @@
-using LINGYUN.Abp.Exporter;
+using LINGYUN.Abp.DataProtection;
+using LINGYUN.Abp.Exporter;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Application;
using Volo.Abp.AutoMapper;
@@ -8,6 +9,7 @@ namespace LINGYUN.Abp.Demo;
[DependsOn(
typeof(AbpDddApplicationModule),
+ typeof(AbpDataProtectionModule),
typeof(AbpDemoDomainModule),
typeof(AbpExporterApplicationModule),
typeof(AbpDemoApplicationContractsModule))]
diff --git a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application/LINGYUN/Abp/Demo/Books/BookAppService.cs b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application/LINGYUN/Abp/Demo/Books/BookAppService.cs
index 079240790..8ac18bbbd 100644
--- a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application/LINGYUN/Abp/Demo/Books/BookAppService.cs
+++ b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Application/LINGYUN/Abp/Demo/Books/BookAppService.cs
@@ -1,4 +1,7 @@
-using LINGYUN.Abp.Demo.Authors;
+using LINGYUN.Abp.DataProtection;
+using LINGYUN.Abp.DataProtection.Models;
+using LINGYUN.Abp.Demo.Authors;
+using LINGYUN.Abp.Demo.Localization;
using LINGYUN.Abp.Demo.Permissions;
using LINGYUN.Abp.Exporter;
using Microsoft.AspNetCore.Authorization;
@@ -7,6 +10,7 @@ using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Content;
using Volo.Abp.Domain.Entities;
+using Volo.Abp.Localization;
namespace LINGYUN.Abp.Demo.Books;
@@ -26,6 +30,8 @@ public class BookAppService :
private readonly IExporterProvider _exporterProvider;
private readonly IImporterProvider _importerProvider;
+ protected IDataAccessEntityTypeInfoProvider EntityTypeInfoProvider => LazyServiceProvider.LazyGetRequiredService();
+
public BookAppService(
IExporterProvider exporterProvider,
IImporterProvider importerProvider,
@@ -38,13 +44,29 @@ public class BookAppService :
_importerProvider = importerProvider;
_authorManager = authorManager;
_authorRepository = authorRepository;
+
GetPolicyName = DemoPermissions.Books.Default;
GetListPolicyName = DemoPermissions.Books.Default;
CreatePolicyName = DemoPermissions.Books.Create;
UpdatePolicyName = DemoPermissions.Books.Edit;
DeletePolicyName = DemoPermissions.Books.Delete;
+
+ LocalizationResource = typeof(DemoResource);
+ ObjectMapperContext = typeof(AbpDemoApplicationModule);
}
+ [DisableDataProtected(DataAccessOperation.Read)]// 更新时禁用查询过滤
+ public override Task UpdateAsync(Guid id, CreateUpdateBookDto input)
+ {
+ return base.UpdateAsync(id, input);
+ }
+
+ [DisableDataProtected(DataAccessOperation.Read)]
+ public override Task DeleteAsync(Guid id)
+ {
+ return base.DeleteAsync(id);
+ }
+
public async virtual Task ImportAsync(BookImportInput input)
{
await CheckCreatePolicyAsync();
@@ -203,4 +225,18 @@ public class BookAppService :
return $"book.{sorting}";
}
+
+ public async virtual Task GetEntityRuleAsync(EntityTypeInfoGetModel input)
+ {
+ var entityType = typeof(Book);
+ var resourceType = LocalizationResource ?? typeof(DefaultResource);
+
+ var context = new DataAccessEntitTypeInfoContext(
+ entityType,
+ resourceType,
+ input.Operation,
+ LazyServiceProvider);
+
+ return await EntityTypeInfoProvider.GetEntitTypeInfoAsync(context);
+ }
}
\ No newline at end of file
diff --git a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Domain.Shared/LINGYUN/Abp/Demo/Localization/Resources/en.json b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Domain.Shared/LINGYUN/Abp/Demo/Localization/Resources/en.json
index 58a7215e9..8ae2a839b 100644
--- a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Domain.Shared/LINGYUN/Abp/Demo/Localization/Resources/en.json
+++ b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Domain.Shared/LINGYUN/Abp/Demo/Localization/Resources/en.json
@@ -12,6 +12,15 @@
"Permission:Authors.Create": "Create Authors",
"Permission:Authors.Edit": "Edit Authors",
"Permission:Authors.Delete": "Delete Authors",
- "Demo:00001": "Author {Name} already exists!"
+ "Demo:00001": "Author {Name} already exists!",
+ "Author": "Authors",
+ "Book": "Books",
+ "DisplayName:Name": "Name",
+ "DisplayName:Type": "Type",
+ "DisplayName:PublishDate": "Publish Date",
+ "DisplayName:Price": "Price",
+ "DisplayName:AuthorId": "Author Id",
+ "DisplayName:BirthDate": "Birth Date",
+ "DisplayName:ShortBio": "Short Bio"
}
}
\ No newline at end of file
diff --git a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Domain.Shared/LINGYUN/Abp/Demo/Localization/Resources/zh-Hans.json b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Domain.Shared/LINGYUN/Abp/Demo/Localization/Resources/zh-Hans.json
index d540adcbd..d97f029e1 100644
--- a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Domain.Shared/LINGYUN/Abp/Demo/Localization/Resources/zh-Hans.json
+++ b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Domain.Shared/LINGYUN/Abp/Demo/Localization/Resources/zh-Hans.json
@@ -12,6 +12,15 @@
"Permission:Authors.Create": "新增作者",
"Permission:Authors.Edit": "编辑作者",
"Permission:Authors.Delete": "删除作者",
- "Demo:00001": "作者 {Name} 已经存在!"
+ "Demo:00001": "作者 {Name} 已经存在!",
+ "Author": "作者",
+ "Book": "书籍",
+ "DisplayName:Name": "名称",
+ "DisplayName:Type": "类型",
+ "DisplayName:PublishDate": "出版日期",
+ "DisplayName:Price": "单价",
+ "DisplayName:AuthorId": "作者",
+ "DisplayName:BirthDate": "生日",
+ "DisplayName:ShortBio": "简介"
}
}
\ No newline at end of file
diff --git a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Domain/LINGYUN/Abp/Demo/AbpDemoDomainModule.cs b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Domain/LINGYUN/Abp/Demo/AbpDemoDomainModule.cs
index d62688561..6391d7c87 100644
--- a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Domain/LINGYUN/Abp/Demo/AbpDemoDomainModule.cs
+++ b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.Domain/LINGYUN/Abp/Demo/AbpDemoDomainModule.cs
@@ -1,7 +1,11 @@
using LINGYUN.Abp.DataProtection;
+using LINGYUN.Abp.DataProtection.Localization;
+using LINGYUN.Abp.Demo.Books;
+using LINGYUN.Abp.Demo.Localization;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Domain;
+using Volo.Abp.Localization;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Demo;
@@ -22,10 +26,11 @@ public class AbpDemoDomainModule : AbpModule
options.AddProfile(validate: true);
});
- //Configure(options =>
- //{
- // options.AddPersistenceResource();
- //});
+ Configure(options =>
+ {
+ options.Resources.Get()
+ .AddBaseTypes(typeof(DataProtectionResource));
+ });
// 分布式事件
//Configure(options =>
@@ -33,5 +38,11 @@ public class AbpDemoDomainModule : AbpModule
// options.AutoEventSelectors.Add();
// options.EtoMappings.Add();
//});
+
+ Configure(options =>
+ {
+ // 外键属性不可设定规则
+ options.EntityIgnoreProperties.Add(typeof(Book), new []{ nameof(Book.AuthorId) } );
+ });
}
}
diff --git a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.EntityFrameworkCore/LINGYUN/Abp/Demo/Books/EfCoreBookRepository.cs b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.EntityFrameworkCore/LINGYUN/Abp/Demo/Books/EfCoreBookRepository.cs
index 17a889a94..6ad8fbea9 100644
--- a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.EntityFrameworkCore/LINGYUN/Abp/Demo/Books/EfCoreBookRepository.cs
+++ b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.EntityFrameworkCore/LINGYUN/Abp/Demo/Books/EfCoreBookRepository.cs
@@ -8,10 +8,11 @@ namespace LINGYUN.Abp.Demo.Books;
public class EfCoreBookRepository : EfCoreDataProtectionRepository, IBookRepository
{
public EfCoreBookRepository(
- [NotNull] IDbContextProvider dbContextProvider,
- [NotNull] IDataAuthorizationService dataAuthorizationService,
- [NotNull] IEntityTypeFilterBuilder entityTypeFilterBuilder)
- : base(dbContextProvider, dataAuthorizationService, entityTypeFilterBuilder)
+ [NotNull] IDbContextProvider dbContextProvider,
+ [NotNull] IDataAuthorizationService dataAuthorizationService,
+ [NotNull] IEntityTypeFilterBuilder entityTypeFilterBuilder,
+ [NotNull] IEntityPropertyResultBuilder entityPropertyResultBuilder)
+ : base(dbContextProvider, dataAuthorizationService, entityTypeFilterBuilder, entityPropertyResultBuilder)
{
}
}
diff --git a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.HttpApi/LINGYUN/Abp/Demo/Books/BookController.cs b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.HttpApi/LINGYUN/Abp/Demo/Books/BookController.cs
index 839d1ac0f..781808e1b 100644
--- a/aspnet-core/modules/demo/LINGYUN.Abp.Demo.HttpApi/LINGYUN/Abp/Demo/Books/BookController.cs
+++ b/aspnet-core/modules/demo/LINGYUN.Abp.Demo.HttpApi/LINGYUN/Abp/Demo/Books/BookController.cs
@@ -1,4 +1,5 @@
-using LINGYUN.Abp.Demo.Permissions;
+using LINGYUN.Abp.DataProtection.Models;
+using LINGYUN.Abp.Demo.Permissions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
@@ -78,4 +79,11 @@ public class BookController : AbpControllerBase, IBookAppService
{
return _service.UpdateAsync(id, input);
}
+
+ [HttpGet]
+ [Route("entity")]
+ public virtual Task GetEntityRuleAsync(EntityTypeInfoGetModel input)
+ {
+ return _service.GetEntityRuleAsync(input);
+ }
}