From f82e97b4ef8309194601cec7fdabfbefe39cf3f7 Mon Sep 17 00:00:00 2001 From: zpc Date: Sun, 14 Jul 2024 15:16:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=9E=E4=BD=93=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cache/Special/CharacterEntityCache.cs | 1 + .../HuanMeng.MiaoYu.Code/Chat/ChatBLL.cs | 34 +++++++------- .../DbSqlServer/Db_MiaoYu/MiaoYuContext.cs | 25 ++++++----- .../DbSqlServer/Db_MiaoYu/T_Chat.cs | 45 +++++++++++++------ .../DbSqlServer/Db_MiaoYu/T_User_Char.cs | 20 ++++----- 5 files changed, 74 insertions(+), 51 deletions(-) diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Cache/Special/CharacterEntityCache.cs b/src/0-core/HuanMeng.MiaoYu.Code/Cache/Special/CharacterEntityCache.cs index 23f2ae2..802ef29 100644 --- a/src/0-core/HuanMeng.MiaoYu.Code/Cache/Special/CharacterEntityCache.cs +++ b/src/0-core/HuanMeng.MiaoYu.Code/Cache/Special/CharacterEntityCache.cs @@ -51,6 +51,7 @@ namespace HuanMeng.MiaoYu.Code.Cache.Special { characterCaches.Remove(characterCache); }); + return characterCaches; } } diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Chat/ChatBLL.cs b/src/0-core/HuanMeng.MiaoYu.Code/Chat/ChatBLL.cs index 4f63843..90e3336 100644 --- a/src/0-core/HuanMeng.MiaoYu.Code/Chat/ChatBLL.cs +++ b/src/0-core/HuanMeng.MiaoYu.Code/Chat/ChatBLL.cs @@ -34,17 +34,17 @@ namespace HuanMeng.MiaoYu.Code.Chat { //var charactersList = MiaoYuCache.CharactersList; //List list = _characterCache.GetCharacterFromCache(characterId); - var chatsToDelete = await Dao.daoDbMiaoYu.context.T_Chat.Where(t => id.Contains(t.Id)).ToListAsync(); - if (chatsToDelete.Count <= 0) - { - throw new Exception(""); - } - var chatList = chatsToDelete.Where(t => t.UserId == _UserId && t.CharacterId == characterId && t.IsDel == false).ToList(); - if (chatList.Count > 0) - { - chatList.ForEach(t => t.IsDel = true); - } - Dao.daoDbMiaoYu.context.SaveChanges(); + //var chatsToDelete = await Dao.daoDbMiaoYu.context.T_Chat.Where(t => id.Contains(t.Id)).ToListAsync(); + //if (chatsToDelete.Count <= 0) + //{ + // throw new Exception(""); + //} + //var chatList = chatsToDelete.Where(t => t.UserId == _UserId && t.CharacterId == characterId && t.Type == 0).ToList(); + //if (chatList.Count > 0) + //{ + // chatList.ForEach(t => t.Type = 2); + //} + //Dao.daoDbMiaoYu.context.SaveChanges(); return true; } @@ -55,12 +55,12 @@ namespace HuanMeng.MiaoYu.Code.Chat /// public async Task DelChat(int characterId) { - var tempList = await Dao.daoDbMiaoYu.context.T_Chat.Where(t => t.UserId == _UserId && t.CharacterId == characterId && t.IsDel == false).ToListAsync(); - if (tempList.Count > 0) - { - tempList.ForEach(t => t.IsDel = true); - } - Dao.daoDbMiaoYu.context.SaveChanges(); + //var tempList = await Dao.daoDbMiaoYu.context.T_Chat.Where(t => t.UserId == _UserId && t.CharacterId == characterId && t.IsDel == false).ToListAsync(); + //if (tempList.Count > 0) + //{ + // tempList.ForEach(t => t.IsDel = true); + //} + //Dao.daoDbMiaoYu.context.SaveChanges(); return true; } } diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/MiaoYuContext.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/MiaoYuContext.cs index 25c6fac..2cc9ab4 100644 --- a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/MiaoYuContext.cs +++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/MiaoYuContext.cs @@ -252,28 +252,33 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext .ValueGeneratedNever() .HasComment("聊天id"); entity.Property(e => e.CharacterId).HasComment("人物表Id"); + entity.Property(e => e.ClaudeId) + .HasMaxLength(100) + .HasComment("聊天返回的Id"); + entity.Property(e => e.ClaudeModel) + .HasMaxLength(50) + .HasComment("人物模型,聊天返回的模型"); + entity.Property(e => e.ClaudeType) + .HasMaxLength(20) + .HasComment("聊天返回的消息的类型"); entity.Property(e => e.Content) - .HasMaxLength(255) + .HasMaxLength(1000) .HasComment("消息内容"); - entity.Property(e => e.CreateDay).HasComment("发送日期"); entity.Property(e => e.CreateTime) .HasComment("创建时间") .HasColumnType("datetime"); entity.Property(e => e.Input_tokens).HasComment("输入token"); - entity.Property(e => e.IsDel).HasComment("是否假删除0否1是"); - entity.Property(e => e.Model) - .HasMaxLength(255) - .IsUnicode(false) - .HasComment("人物模型"); entity.Property(e => e.Output_tokens).HasComment("输出token"); entity.Property(e => e.Role) .HasMaxLength(50) - .IsUnicode(false) .HasComment("user/assistant"); + entity.Property(e => e.SendDateDay).HasComment("发送消息,天"); + entity.Property(e => e.SendMessageDay).HasComment("发送消息时间戳"); entity.Property(e => e.TenantId).HasComment("租户id"); entity.Property(e => e.TimeStamp) .HasComment("发送时间") .HasColumnType("datetime"); + entity.Property(e => e.Type).HasComment("0正常,1重新生成,2 删除"); entity.Property(e => e.UpdateTime) .HasComment("更新时间") .HasColumnType("datetime"); @@ -365,7 +370,7 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext modelBuilder.Entity(entity => { entity.Property(e => e.CharacterId).HasComment("角色Id"); - entity.Property(e => e.CreateDateTime) + entity.Property(e => e.CreateAt) .HasComment("创建时间") .HasColumnType("datetime"); entity.Property(e => e.IsEnable).HasComment("是否启用"); @@ -375,7 +380,7 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext .HasMaxLength(50) .HasComment("会话名称"); entity.Property(e => e.TenantId).HasComment("租户"); - entity.Property(e => e.UpdateDateTime) + entity.Property(e => e.UpdateAt) .HasComment("修改时间") .HasColumnType("datetime"); entity.Property(e => e.UserId).HasComment("用户Id"); diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_Chat.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_Chat.cs index f20ee9b..78dc785 100644 --- a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_Chat.cs +++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_Chat.cs @@ -16,7 +16,7 @@ public partial class T_Chat: MultiTenantEntity /// /// 聊天内容 /// - public int? UserId { get; set; } + public int UserId { get; set; } /// /// 消息内容 @@ -26,22 +26,22 @@ public partial class T_Chat: MultiTenantEntity /// /// 发送时间 /// - public DateTime? TimeStamp { get; set; } + public DateTime TimeStamp { get; set; } /// /// 创建时间 /// - public DateTime? CreateTime { get; set; } + public DateTime CreateTime { get; set; } /// /// 更新时间 /// - public DateTime? UpdateTime { get; set; } + public DateTime UpdateTime { get; set; } /// /// 输入token /// - public int? Input_tokens { get; set; } + public int Input_tokens { get; set; } /// /// 输出token @@ -51,25 +51,42 @@ public partial class T_Chat: MultiTenantEntity /// /// 人物表Id /// - public int? CharacterId { get; set; } + public int CharacterId { get; set; } /// /// user/assistant /// public string Role { get; set; } = null!; - /// - /// 发送日期 - /// - public DateOnly? CreateDay { get; set; } + public Guid SessionId { get; set; } /// - /// 是否假删除0否1是 + /// 发送消息,天 /// - public bool IsDel { get; set; } + public long SendDateDay { get; set; } /// - /// 人物模型 + /// 发送消息时间戳 /// - public string Model { get; set; } = null!; + public long SendMessageDay { get; set; } + + /// + /// 0正常,1重新生成,2 删除 + /// + public int Type { get; set; } + + /// + /// 聊天返回的消息的类型 + /// + public string? ClaudeType { get; set; } + + /// + /// 聊天返回的Id + /// + public string? ClaudeId { get; set; } + + /// + /// 人物模型,聊天返回的模型 + /// + public string? ClaudeModel { get; set; } } diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_User_Char.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_User_Char.cs index 834bd89..db57fd2 100644 --- a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_User_Char.cs +++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_User_Char.cs @@ -26,16 +26,6 @@ public partial class T_User_Char: MultiTenantEntity /// public int ModelConfigId { get; set; } - /// - /// 创建时间 - /// - public DateTime CreateDateTime { get; set; } - - /// - /// 修改时间 - /// - public DateTime UpdateDateTime { get; set; } - /// /// 是否启用 /// @@ -46,4 +36,14 @@ public partial class T_User_Char: MultiTenantEntity /// 用户Id /// public int UserId { get; set; } + + /// + /// 创建时间 + /// + public DateTime CreateAt { get; set; } + + /// + /// 修改时间 + /// + public DateTime UpdateAt { get; set; } }