Merge branch 'dev' of 123.207.203.228:server/HuanMengProject into dev
This commit is contained in:
commit
02ac4e3961
38
src/0-core/HuanMeng.MiaoYu.Code/Chat/ChatBLL.cs
Normal file
38
src/0-core/HuanMeng.MiaoYu.Code/Chat/ChatBLL.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using HuanMeng.DotNetCore.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Code.Chat
|
||||
{
|
||||
/// <summary>
|
||||
/// 聊天类
|
||||
/// </summary>
|
||||
public class ChatBLL : MiaoYuBase
|
||||
{
|
||||
public ChatBLL(IServiceProvider serviceProvider) : base(serviceProvider)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除聊天记录
|
||||
/// </summary>
|
||||
/// <param name="id">聊天id</param>
|
||||
/// <param name="characterId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DelChatByIds(List<int> id,int characterId)
|
||||
{
|
||||
var chatsToDelete = Dao.daoDbMiaoYu.context.T_Chat.Where(t => id.Contains(t.Id)).ToList();
|
||||
if (chatsToDelete.Count <= 0)
|
||||
{
|
||||
throw new Exception("");
|
||||
}
|
||||
var chatList = chatsToDelete.Where(t => t.UserId == _UserId && t.CharacterId == characterId && t.IsDel == false).ToList();
|
||||
Dao.daoDbMiaoYu.context.T_Chat.RemoveRange(chatList);
|
||||
Dao.daoDbMiaoYu.context.SaveChanges();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -38,6 +38,36 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
|
|||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 人物表
|
||||
/// </summary>
|
||||
public virtual DbSet<T_Character> T_Character { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 角色标签表
|
||||
/// </summary>
|
||||
public virtual DbSet<T_Character_Label> T_Character_Label { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联角色和标签
|
||||
/// </summary>
|
||||
public virtual DbSet<T_Character_Label_Relation> T_Character_Label_Relation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发现页类型分类
|
||||
/// </summary>
|
||||
public virtual DbSet<T_Character_Type> T_Character_Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存储用户和角色之间的亲密值
|
||||
/// </summary>
|
||||
public virtual DbSet<T_Character_User_Intimacy> T_Character_User_Intimacy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 聊天记录表
|
||||
/// </summary>
|
||||
public virtual DbSet<T_Chat> T_Chat { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户表
|
||||
/// </summary>
|
||||
|
|
@ -63,6 +93,193 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
|
|||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<T_Character>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__T_Charac__3214EC070A8D79B3");
|
||||
|
||||
entity.ToTable(tb => tb.HasComment("人物表"));
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.ValueGeneratedNever()
|
||||
.HasComment("人物id");
|
||||
entity.Property(e => e.Biography)
|
||||
.HasMaxLength(500)
|
||||
.HasComment("人物简介");
|
||||
entity.Property(e => e.CreateTime)
|
||||
.HasComment("创建时间")
|
||||
.HasColumnType("datetime");
|
||||
entity.Property(e => e.Gender).HasComment("性别0男1女2其他");
|
||||
entity.Property(e => e.Model)
|
||||
.HasMaxLength(255)
|
||||
.IsUnicode(false)
|
||||
.HasComment("人物模型");
|
||||
entity.Property(e => e.Name)
|
||||
.HasMaxLength(50)
|
||||
.HasComment("人物名字");
|
||||
entity.Property(e => e.Prologue)
|
||||
.HasMaxLength(255)
|
||||
.HasComment("开场白");
|
||||
entity.Property(e => e.Style).HasComment("风格id");
|
||||
entity.Property(e => e.System)
|
||||
.HasMaxLength(255)
|
||||
.IsUnicode(false)
|
||||
.HasComment("人物初始设定");
|
||||
entity.Property(e => e.TenantId).HasComment("租户Id");
|
||||
entity.Property(e => e.UpdateTime)
|
||||
.HasComment("更新时间")
|
||||
.HasColumnType("datetime");
|
||||
entity.Property(e => e.Visibility).HasComment("公开/私密 0公开 1私密");
|
||||
//添加全局筛选器
|
||||
if (this.TenantInfo != null)
|
||||
{
|
||||
entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
|
||||
}
|
||||
});
|
||||
|
||||
modelBuilder.Entity<T_Character_Label>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__T_Charac__3214EC0777B5F217");
|
||||
|
||||
entity.ToTable(tb => tb.HasComment("角色标签表"));
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.ValueGeneratedNever()
|
||||
.HasComment("标签id");
|
||||
entity.Property(e => e.CreateTime)
|
||||
.HasComment("创建时间")
|
||||
.HasColumnType("datetime");
|
||||
entity.Property(e => e.LabelName)
|
||||
.HasMaxLength(50)
|
||||
.HasComment("标签名称");
|
||||
entity.Property(e => e.TenantId).HasComment("租户id");
|
||||
entity.Property(e => e.UpdateTime)
|
||||
.HasComment("更新时间")
|
||||
.HasColumnType("datetime");
|
||||
//添加全局筛选器
|
||||
if (this.TenantInfo != null)
|
||||
{
|
||||
entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
|
||||
}
|
||||
});
|
||||
|
||||
modelBuilder.Entity<T_Character_Label_Relation>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__T_Charac__3214EC071FC16A53");
|
||||
|
||||
entity.ToTable(tb => tb.HasComment("关联角色和标签"));
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.ValueGeneratedNever()
|
||||
.HasComment("人物和标签的关联id");
|
||||
entity.Property(e => e.CharacterId_)
|
||||
.HasComment("人物Id")
|
||||
.HasColumnName("CharacterId ");
|
||||
entity.Property(e => e.CharacterLabelId).HasComment("人物标签id");
|
||||
entity.Property(e => e.CreateTime)
|
||||
.HasComment("创建时间")
|
||||
.HasColumnType("datetime");
|
||||
entity.Property(e => e.TenantId).HasComment("租户id");
|
||||
entity.Property(e => e.UpdateTime)
|
||||
.HasComment("更新时间")
|
||||
.HasColumnType("datetime");
|
||||
//添加全局筛选器
|
||||
if (this.TenantInfo != null)
|
||||
{
|
||||
entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
|
||||
}
|
||||
});
|
||||
|
||||
modelBuilder.Entity<T_Character_Type>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__T_Charac__3214EC070CC04F82");
|
||||
|
||||
entity.ToTable(tb => tb.HasComment("发现页类型分类"));
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.ValueGeneratedNever()
|
||||
.HasComment("类型id");
|
||||
entity.Property(e => e.CreateTime).HasComment("创建时间");
|
||||
entity.Property(e => e.Name)
|
||||
.HasMaxLength(255)
|
||||
.HasComment("类型名称");
|
||||
entity.Property(e => e.TenantId).HasComment("租户id");
|
||||
entity.Property(e => e.UpdateTime).HasComment("更新时间");
|
||||
//添加全局筛选器
|
||||
if (this.TenantInfo != null)
|
||||
{
|
||||
entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
|
||||
}
|
||||
});
|
||||
|
||||
modelBuilder.Entity<T_Character_User_Intimacy>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__T_Charac__3214EC079BEEBDEA");
|
||||
|
||||
entity.ToTable(tb => tb.HasComment("存储用户和角色之间的亲密值"));
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.ValueGeneratedNever()
|
||||
.HasComment("亲密度id");
|
||||
entity.Property(e => e.CharacterId).HasComment("人物Id");
|
||||
entity.Property(e => e.CreateTime)
|
||||
.HasComment("创建时间")
|
||||
.HasColumnType("datetime");
|
||||
entity.Property(e => e.IntimacyValue).HasComment("亲密值");
|
||||
entity.Property(e => e.TenantId).HasComment("租户id");
|
||||
entity.Property(e => e.UpdateTime)
|
||||
.HasComment("更新时间")
|
||||
.HasColumnType("datetime");
|
||||
entity.Property(e => e.UserId).HasComment("用户Id");
|
||||
//添加全局筛选器
|
||||
if (this.TenantInfo != null)
|
||||
{
|
||||
entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
|
||||
}
|
||||
});
|
||||
|
||||
modelBuilder.Entity<T_Chat>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__T_Chat__3214EC079C2C8859");
|
||||
|
||||
entity.ToTable(tb => tb.HasComment("聊天记录表"));
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.ValueGeneratedNever()
|
||||
.HasComment("聊天id");
|
||||
entity.Property(e => e.CharacterId).HasComment("人物表Id");
|
||||
entity.Property(e => e.Content)
|
||||
.HasMaxLength(255)
|
||||
.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.TenantId).HasComment("租户id");
|
||||
entity.Property(e => e.TimeStamp)
|
||||
.HasComment("发送时间")
|
||||
.HasColumnType("datetime");
|
||||
entity.Property(e => e.UpdateTime)
|
||||
.HasComment("更新时间")
|
||||
.HasColumnType("datetime");
|
||||
entity.Property(e => e.UserId).HasComment("聊天内容");
|
||||
//添加全局筛选器
|
||||
if (this.TenantInfo != null)
|
||||
{
|
||||
entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
|
||||
}
|
||||
});
|
||||
|
||||
modelBuilder.Entity<T_User>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__T_User__3214EC073733108B");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 人物表
|
||||
/// </summary>
|
||||
public partial class T_Character: MultiTenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 人物id
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 人物名字
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 人物简介
|
||||
/// </summary>
|
||||
public string? Biography { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 开场白
|
||||
/// </summary>
|
||||
public string Prologue { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 风格id
|
||||
/// </summary>
|
||||
public int? Style { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 公开/私密 0公开 1私密
|
||||
/// </summary>
|
||||
public bool Visibility { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 性别0男1女2其他
|
||||
/// </summary>
|
||||
public int Gender { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 人物模型
|
||||
/// </summary>
|
||||
public string? Model { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 人物初始设定
|
||||
/// </summary>
|
||||
public string? System { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 角色标签表
|
||||
/// </summary>
|
||||
public partial class T_Character_Label: MultiTenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 标签id
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 标签名称
|
||||
/// </summary>
|
||||
public string? LabelName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 关联角色和标签
|
||||
/// </summary>
|
||||
public partial class T_Character_Label_Relation: MultiTenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 人物和标签的关联id
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 人物Id
|
||||
/// </summary>
|
||||
public int? CharacterId_ { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 人物标签id
|
||||
/// </summary>
|
||||
public int? CharacterLabelId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 发现页类型分类
|
||||
/// </summary>
|
||||
public partial class T_Character_Type: MultiTenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 类型id
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类型名称
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime UpdateTime { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 存储用户和角色之间的亲密值
|
||||
/// </summary>
|
||||
public partial class T_Character_User_Intimacy: MultiTenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 亲密度id
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 人物Id
|
||||
/// </summary>
|
||||
public int? CharacterId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户Id
|
||||
/// </summary>
|
||||
public int? UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 亲密值
|
||||
/// </summary>
|
||||
public int? IntimacyValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 聊天记录表
|
||||
/// </summary>
|
||||
public partial class T_Chat: MultiTenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 聊天id
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 聊天内容
|
||||
/// </summary>
|
||||
public int? UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消息内容
|
||||
/// </summary>
|
||||
public string Content { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 发送时间
|
||||
/// </summary>
|
||||
public DateTime? TimeStamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 输入token
|
||||
/// </summary>
|
||||
public int? Input_tokens { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 输出token
|
||||
/// </summary>
|
||||
public int Output_tokens { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 人物表Id
|
||||
/// </summary>
|
||||
public int? CharacterId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// user/assistant
|
||||
/// </summary>
|
||||
public string Role { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 发送日期
|
||||
/// </summary>
|
||||
public DateOnly? CreateDay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否假删除0否1是
|
||||
/// </summary>
|
||||
public bool IsDel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 人物模型
|
||||
/// </summary>
|
||||
public string Model { get; set; } = null!;
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using HuanMeng.DotNetCore.Base;
|
||||
using HuanMeng.MiaoYu.Code.Chat;
|
||||
using HuanMeng.MiaoYu.Model.Dto.Home;
|
||||
using HuanMeng.MiaoYu.WebApi.Base;
|
||||
|
||||
|
|
@ -46,5 +47,23 @@ namespace HuanMeng.MiaoYu.WebApi.Controllers
|
|||
var obj = JsonConvert.DeserializeObject<ChatListDto>("{\"ChatList\":[{\"Id\":\"1\",\"Role\":\"user\",\"Content\":\"Hello, how are you?\",\"Timestamp\":\"2022-03-01 12:00:00 \",\"MessageType\":0,\"UserIcon\":\"\"},{\"Id\":\"2\",\"Role\":\"assistant\",\"Content\":\"I'm fine, thanks!\",\"Timestamp\":\"2022-03-01 12:05:00 \",\"UserIcon\":\"\"}]}");
|
||||
return new BaseResponse<ChatListDto>(ResonseCode.Success, "", obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除聊天记录
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="characterId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<BaseResponse<bool>> DelChatByIds(List<int> id, int characterId)
|
||||
{
|
||||
if(id == null || characterId == 0)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
ChatBLL chatBLL = new ChatBLL(ServiceProvider);
|
||||
var obj =await chatBLL.DelChatByIds(id, characterId);
|
||||
return new BaseResponse<bool>(ResonseCode.Success, "", obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user