Browse Source

消息分页 调整

leiy 1 year ago
parent
commit
653825016d
1 changed files with 29 additions and 24 deletions
  1. 29 24
      OASystem/OASystem.Api/Controllers/SystemController.cs

+ 29 - 24
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -158,40 +158,45 @@ namespace OASystem.API.Controllers
             var _readableMsgList = await _sqlSugar.SqlQueryable<ReadbleMessageView>(msgSqlWhere).ToListAsync();
             if (_readableMsgList.Count > 0)
             {
-                int pageSize = dto.PageSize; // 每页显示的记录数量
-                int currentPage = dto.PageIndex; // 当前页码(从1开始)
 
-                if (dto.Type == 1) //团组操作通知
+                if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3)
                 {
-                    //操作通知 OperationNotification
-                    var operationNotificationData = _readableMsgList.Where(it => _operationTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
-                    int operationNotificationDataCount = operationNotificationData.Count;
-                    // 计算起始索引和结束索引
-                    int operationStartIndex = (currentPage - 1) * pageSize;
-                    int operationEndIndex = Math.Min(operationStartIndex + pageSize, operationNotificationDataCount);
+                    int pageSize = dto.PageSize; // 每页显示的记录数量
+                    int currentPage = dto.PageIndex; // 当前页码(从1开始)
 
-                    var operationNotificationDataView = operationNotificationData.Skip(operationStartIndex).Take(pageSize).ToList();
+                    if (dto.Type == 1) //团组操作通知
+                    {
+                        //操作通知 OperationNotification
+                        var operationNotificationData = _readableMsgList.Where(it => _operationTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
+                        int operationNotificationDataCount = operationNotificationData.Count;
+                        // 计算起始索引和结束索引
+                        int operationStartIndex = (currentPage - 1) * pageSize;
+                        int operationEndIndex = Math.Min(operationStartIndex + pageSize, operationNotificationDataCount);
 
-                    return Ok(JsonView(true, "成功", operationNotificationDataView, operationNotificationDataCount));
-                }
-                else if (dto.Type == 2) //2 任务操作通知
-                {
+                        var operationNotificationDataView = operationNotificationData.Skip(operationStartIndex).Take(pageSize).ToList();
+
+                        return Ok(JsonView(true, "成功", operationNotificationDataView, operationNotificationDataCount));
+                    }
+                    else if (dto.Type == 2) //2 任务操作通知
+                    {
 
-                    //任务通知 TaskNotification
-                    List<int> taskTypeList = new List<int>() { 6 };
-                    var taskNotificationData = _readableMsgList.Where(it => taskTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
-                    int taskNotificationDataCount = taskNotificationData.Count;
-                    // 计算起始索引和结束索引
-                    int taskStartIndex = (currentPage - 1) * pageSize;
-                    int taskEndIndex = Math.Min(taskStartIndex + pageSize, taskNotificationDataCount);
+                        //任务通知 TaskNotification
+                        List<int> taskTypeList = new List<int>() { 6 };
+                        var taskNotificationData = _readableMsgList.Where(it => taskTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
+                        int taskNotificationDataCount = taskNotificationData.Count;
+                        // 计算起始索引和结束索引
+                        int taskStartIndex = (currentPage - 1) * pageSize;
+                        int taskEndIndex = Math.Min(taskStartIndex + pageSize, taskNotificationDataCount);
 
-                    var taskNotificationDataView = taskNotificationData.Skip(taskStartIndex).Take(pageSize).ToList();
+                        var taskNotificationDataView = taskNotificationData.Skip(taskStartIndex).Take(pageSize).ToList();
+
+                        return Ok(JsonView(true, "成功", taskNotificationDataView, taskNotificationDataCount));
+                    }
 
-                    return Ok(JsonView(true, "成功", taskNotificationDataView, taskNotificationDataCount));
                 }
             }
 
-            return Ok(JsonView(false));
+            return Ok(JsonView(true,"操作成功!" ,new List<int>() { }, 0));
         }