From 5dfaf75440ea7e0aa1694ea82e890d1b46101656 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com>
Date: Tue, 10 Dec 2024 22:04:46 +0800
Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=AE=9E?=
=?UTF-8?q?=E4=BD=93=E9=A2=86=E5=9F=9F=E4=BA=8B=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ISqlSugarDbContext.cs | 2 +-
.../DefaultSqlSugarDbContext.cs | 83 ++++++++++++++++++-
.../SqlSugarDbContextFactory.cs | 1 -
.../Uow/SqlSugarDatabaseApi.cs | 2 +-
.../Services/TestService.cs | 1 -
5 files changed, 83 insertions(+), 6 deletions(-)
diff --git a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore.Abstractions/ISqlSugarDbContext.cs b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore.Abstractions/ISqlSugarDbContext.cs
index cd4f9dce..cb736291 100644
--- a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore.Abstractions/ISqlSugarDbContext.cs
+++ b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore.Abstractions/ISqlSugarDbContext.cs
@@ -14,7 +14,7 @@ namespace Yi.Framework.SqlSugarCore.Abstractions
/// SqlSugarDb
///
ISqlSugarClient SqlSugarClient { get; }
-
+
///
/// 数据库备份
///
diff --git a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/DefaultSqlSugarDbContext.cs b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/DefaultSqlSugarDbContext.cs
index 0c13e6bf..9ba17dc3 100644
--- a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/DefaultSqlSugarDbContext.cs
+++ b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/DefaultSqlSugarDbContext.cs
@@ -12,6 +12,7 @@ using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Events;
using Volo.Abp.Guids;
using Volo.Abp.MultiTenancy;
+using Volo.Abp.Uow;
using Volo.Abp.Users;
using Yi.Framework.SqlSugarCore.Abstractions;
@@ -19,13 +20,13 @@ namespace Yi.Framework.SqlSugarCore;
public class DefaultSqlSugarDbContext : SqlSugarDbContext
{
-
protected DbConnOptions Options => LazyServiceProvider.LazyGetRequiredService>().Value;
protected ICurrentUser CurrentUser => LazyServiceProvider.GetRequiredService();
protected IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetRequiredService();
protected ILoggerFactory Logger => LazyServiceProvider.LazyGetRequiredService();
protected ICurrentTenant CurrentTenant => LazyServiceProvider.LazyGetRequiredService();
protected IDataFilter DataFilter => LazyServiceProvider.LazyGetRequiredService();
+ public IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService();
protected virtual bool IsMultiTenantFilterEnabled => DataFilter?.IsEnabled() ?? false;
protected virtual bool IsSoftDeleteFilterEnabled => DataFilter?.IsEnabled() ?? false;
@@ -35,6 +36,7 @@ public class DefaultSqlSugarDbContext : SqlSugarDbContext
public DefaultSqlSugarDbContext(IAbpLazyServiceProvider lazyServiceProvider) : base(lazyServiceProvider)
{
}
+
protected override void CustomDataFilter(ISqlSugarClient sqlSugarClient)
{
if (IsSoftDeleteFilterEnabled)
@@ -123,7 +125,7 @@ public class DefaultSqlSugarDbContext : SqlSugarDbContext
}
- //领域事件
+ //实体变更领域事件
switch (entityInfo.OperationType)
{
case DataFilterType.InsertByObject:
@@ -166,6 +168,14 @@ public class DefaultSqlSugarDbContext : SqlSugarDbContext
break;
}
+
+
+ //实体领域事件-所有操作类型
+ if (entityInfo.PropertyName == nameof(IEntity