Selaa lähdekoodia

增加返回排行榜页面通知内容

qinchaoyue 1 päivä sitten
vanhempi
commit
fd6e6f8183

+ 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>
@@ -133,7 +133,7 @@ jxrWXHbT1FB6DqkdOnBbQqS1Azqz5HxLlSyEK3F60e3SgB5iZsDZ
     [AllowAnonymous]
     [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

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
src/Hotline.Application/Snapshot/DefaultSnapshotApplication.cs


+ 28 - 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;
 
 namespace Hotline.Application.Snapshot;
 
@@ -397,7 +398,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,
@@ -1009,6 +1010,32 @@ public abstract class SnapshotApplicationBase
                 m.HeadUrl = _systemDicDataCacheManager.HeaderImages("default");
         });
         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)
+            .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 = await _notificationReceiverRepository.Queryable()
+            .LeftJoin<Notification>((receiver, notify) => notify.Id == receiver.NotificationId)
+            .Select((receiver, notify) => new PointsBulletinOutDto 
+            {
+                BulletinId = notify.ExternalId,
+                Title = notify.Title,
+            }, true)
+            .Take(2)
+            .ToListAsync();
+
         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);
                         });
                 }

+ 2 - 0
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>

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

@@ -115,6 +115,57 @@ public class PointsRankOutDto
     /// 排行
     /// </summary>
     public IList<PointsRankUserDto> Ranks { get; set; }
+
+    /// <summary>
+    /// 视频公告
+    /// </summary>
+    public VideoBulletinOutDto VideoBulletin { get; set; }
+
+    /// <summary>
+    /// 通知公告
+    /// </summary>
+    public IList<PointsBulletinOutDto> Bulletins { get; set; }
+}
+
+public class PointsBulletinOutDto
+{
+    /// <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

+ 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; }
 }

+ 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();
     }
 

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä