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