From 682b9f6c3a71d96a0ea426e8a8f4e3694519f205 Mon Sep 17 00:00:00 2001
From: wtp <1813748440@qq.com>
Date: Wed, 15 Mar 2023 18:17:12 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B1=95=E7=A4=BA=E6=97=B6?=
=?UTF-8?q?=E9=97=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
GDZZ.Application/GDZZ.Application.xml | 15 ++++++++-
GDZZ.Application/Help/CacheService.cs | 5 +++
GDZZ.Application/Help/ICacheService.cs | 1 +
GDZZ.Application/Help/Utils.cs | 31 +++++++++++++++++++
.../Dto/LiveHistoryContactsDto.cs | 2 +-
.../LiveHistoryContactsService.cs | 24 ++++++++------
6 files changed, 67 insertions(+), 11 deletions(-)
create mode 100644 GDZZ.Application/Help/Utils.cs
diff --git a/GDZZ.Application/GDZZ.Application.xml b/GDZZ.Application/GDZZ.Application.xml
index 429616c..42ce7c8 100644
--- a/GDZZ.Application/GDZZ.Application.xml
+++ b/GDZZ.Application/GDZZ.Application.xml
@@ -334,6 +334,11 @@
聊天详情
+
+
+ 聊天详情
+
+
小程序用户信息
@@ -394,6 +399,14 @@
+
+
+ 设置未读数
+
+
+
+
+
获取聊天列表
@@ -1232,7 +1245,7 @@
- 修改消息条数
+ 修改未读消息
diff --git a/GDZZ.Application/Help/CacheService.cs b/GDZZ.Application/Help/CacheService.cs
index 12542ce..daaeeff 100644
--- a/GDZZ.Application/Help/CacheService.cs
+++ b/GDZZ.Application/Help/CacheService.cs
@@ -112,6 +112,11 @@ namespace GDZZ.Application.Help
return _redisCache.Get(cacheKey);
}
+ public async Task UpUnreadAsync(long UserID)
+ {
+ string cacheKey = SystemConst.LIVE_UNREAD + $"{UserID}";
+ await _redisCache.SetAsync(cacheKey, 0);
+ }
///
/// 获取聊天列表
diff --git a/GDZZ.Application/Help/ICacheService.cs b/GDZZ.Application/Help/ICacheService.cs
index bfb9de0..8a0845f 100644
--- a/GDZZ.Application/Help/ICacheService.cs
+++ b/GDZZ.Application/Help/ICacheService.cs
@@ -21,6 +21,7 @@ namespace GDZZ.Application.Help
Task GetUnreadAsync(long LiveID);
+ Task UpUnreadAsync(long UserID);
#endregion
diff --git a/GDZZ.Application/Help/Utils.cs b/GDZZ.Application/Help/Utils.cs
new file mode 100644
index 0000000..8ad946b
--- /dev/null
+++ b/GDZZ.Application/Help/Utils.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GDZZ.Application.Help
+{
+ public class Utils
+ {
+ public static bool ShowHelp(DateTime date)
+ {
+ bool isTheDay = false;
+ //判断日期是否是当天
+ DateTime time = DateTime.Now;//当天
+ DateTime time2 = new DateTime(time.Year, time.Month, time.Day);//当天的零时零分
+ DateTime time3 = time.AddDays(1);//后一天
+ DateTime time4 = new DateTime(time3.Year, time3.Month, time3.Day);//后一天的零时零分
+
+ if (date > time2 && date < time4)
+ {
+ isTheDay = true;
+ }
+ else
+ {
+ isTheDay = false;
+ }
+ return isTheDay;
+ }
+ }
+}
diff --git a/GDZZ.Application/Service/LiveHistoryContacts/Dto/LiveHistoryContactsDto.cs b/GDZZ.Application/Service/LiveHistoryContacts/Dto/LiveHistoryContactsDto.cs
index 16bb6e5..ebfd0cc 100644
--- a/GDZZ.Application/Service/LiveHistoryContacts/Dto/LiveHistoryContactsDto.cs
+++ b/GDZZ.Application/Service/LiveHistoryContacts/Dto/LiveHistoryContactsDto.cs
@@ -101,7 +101,7 @@ namespace GDZZ.Application
///最新消息时间格式
///
- public DateTime LastSendTimeData { get; set; }
+ public string LastSendTimeData { get; set; }
}
diff --git a/GDZZ.Application/Service/LiveHistoryContacts/LiveHistoryContactsService.cs b/GDZZ.Application/Service/LiveHistoryContacts/LiveHistoryContactsService.cs
index 34acb3d..4bfac91 100644
--- a/GDZZ.Application/Service/LiveHistoryContacts/LiveHistoryContactsService.cs
+++ b/GDZZ.Application/Service/LiveHistoryContacts/LiveHistoryContactsService.cs
@@ -78,17 +78,13 @@ namespace GDZZ.Application
///
- /// 修改消息条数
+ /// 修改未读消息
///
///
[HttpPut("/Mini/LiveHistoryContacts/UPLive")]
public async Task UPLive(UpdateLiveHistoryContactsInput input)
{
-
-
- var entity = input.Adapt();
- await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
- await this.cacheService.DelLiveHistoryService(UserManager.UserId);
+ this.cacheService.UpUnreadAsync(input.Id);
}
@@ -149,8 +145,18 @@ namespace GDZZ.Application
if (live != null)
{
+
+ var isNow = Utils.ShowHelp(live.SendTime);
+ if (isNow)
+ {
+ liveHis.LastSendTimeData = live.SendTime.ToString("HH:mm:ss");
+ }
+ else
+ {
+ liveHis.LastSendTimeData = live.SendTime.ToString("yyyy/MM/dd");
+ }
liveHis.LastSendTime = (live.SendTime.ToUniversalTime().Ticks - 621355968000000000) / 10000;
- liveHis.LastSendTimeData = live.SendTime;
+
liveHis.LastContent = live.Content;
liveHis.Type = live.Type;
}
@@ -203,8 +209,8 @@ namespace GDZZ.Application
id = UserManager.UserId
}
};
- await this.cacheService.SetUnreadAsync(UserManager.UserId);
- await this.cacheService.SetUnreadAsync(entity.OtherUserID);
+ //await this.cacheService.SetUnreadAsync(UserManager.UserId);
+ //await this.cacheService.SetUnreadAsync(entity.OtherUserID);
var livejson = livemes.ToJsonString();
await _chatHubContext.Clients.Client(user.ConnectionId).SendMessage(livejson, "SendMessage");