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");