feat: db操作支持不修改更新审计日志
This commit is contained in:
@@ -61,7 +61,12 @@ public class DefaultSqlSugarDbContext : SqlSugarDbContext
|
|||||||
|
|
||||||
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModificationTime)))
|
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);
|
entityInfo.SetValue(DateTime.Now);
|
||||||
}
|
}
|
||||||
@@ -70,7 +75,12 @@ public class DefaultSqlSugarDbContext : SqlSugarDbContext
|
|||||||
{
|
{
|
||||||
if (typeof(Guid?) == entityInfo.EntityColumnInfo.PropertyInfo.PropertyType)
|
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);
|
entityInfo.SetValue(CurrentUser.Id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,15 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
|
|||||||
PlateId = plateId;
|
PlateId = plateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddSeeNumber()
|
||||||
|
{
|
||||||
|
this.SeeNum += 1;
|
||||||
|
//设置最小值,不更新
|
||||||
|
this.LastModificationTime = DateTime.MinValue;
|
||||||
|
//设置空值,不更新
|
||||||
|
this.LastModifierId = Guid.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
||||||
public override Guid Id { get; protected set; }
|
public override Guid Id { get; protected set; }
|
||||||
public string? Title { get; set; }
|
public string? Title { get; set; }
|
||||||
|
|||||||
@@ -23,13 +23,9 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
|
|||||||
var entity = await _repository.GetAsync(eventData.DiscussId);
|
var entity = await _repository.GetAsync(eventData.DiscussId);
|
||||||
if (entity is not null)
|
if (entity is not null)
|
||||||
{
|
{
|
||||||
entity.SeeNum += 1;
|
entity.AddSeeNumber();
|
||||||
await _repository.UpdateAsync(entity);
|
await _repository.UpdateAsync(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace Yi.Framework.ChatHub.Domain.Managers
|
|||||||
{
|
{
|
||||||
if (result.Successful)
|
if (result.Successful)
|
||||||
{
|
{
|
||||||
yield return result.Choices.FirstOrDefault()?.Message.Content ?? string.Empty;
|
yield return result.Choices.FirstOrDefault()?.Message.Content ?? null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user