From 754da2c7fc76947f3deaed928f1279b27c4a415a Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Tue, 20 Aug 2024 13:50:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/QC/QCQuestionService.cs | 3 +- .../ClinicalData/ClinicalAnswerService.cs | 2 +- .../ReadingMedicineQuestionService.cs | 2 +- .../_IRaCIS/IQueryablePageListExtensions.cs | 48 ------------------- 4 files changed, 4 insertions(+), 51 deletions(-) diff --git a/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs b/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs index 3e9a526e9..a72e93ea7 100644 --- a/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs @@ -7,6 +7,7 @@ using IRaCIS.Core.Application.Service.Reading.Dto; using IRaCIS.Core.Infra.EFCore.Common; using IRaCIS.Core.Infrastructure; +using IRaCIS.Core.Infrastructure.Extention; using Microsoft.AspNetCore.Mvc; namespace IRaCIS.Core.Application.Contracts @@ -106,7 +107,7 @@ namespace IRaCIS.Core.Application.Contracts var defalutSortArray = new string[] { nameof(QCQuestionConfigureView.LanguageType) + " desc", nameof(QCQuestionConfigureView.ShowOrder) }; - return await QCQuestionQueryable.ToPagedListAsync(queryQCQuestionConfigure.PageIndex, queryQCQuestionConfigure.PageSize, new string[2] { "LanguageType desc", "ShowOrder asc" }); + return await QCQuestionQueryable.ToPagedListAsync(queryQCQuestionConfigure, queryQCQuestionConfigure.SortField.IsNullOrEmpty(), defalutSortArray); } public async Task AddOrUpdateQCQuestionConfigure(QCQuestionAddOrEdit addOrEditQCQuestionConfigure) diff --git a/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalAnswerService.cs b/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalAnswerService.cs index 8f299b175..246cfc8b7 100644 --- a/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalAnswerService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalAnswerService.cs @@ -639,7 +639,7 @@ namespace IRaCIS.Core.Application.Service var defalutSortArray = new string[] { nameof(GetCRCConfirmListOutDto.SubjectCode) + " desc", nameof(GetCRCConfirmListOutDto.LatestScanDate) }; - var result = await query.ToPagedListAsync(inDto.PageIndex, inDto.PageSize, new string[2] { "SubjectCode asc", "LatestScanDate asc" }); + var result = await query.ToPagedListAsync(inDto,inDto.SortField.IsNullOrEmpty(), defalutSortArray); var formList = await _clinicalFormRepository.Where(x => x.TrialId == inDto.TrialId) .Where(x => x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC) diff --git a/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicineQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicineQuestionService.cs index a148bed8f..a64666ede 100644 --- a/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicineQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicineQuestionService.cs @@ -67,7 +67,7 @@ namespace IRaCIS.Core.Application.Service var defalutSortArray = new string[] { nameof(ReadingMedicineSystemQuestionView.LanguageType) + " desc", nameof(ReadingMedicineSystemQuestionView.ShowOrder) }; - return await query.ToPagedListAsync(inDto.PageIndex, inDto.PageSize, new string[2] { "LanguageType desc", "ShowOrder asc" }); + return await query.ToPagedListAsync(inDto, inDto.SortField.IsNullOrEmpty(), defalutSortArray); } /// diff --git a/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryablePageListExtensions.cs b/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryablePageListExtensions.cs index d04cc4ca8..9bc8ea98c 100644 --- a/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryablePageListExtensions.cs +++ b/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryablePageListExtensions.cs @@ -149,54 +149,6 @@ namespace IRaCIS.Core.Infrastructure.Extention } - - - - //多字段排序异步 ["a asc", "b desc", "c asc"] - public static async Task> ToPagedListAsync(this IQueryable source, int pageNumber, int pageSize, string[] sortArray) - { - if (pageNumber <= 0) - { - pageNumber = 1; - } - if (pageSize <= 0) - { - pageSize = 10; - } - - var count = await source.CountAsync().ConfigureAwait(false); - - if (count == 0) - { - return new PageOutput() { CurrentPageData = new T[0] }; - } - - if(sortArray.Count()>0) - { - var sortString = string.Join(',', sortArray); - - source = source.OrderBy(sortString); - } - - - source = source.Skip((pageNumber - 1) * pageSize); - var items = await source - .Take(pageSize) - .ToArrayAsync() - .ConfigureAwait(false); - - var pagedList = new PageOutput() - { - PageIndex = pageNumber, - PageSize = pageSize, - TotalCount = count, - CurrentPageData = items - }; - - return pagedList; - } - - #region 同步方法废弃 ////单字段排序 //public static PageOutput ToPagedList(this IQueryable source, int pageIndex, int pageSize, string defaultSortFiled = "Id", bool isAsc = true)