HuanMengProject/src/0-core/HuanMeng.MiaoYu.Code/Chat/ChatBLL.cs
2024-07-14 15:16:40 +08:00

68 lines
2.2 KiB
C#

using HuanMeng.DotNetCore.Base;
using HuanMeng.MiaoYu.Code.Cache;
using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
using HuanMeng.MiaoYu.Model.Dto.Home;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
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 charactersList = MiaoYuCache.CharactersList;
//List<T_Character> 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.Type == 0).ToList();
//if (chatList.Count > 0)
//{
// chatList.ForEach(t => t.Type = 2);
//}
//Dao.daoDbMiaoYu.context.SaveChanges();
return true;
}
/// <summary>
/// 清空聊天记录
/// </summary>
/// <param name="characterId"></param>
/// <returns></returns>
public async Task<bool> 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();
return true;
}
}
}