diff --git a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/DefaultSqlSugarDbContext.cs b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/DefaultSqlSugarDbContext.cs index 3245b95f..85f71a55 100644 --- a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/DefaultSqlSugarDbContext.cs +++ b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/DefaultSqlSugarDbContext.cs @@ -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); } diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Forum/DiscussAggregateRoot.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Forum/DiscussAggregateRoot.cs index be562f33..24ef78b8 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Forum/DiscussAggregateRoot.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Forum/DiscussAggregateRoot.cs @@ -24,6 +24,15 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum PlateId = plateId; } + public void AddSeeNumber() + { + this.SeeNum += 1; + //设置最小值,不更新 + this.LastModificationTime = DateTime.MinValue; + //设置空值,不更新 + this.LastModifierId = Guid.Empty; + } + [SugarColumn(ColumnName = "Id", IsPrimaryKey = true)] public override Guid Id { get; protected set; } public string? Title { get; set; } diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/SeeDiscussEventHandler.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/SeeDiscussEventHandler.cs index b9411b40..f82b15dd 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/SeeDiscussEventHandler.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/SeeDiscussEventHandler.cs @@ -23,13 +23,9 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers var entity = await _repository.GetAsync(eventData.DiscussId); if (entity is not null) { - entity.SeeNum += 1; + entity.AddSeeNumber(); await _repository.UpdateAsync(entity); } } - - - - } } diff --git a/Yi.Abp.Net8/module/chat-hub/Yi.Framework.ChatHub.Domain/Managers/AiManager.cs b/Yi.Abp.Net8/module/chat-hub/Yi.Framework.ChatHub.Domain/Managers/AiManager.cs index a8571f2b..7c64ea9b 100644 --- a/Yi.Abp.Net8/module/chat-hub/Yi.Framework.ChatHub.Domain/Managers/AiManager.cs +++ b/Yi.Abp.Net8/module/chat-hub/Yi.Framework.ChatHub.Domain/Managers/AiManager.cs @@ -53,7 +53,7 @@ namespace Yi.Framework.ChatHub.Domain.Managers { if (result.Successful) { - yield return result.Choices.FirstOrDefault()?.Message.Content ?? string.Empty; + yield return result.Choices.FirstOrDefault()?.Message.Content ?? null; } else {