From 3a61df42ead6ad740dc12a71c4c1346c879fa1fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Tue, 8 Aug 2023 10:35:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84aop=E6=8F=92=E5=85=A5?= =?UTF-8?q?=E5=AE=A1=E8=AE=A1=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sqlsugar/SqlSugarDbContext.cs | 14 +++++++++++--- Yi.Furion.Net6/Yi.Furion.Web.Core/Startup.cs | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Yi.Furion.Net6/Yi.Framework.Infrastructure/Sqlsugar/SqlSugarDbContext.cs b/Yi.Furion.Net6/Yi.Framework.Infrastructure/Sqlsugar/SqlSugarDbContext.cs index 880ef42c..702ca832 100644 --- a/Yi.Furion.Net6/Yi.Framework.Infrastructure/Sqlsugar/SqlSugarDbContext.cs +++ b/Yi.Furion.Net6/Yi.Framework.Infrastructure/Sqlsugar/SqlSugarDbContext.cs @@ -13,7 +13,7 @@ using Yi.Framework.Infrastructure.Data.Entities; namespace Yi.Framework.Infrastructure.Sqlsugar { - public class SqlSugarDbContext + public class SqlSugarDbContext { /// /// SqlSugar 客户端 @@ -109,7 +109,11 @@ namespace Yi.Framework.Infrastructure.Sqlsugar if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModificationTime))) { - entityInfo.SetValue(DateTime.Now); + //为空或者为默认最小值 + if (oldValue is null || DateTime.MinValue.Equals((DateTime)oldValue)) + { + entityInfo.SetValue(DateTime.Now); + } } if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModifierId))) { @@ -122,7 +126,11 @@ namespace Yi.Framework.Infrastructure.Sqlsugar case DataFilterType.InsertByObject: if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreationTime))) { - entityInfo.SetValue(DateTime.Now); + //为空或者为默认最小值 + if (oldValue is null || DateTime.MinValue.Equals((DateTime)oldValue)) + { + entityInfo.SetValue(DateTime.Now); + } } if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreatorId))) { diff --git a/Yi.Furion.Net6/Yi.Furion.Web.Core/Startup.cs b/Yi.Furion.Net6/Yi.Furion.Web.Core/Startup.cs index 375f00de..51900e3b 100644 --- a/Yi.Furion.Net6/Yi.Furion.Web.Core/Startup.cs +++ b/Yi.Furion.Net6/Yi.Furion.Web.Core/Startup.cs @@ -36,7 +36,7 @@ public class Startup : AppStartup services.AddSchedule(options => { // 注册作业,并配置作业触发器 - options.AddJob(Triggers.Period(10000)); + //options.AddJob(Triggers.Period(10000)); options.AddJob(Triggers.Cron("0 0 0,12 ? * ?",CronStringFormat.WithSeconds)); // 表示每天凌晨与12点 }); services.AddFileLogging("log/application-{0:yyyy}-{0:MM}-{0:dd}.log", options =>