Преглед на файлове

注释SignalR - Login 代码
消息通知列表分类分页(操作通知,任务通知)

leiy преди 1 година
родител
ревизия
bf2a3f1f25
променени са 2 файла, в които са добавени 21 реда и са изтрити 13 реда
  1. 0 6
      OASystem/OASystem.Api/Controllers/AuthController.cs
  2. 21 7
      OASystem/OASystem.Infrastructure/Repositories/System/MessageRepository.cs

+ 0 - 6
OASystem/OASystem.Api/Controllers/AuthController.cs

@@ -111,12 +111,6 @@ namespace OASystem.API.Controllers
 
             }
 
-
-            #region signalR
-            new MyHub().Login(uId.ToString()); ;
-
-            #endregion
-
             #region 测试添加系统消息
 
             //await _message.AddMsg(new MessageDto()

+ 21 - 7
OASystem/OASystem.Infrastructure/Repositories/System/MessageRepository.cs

@@ -1,6 +1,8 @@
-using NPOI.SS.Formula.Functions;
+using NPOI.POIFS.Crypt.Dsig;
+using NPOI.SS.Formula.Functions;
 using OASystem.Domain;
 using OASystem.Domain.Dtos.System;
+using OASystem.Domain.ViewModels.QiYeWeChat;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -113,25 +115,37 @@ namespace OASystem.Infrastructure.Repositories.System
                 var _readableMsgList = await _sqlSugar.SqlQueryable<ReadbleMessageView>(msgSqlWhere).ToListAsync();
                 if (_readableMsgList.Count > 0)
                 {
-                    int pageIndex = dto.PageIndex;
-                    int pageSize = pageIndex + 9;
+                    int pageSize = dto.PageSize; // 每页显示的记录数量
+                    int currentPage = dto.PageIndex; // 当前页码(从1开始)
+
+                    
                     //操作通知 OperationNotification
                     List<int> operationTypeList = new List<int>() {1,2,3,4,5 };
                     var operationNotificatioData = _readableMsgList.Where(it => operationTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
+                    int operationNotificatioDataCount = operationNotificatioData.Count;
+                    // 计算起始索引和结束索引
+                    int operationStartIndex = (currentPage - 1) * pageSize;
+                    int operationEndIndex = Math.Min(operationStartIndex + pageSize, operationNotificatioDataCount);
+
                     var operationNotificatioDataView = new {
-                        Count = operationNotificatioData.Count,
+                        Count = operationNotificatioDataCount,
                         UnReadCount = operationNotificatioData.Where(it => it.IsRead == 0).Count(),
-                        OperationNotificatioData = operationNotificatioData.Skip(pageIndex).Take(pageSize).ToList()
+                        OperationNotificatioData = operationNotificatioData.Skip(operationStartIndex).Take(pageSize).ToList()
                     };
 
                     //任务通知 TaskNotification
                     List<int> taskTypeList = new List<int>() { 6 };
                     var taskNotificatioData = _readableMsgList.Where(it => taskTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
+                    int taskNotificatioDataCount = taskNotificatioData.Count;
+                    // 计算起始索引和结束索引
+                    int taskStartIndex = (currentPage - 1) * pageSize;
+                    int taskEndIndex = Math.Min(operationStartIndex + pageSize, operationNotificatioDataCount);
+
                     var taskNotificatioDataView = new
                     {
-                        Count = taskNotificatioData.Count,
+                        Count = taskNotificatioDataCount,
                         UnReadCount = taskNotificatioData.Where(it => it.IsRead == 0).Count(),
-                        TaskNotificatioData = taskNotificatioData.Skip(pageIndex).Take(pageSize).ToList()
+                        TaskNotificatioData = taskNotificatioData.Skip(taskStartIndex).Take(pageSize).ToList()
                     };
 
                     var _view = new {