feat: 完善aop插入审计日志

This commit is contained in:
陈淳
2023-08-08 10:35:09 +08:00
parent d62baa0e51
commit 3a61df42ea
2 changed files with 12 additions and 4 deletions

View File

@@ -13,7 +13,7 @@ using Yi.Framework.Infrastructure.Data.Entities;
namespace Yi.Framework.Infrastructure.Sqlsugar
{
public class SqlSugarDbContext
public class SqlSugarDbContext
{
/// <summary>
/// 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)))
{