feat: db操作支持不修改更新审计日志

This commit is contained in:
橙子
2025-02-05 00:02:04 +08:00
parent e69bbb46b3
commit 5d286ebc9e
4 changed files with 23 additions and 8 deletions

View File

@@ -61,7 +61,12 @@ public class DefaultSqlSugarDbContext : SqlSugarDbContext
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModificationTime)))
{
if (!DateTime.MinValue.Equals(oldValue))
//最后更新时间,已经是最小值,忽略
if (DateTime.MinValue.Equals(oldValue))
{
entityInfo.SetValue(null);
}
else
{
entityInfo.SetValue(DateTime.Now);
}
@@ -70,7 +75,12 @@ public class DefaultSqlSugarDbContext : SqlSugarDbContext
{
if (typeof(Guid?) == entityInfo.EntityColumnInfo.PropertyInfo.PropertyType)
{
if (CurrentUser.Id != null)
//最后更新者已经是空guid忽略
if (Guid.Empty.Equals(oldValue))
{
entityInfo.SetValue(null);
}
else if (CurrentUser.Id != null)
{
entityInfo.SetValue(CurrentUser.Id);
}