Browse Source

fixed: 新分页查询偏移量错误

xf 4 months ago
parent
commit
1a1d7f14a3

+ 0 - 11
src/Hotline.Application/Orders/OrderApplication.cs

@@ -3302,17 +3302,6 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         var isAdmin = _orderDomainService.IsCheckAdmin();
         if (!isAdmin)
         {
-            //query.Includes(d => d.WorkflowSteps.Where(step =>
-            //            ((step.FlowAssignType == EFlowAssignType.User && !string.IsNullOrEmpty(step.HandlerId) && step.HandlerId == _sessionContext.RequiredUserId) ||
-            //             (step.FlowAssignType == EFlowAssignType.Org && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == _sessionContext.RequiredOrgId) ||
-            //             (step.FlowAssignType == EFlowAssignType.Role && !string.IsNullOrEmpty(step.RoleId) && _sessionContext.Roles.Contains(step.RoleId)) ||
-            //             (step.FlowAssignType == EFlowAssignType.OrgAndRole && !string.IsNullOrEmpty(step.RoleId) && _sessionContext.Roles.Contains(step.RoleId)
-            //              && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == _sessionContext.RequiredOrgId)))
-            //        .OrderByDescending(step => step.CreationTime)
-            //        .Take(1)
-            //        .ToList()
-            //    );
-
             if (hasHandled)
             {
                 query.Where(d => d.WorkflowSteps

+ 4 - 2
src/Hotline.Repository.SqlSugar/Extensions/SqlSugarRepositoryExtensions.cs

@@ -52,14 +52,16 @@ namespace Hotline.Repository.SqlSugar.Extensions
         public static Task<List<TEntity>> ToPageListWithoutTotalAsync<TEntity>(this ISugarQueryable<TEntity> query, PagedRequest request, CancellationToken cancellationToken)
             where TEntity : class, new()
         {
-            return query.Skip(request.PageIndex * request.PageSize).Take(request.PageSize).ToListAsync(cancellationToken);
+            if (request.PageSize > 500) request.PageSize = 500;
+            return query.Skip((request.PageIndex - 1) * request.PageSize).Take(request.PageSize).ToListAsync(cancellationToken);
         }
 
         public static Task<List<TEntity>> ToPageListWithoutTotalAsync<TEntity>(this ISugarQueryable<TEntity> query, int pageIndex, int? pageSize = null, CancellationToken cancellationToken = default)
             where TEntity : class, new()
         {
             if (pageSize is null or 0) pageSize = 20;
-            return query.Skip(pageIndex * pageSize.Value).Take(pageSize.Value).ToListAsync(cancellationToken);
+            if (pageSize > 500) pageSize = 500;
+            return query.Skip((pageIndex - 1) * pageSize.Value).Take(pageSize.Value).ToListAsync(cancellationToken);
         }
     }
 }