From d532bf3bb652455f1c223586c0df77284a97acca Mon Sep 17 00:00:00 2001 From: zyxucp <286513187@qq.com> Date: Mon, 22 Apr 2024 23:50:08 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E8=81=8A=E5=A4=A9=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Setting/ChatHistory/ChatHistory.razor | 115 ++++++++++++------ 1 file changed, 75 insertions(+), 40 deletions(-) diff --git a/src/AntSK/Pages/Setting/ChatHistory/ChatHistory.razor b/src/AntSK/Pages/Setting/ChatHistory/ChatHistory.razor index a6b1794..510f727 100644 --- a/src/AntSK/Pages/Setting/ChatHistory/ChatHistory.razor +++ b/src/AntSK/Pages/Setting/ChatHistory/ChatHistory.razor @@ -8,34 +8,42 @@ @using AntSK.Domain.Repositories @using AntSK.Domain.Common.Map @attribute [Authorize(Roles = "AntSKAdmin")] -
- - - - - - - - - - - @((MarkupString)(context.Context)) - - - - -
-
-
-
+ + + + + + 聊天记录 + + + + + + + + + + + + + + + @((MarkupString)(context.Context)) + + + + + +
+ @using System.Text.Json; @code { [Inject] IChats_Repositories _chats_Repositories { get; set; } @@ -47,6 +55,7 @@ int _pageIndex = 1; int _pageSize = 10; int _total = 0; + string searchString; protected override async Task OnInitializedAsync() { @@ -60,21 +69,47 @@ private async Task InitData() { - _total = _chats_Repositories.Count(p => true); - var chatList = _chats_Repositories.GetDB().Queryable((c, a) => new object[] { + if (string.IsNullOrEmpty(searchString)) + { + _total = _chats_Repositories.Count(p => true); + var chatList = _chats_Repositories.GetDB().Queryable((c, a) => new object[] { SqlSugar.JoinType.Left,c.AppId==a.Id }).Select((c, a) => new ChatsDto + { + Id = c.Id, + UserName = c.UserName, + AppId = c.AppId, + IsSend = c.IsSend, + SendReveice = c.IsSend ? "发送" : "接收", + Context = c.Context, + CreateTime = c.CreateTime, + AppName = a.Name + }).ToPageList(_pageIndex, _pageSize); + chatDtoList = chatList.ToArray(); + } + else + { + _total = _chats_Repositories.Count(p => p.UserName.Contains(searchString) || p.Context.Contains(searchString)); + var chatList = _chats_Repositories.GetDB().Queryable((c, a) => new object[] { + SqlSugar.JoinType.Left,c.AppId==a.Id + }).Select((c, a) => new ChatsDto + { + Id = c.Id, + UserName = c.UserName, + AppId = c.AppId, + IsSend = c.IsSend, + SendReveice = c.IsSend ? "发送" : "接收", + Context = c.Context, + CreateTime = c.CreateTime, + AppName = a.Name + }).Where(c => c.UserName.Contains(searchString) || c.Context.Contains(searchString)).ToPageList(_pageIndex, _pageSize); + chatDtoList = chatList.ToArray(); + } + } + + private async Task Search(string searchKey) { - Id = c.Id, - UserName = c.UserName, - AppId = c.AppId, - IsSend = c.IsSend, - SendReveice = c.IsSend ? "发送" : "接收", - Context=c.Context, - CreateTime = c.CreateTime, - AppName = a.Name - }).ToPageList(_pageIndex, _pageSize); - chatDtoList = chatList.ToArray(); + await InitData(); } public class ChatsDto : Chats