代码修改

IRC_NewDev
he 2024-08-20 13:50:03 +08:00
parent 7194796841
commit 754da2c7fc
4 changed files with 4 additions and 51 deletions

View File

@ -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<IResponseOutput> AddOrUpdateQCQuestionConfigure(QCQuestionAddOrEdit addOrEditQCQuestionConfigure)

View File

@ -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)

View File

@ -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);
}
/// <summary>

View File

@ -149,54 +149,6 @@ namespace IRaCIS.Core.Infrastructure.Extention
}
//多字段排序异步 ["a asc", "b desc", "c asc"]
public static async Task<PageOutput<T>> ToPagedListAsync<T>(this IQueryable<T> 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<T>() { 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<T>()
{
PageIndex = pageNumber,
PageSize = pageSize,
TotalCount = count,
CurrentPageData = items
};
return pagedList;
}
#region 同步方法废弃
////单字段排序
//public static PageOutput<T> ToPagedList<T>(this IQueryable<T> source, int pageIndex, int pageSize, string defaultSortFiled = "Id", bool isAsc = true)