Quellcode durchsuchen

解决合并冲突

qinchaoyue vor 1 Tag
Ursprung
Commit
0ae1d4d102

+ 2 - 2
src/Hotline.Api/Controllers/IdentityController.cs

@@ -119,7 +119,7 @@ jxrWXHbT1FB6DqkdOnBbQqS1Azqz5HxLlSyEK3F60e3SgB5iZsDZ
     [AllowAnonymous]
     [HttpPost("third/token")]
     public async Task<Dictionary<string, object>> GetThirdTokenAsync([FromBody] ThirdTokenInDto dto)
-        => await _identityAppService.GetThredTokenAsync(dto, HttpContext.RequestAborted);
+        => await _identityAppService.GetThirdTokenAsync(dto, HttpContext.RequestAborted);
 
 
     /// <summary>
@@ -130,7 +130,7 @@ jxrWXHbT1FB6DqkdOnBbQqS1Azqz5HxLlSyEK3F60e3SgB5iZsDZ
     [LogFilterAlpha("老系统微信用户登录")]
     [HttpPost("third/login")]
     public async Task<Dictionary<string, object>> GetThirdLoginAsync([FromBody] ThirdOpenIdInDto dto)
-            => await _identityAppService.GetThredTokenAsync(dto, HttpContext.RequestAborted);
+            => await _identityAppService.GetThirdTokenAsync(dto, HttpContext.RequestAborted);
 
     /// <summary>
     /// 根据OpenId刷新令牌

+ 1 - 1
src/Hotline.Api/Controllers/Snapshot/BiSnapshotController.cs

@@ -334,6 +334,6 @@ public class BiSnapshotController : BaseController
     /// <param name="dto"></param>
     /// <returns></returns>
     [HttpGet("county_points")]
-    public async Task<IList<SnapshotCountyPointsStatisticsOutDto>> Get([FromQuery] SnapshotCountyPointsStatisticsInDto dto)
+    public async Task<IList<SnapshotCountyPointsStatisticsOutDto>> GetAreaPointsStatistics([FromQuery] SnapshotCountyPointsStatisticsInDto dto)
         => await _biSnapshotApplication.GetAreaPointsStatistics(dto).ToListAsync(HttpContext.RequestAborted);
 }

+ 1 - 0
src/Hotline.Api/Controllers/Snapshot/SnapshotController.cs

@@ -32,6 +32,7 @@ using XF.Domain.Authentications;
 using XF.Domain.Exceptions;
 using XF.Domain.Filters;
 using XF.Domain.Repository;
+using BulletinOutDto = Hotline.Share.Dtos.Article.BulletinOutDto;
 
 namespace Hotline.Api.Controllers.Snapshot;
 

+ 2 - 2
src/Hotline.Application/Identity/IIdentityAppService.cs

@@ -20,7 +20,7 @@ namespace Hotline.Application.Identity
         /// <param name="dto"></param>
         /// <returns></returns>
         /// <exception cref="UserFriendlyException"></exception>
-        Task<Dictionary<string, object>> GetThredTokenAsync(ThirdTokenInDto dto, CancellationToken token);
+        Task<Dictionary<string, object>> GetThirdTokenAsync(ThirdTokenInDto dto, CancellationToken token);
 
         /// <summary>
         /// 第三方登录
@@ -28,7 +28,7 @@ namespace Hotline.Application.Identity
         /// <param name="dto"></param>
         /// <param name="token"></param>
         /// <returns></returns>
-        Task<Dictionary<string, object>> GetThredTokenAsync(ThirdOpenIdInDto dto, CancellationToken token);
+        Task<Dictionary<string, object>> GetThirdTokenAsync(ThirdOpenIdInDto dto, CancellationToken token);
 
         /// <summary>
         /// 根据OpenId刷新令牌

+ 3 - 3
src/Hotline.Application/Identity/IdentityAppService.cs

@@ -330,7 +330,7 @@ public class IdentityAppService : IIdentityAppService, IScopeDependency
     /// <param name="dto"></param>
     /// <returns></returns>
     /// <exception cref="UserFriendlyException"></exception>
-    public async Task<Dictionary<string, object>> GetThredTokenAsync(ThirdTokenInDto dto, CancellationToken token)
+    public async Task<Dictionary<string, object>> GetThirdTokenAsync(ThirdTokenInDto dto, CancellationToken token)
     {
         var thirdDto = dto.Adapt<ThirdTokenDto>();
         thirdDto = await _thirdAccountDomainFactory.GetThirdParameterAsync(thirdDto, token);
@@ -345,10 +345,10 @@ public class IdentityAppService : IIdentityAppService, IScopeDependency
             ThirdType = dto.ThirdType,
             PhoneNumber = phone.PhoneNumber
         };
-        return await GetThredTokenAsync(inDto, token);
+        return await GetThirdTokenAsync(inDto, token);
     }
 
-    public async Task<Dictionary<string, object>> GetThredTokenAsync(ThirdOpenIdInDto dto, CancellationToken token)
+    public async Task<Dictionary<string, object>> GetThirdTokenAsync(ThirdOpenIdInDto dto, CancellationToken token)
     {
         var thirdAccount = await _thirdAccountRepository.GetByOpenIdAsync(dto.OpenId, token);
 

+ 1 - 0
src/Hotline.Application/Snapshot/Contracts/ISnapshotApplication.cs

@@ -2,6 +2,7 @@
 using Hotline.Share.Dtos.Article;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Snapshot;
+using BulletinOutDto = Hotline.Share.Dtos.Article.BulletinOutDto;
 
 namespace Hotline.Application.Snapshot.Contracts;
 public interface ISnapshotApplication

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
src/Hotline.Application/Snapshot/DefaultSnapshotApplication.cs


+ 42 - 1
src/Hotline.Application/Snapshot/SnapshotApplicationBase.cs

@@ -41,6 +41,7 @@ using Hotline.Settings.Hotspots;
 using Microsoft.Extensions.Options;
 using XF.Utility.MQ;
 using System.Threading;
+using BulletinOutDto = Hotline.Share.Dtos.Article.BulletinOutDto;
 using NPOI.SS.Formula.Functions;
 
 namespace Hotline.Application.Snapshot;
@@ -398,7 +399,7 @@ public abstract class SnapshotApplicationBase
     {
         var items = await _notificationReceiverRepository.Queryable()
             .LeftJoin<Notification>((m , notify) => m.NotificationId == notify.Id)
-            .Where(m => m.ReceiverId == _sessionContext.UserId)
+            .Where((m, notify) => m.ReceiverId == _sessionContext.UserId && dto.NotifyType == notify.NotifyType)
             .Select((m, notify) => new GetNotifyOutDto 
             {
                 NotificationId = m.NotificationId,
@@ -1058,6 +1059,46 @@ public abstract class SnapshotApplicationBase
             item.Insert(0, my);
         }
         outDto.Ranks = item;
+
+
+        outDto.VideoBulletin = await _notificationReceiverRepository.Queryable()
+            .LeftJoin<Notification>((receiver, notify) => notify.Id == receiver.NotificationId)
+            .LeftJoin<SnapshotBulletin>((receiver, notify, bulletin) => bulletin.Id == notify.ExternalId)
+            .Where((receiver, notify) => receiver.ReceiverId == _sessionContext.UserId)
+            .GroupBy((receiver, notify, bulletin) => new 
+            {
+                notify.Title,
+                notify.ExternalId,
+                bulletin.SnapshotBulletinTypeName,
+                bulletin.VideoCoverImgUrl,
+                notify.CreationTime
+            })
+            .OrderByDescending((receiver, notify) => notify.CreationTime)
+            .Select((receiver, notify, bulletin) => new VideoBulletinOutDto
+            {
+                Title = notify.Title,
+                BulletinId = notify.ExternalId,
+                UnReadCount = SqlFunc.AggregateSum(SqlFunc.IIF( receiver.IsRead == false, 1, 0)),
+                SnapshotBulletinTypeName = bulletin.SnapshotBulletinTypeName,
+                VideoCoverImgUrl = bulletin.VideoCoverImgUrl,
+            }).FirstAsync();
+
+        outDto.Bulletins = new PointsBulletinOutDto
+        {
+            Items = await _notificationReceiverRepository.Queryable()
+                .LeftJoin<Notification>((receiver, notify) => notify.Id == receiver.NotificationId)
+                .Select((receiver, notify) => new PointsBulletinItemsOutDto
+                {
+                    BulletinId = notify.ExternalId,
+                    Title = notify.Title,
+                }, true)
+                .Take(2)
+                .ToListAsync(),
+            UnReadCount = await _notificationReceiverRepository.Queryable()
+            .Where(m => m.IsRead == false && m.ReceiverId == _sessionContext.UserId)
+            .CountAsync()
+        };
+
         return outDto;
     }
     #endregion

+ 1 - 0
src/Hotline.Application/Snapshot/SnapshotBulletinApplication.cs

@@ -103,6 +103,7 @@ public class SnapshotBulletinApplication : ISnapshotBulletinApplication, IScopeD
                             {
                                 inDto.NotifyType = ENotificationType.Video;
                             }
+                            inDto.ExternalId = bulletion.Id;
                             await _notificationDomainService.AddNotifyAsync(inDto, token);
                         });
                 }

+ 5 - 1
src/Hotline.Share/Dtos/Snapshot/NotifyDto.cs

@@ -29,6 +29,8 @@ public class AddNotifyInDto
     /// </summary>
     public ENotificationType NotifyType { get; set; }
 
+    public string ExternalId { get; set; }
+
     /// <summary>
     /// 用户
     /// </summary>
@@ -38,7 +40,9 @@ public class AddNotifyInDto
 public class GetNotifyInDto : QueryFixedDto
 {
     /// <summary>
-    /// 消息类型
+    /// 消息类型:
+    /// 0: 通知公告
+    /// 1: 宣传视频
     /// </summary>
     public ENotificationType NotifyType { get; set; }
 }

+ 64 - 0
src/Hotline.Share/Dtos/Snapshot/PointsDto.cs

@@ -115,6 +115,70 @@ public class PointsRankOutDto
     /// 排行
     /// </summary>
     public IList<PointsRankUserDto> Ranks { get; set; }
+
+    /// <summary>
+    /// 视频公告
+    /// </summary>
+    public VideoBulletinOutDto VideoBulletin { get; set; }
+
+    /// <summary>
+    /// 通知公告
+    /// </summary>
+    public PointsBulletinOutDto Bulletins { get; set; }
+}
+
+public class PointsBulletinOutDto
+{
+    /// <summary>
+    /// 未读个数
+    /// </summary>
+    public int UnReadCount { get; set; }
+
+    /// <summary>
+    /// Summary
+    /// </summary>
+    public IList<PointsBulletinItemsOutDto> Items { get; set; }
+}
+
+public class PointsBulletinItemsOutDto
+{
+    /// <summary>
+    /// Id
+    /// </summary>
+    public string BulletinId { get; set; }
+
+    /// <summary>
+    /// 标题
+    /// </summary>
+    public string Title { get; set; }
+}
+
+public class VideoBulletinOutDto
+{
+    /// <summary>
+    /// Id
+    /// </summary>
+    public string BulletinId { get; set; }
+
+    /// <summary>
+    /// 标题
+    /// </summary>
+    public string Title { get; set; }
+
+    /// <summary>
+    /// 栏目
+    /// </summary>
+    public string SnapshotBulletinTypeName { get; set; }
+
+    /// <summary>
+    /// 视频封面
+    /// </summary>
+    public string VideoCoverImgUrl { get; set; }
+
+    /// <summary>
+    /// 未读个数
+    /// </summary>
+    public int UnReadCount { get; set; }
 }
 
 public class PointsRankUserDto

+ 6 - 0
src/Hotline.Share/Enums/Snapshot/ENotificationType.cs

@@ -9,9 +9,15 @@ namespace Hotline.Share.Enums.Snapshot;
 
 public enum ENotificationType
 {
+    /// <summary>
+    /// 通知公告
+    /// </summary>
     [Description("消息")]
     Message = 0,
 
+    /// <summary>
+    /// 宣传视频
+    /// </summary>
     [Description("视频")]
     Video = 1
 }

+ 7 - 0
src/Hotline/Snapshot/Notification.cs

@@ -1,4 +1,5 @@
 using Hotline.Share.Enums.Snapshot;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -24,4 +25,10 @@ public class Notification : CreationSoftDeleteEntity
     /// 类型
     /// </summary>
     public ENotificationType NotifyType { get; set; }
+
+    /// <summary>
+    /// 外部业务唯一标识
+    /// </summary>
+    [SugarColumn(ColumnDescription = "外部业务唯一标识")]
+    public string? ExternalId { get; set; }
 }

+ 4 - 4
test/Hotline.Tests/Application/PointsRecordApplicationTest.cs

@@ -5,6 +5,7 @@ using Hotline.Identity.Roles;
 using Hotline.Orders;
 using Hotline.Settings;
 using Hotline.Share.Dtos.Snapshot;
+using Hotline.Share.Tools;
 using Hotline.Snapshot.IRepository;
 using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
@@ -83,9 +84,8 @@ public class PointsRecordApplicationTest : TestBase
         SetWeiXin();
         var item = await _snapshotApplication.GetPointsRankAsync();
         item.ShouldNotBeNull();
-        foreach (var a in item.Ranks)
-        {
-            var s = a.PhoneNumber;
-        }
+        item.Bulletins.Items.Any(m => m.Title.IsNullOrEmpty()).ShouldBeFalse();
+        item.Bulletins.Items.Any(m => m.BulletinId.IsNullOrEmpty()).ShouldBeFalse();
+        item.VideoBulletin.ShouldNotBeNull();
     }
 }

+ 2 - 2
test/Hotline.Tests/Application/SnapshotApplicationTest.cs

@@ -251,7 +251,7 @@ public class SnapshotApplicationTest : TestBase
     [Fact]
     public async Task RefreshTokenAsync()
     {
-        var token = await _identityAppService.GetThredTokenAsync(new ThirdTokenInDto(), CancellationToken.None);
+        var token = await _identityAppService.GetThirdTokenAsync(new ThirdTokenInDto(), CancellationToken.None);
         var newToken = await _identityAppService.RefreshTokenAsync(token["OpenId"].ToString(), CancellationToken.None);
         newToken.ShouldNotBeNull();
         newToken["OpenId"].ShouldBe(token["OpenId"].ToString());
@@ -265,7 +265,7 @@ public class SnapshotApplicationTest : TestBase
     [Fact]
     public async Task GetThirdToken_Test()
     {
-        var result = await _identityAppService.GetThredTokenAsync(new ThirdTokenInDto { AppType = EAppType.Snapshot, ThirdType = EThirdType.WeChat, LoginCode = "0c3Adhll2zDMBe413rnl2KvEym2AdhlH" }, CancellationToken.None);
+        var result = await _identityAppService.GetThirdTokenAsync(new ThirdTokenInDto { AppType = EAppType.Snapshot, ThirdType = EThirdType.WeChat,   LoginCode = "0c3Adhll2zDMBe413rnl2KvEym2AdhlH" }, CancellationToken.None);
         result["PhoneNumber"].ToString().ShouldNotBeNullOrEmpty();
     }
 

+ 2 - 2
test/Hotline.Tests/Application/SnapshotBulletionApplicationTest.cs

@@ -81,11 +81,11 @@ public class SnapshotBulletionApplicationTest : TestBase
             Reason = "审核通过"
         };
         await _snapshotBulletinApplication.ExamineBulletinAsync(examineDto, CancellationToken.None);
-        Thread.Sleep(5 * 1000);
+        Thread.Sleep(10 * 1000);
         //await _snapshotBulletinApplication.NotifyUserAsync(bulletinId, CancellationToken.None);
 
 
-        var notifyItems = await _snapshotApplication.GetNotificationAsync(new GetNotifyInDto(), CancellationToken.None);
+        var notifyItems = await _snapshotApplication.GetNotificationAsync(new GetNotifyInDto { NotifyType = Share.Enums.Snapshot.ENotificationType.Video}, CancellationToken.None);
         notifyItems.Any(m => m.Title == inDto.Title).ShouldBeTrue();
     }
 }

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.