修改分页参数
continuous-integration/drone/push Build is passing Details

IRC_NewDev
hang 2024-08-20 13:59:52 +08:00
parent a579c26ada
commit 9e1cc1521f
4 changed files with 37 additions and 37 deletions

View File

@ -107,7 +107,7 @@ namespace IRaCIS.Core.Application.Contracts
var defalutSortArray = new string[] { nameof(QCQuestionConfigureView.LanguageType) + " desc", nameof(QCQuestionConfigureView.ShowOrder) }; var defalutSortArray = new string[] { nameof(QCQuestionConfigureView.LanguageType) + " desc", nameof(QCQuestionConfigureView.ShowOrder) };
return await QCQuestionQueryable.ToPagedListAsync(queryQCQuestionConfigure, queryQCQuestionConfigure.SortField.IsNullOrEmpty(), defalutSortArray); return await QCQuestionQueryable.ToPagedListAsync(queryQCQuestionConfigure, defalutSortArray);
} }
public async Task<IResponseOutput> AddOrUpdateQCQuestionConfigure(QCQuestionAddOrEdit addOrEditQCQuestionConfigure) 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 defalutSortArray = new string[] { nameof(GetCRCConfirmListOutDto.SubjectCode) + " desc", nameof(GetCRCConfirmListOutDto.LatestScanDate) };
var result = await query.ToPagedListAsync(inDto,inDto.SortField.IsNullOrEmpty(), defalutSortArray); var result = await query.ToPagedListAsync(inDto, defalutSortArray);
var formList = await _clinicalFormRepository.Where(x => x.TrialId == inDto.TrialId) var formList = await _clinicalFormRepository.Where(x => x.TrialId == inDto.TrialId)
.Where(x => x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC) .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) }; var defalutSortArray = new string[] { nameof(ReadingMedicineSystemQuestionView.LanguageType) + " desc", nameof(ReadingMedicineSystemQuestionView.ShowOrder) };
return await query.ToPagedListAsync(inDto, inDto.SortField.IsNullOrEmpty(), defalutSortArray); return await query.ToPagedListAsync(inDto, defalutSortArray);
} }
/// <summary> /// <summary>

View File

@ -14,15 +14,15 @@ namespace IRaCIS.Core.Infrastructure.Extention
{ {
//单字段排序 异步 (或者默认排序字段是空,多字段排序,传递了,就以传递的单字段为准) //单字段排序 异步 (或者默认排序字段是空,多字段排序,传递了,就以传递的单字段为准)
public static async Task<PageOutput<T>> ToPagedListAsync<T>(this IQueryable<T> source, PageInput pageInput, bool isMultiSortFiled = false, string[] sortArray = default, CancellationToken cancellationToken = default) public static async Task<PageOutput<T>> ToPagedListAsync<T>(this IQueryable<T> source, PageInput pageInput, string[] sortArray = default, CancellationToken cancellationToken = default)
{ {
var isMultiSortFiled = true;
if (isMultiSortFiled && sortArray == default) if (string.IsNullOrWhiteSpace(pageInput.SortField) && sortArray != default)
{ {
throw new InvalidOperationException("The sort field must be specified"); isMultiSortFiled = true;
} }
if (pageInput.PageIndex <= 0) if (pageInput.PageIndex <= 0)
{ {
pageInput.PageIndex = 1; pageInput.PageIndex = 1;
@ -39,7 +39,16 @@ namespace IRaCIS.Core.Infrastructure.Extention
return new PageOutput<T>() { CurrentPageData = new T[0] }; return new PageOutput<T>() { CurrentPageData = new T[0] };
} }
var propName=string.Empty; if (isMultiSortFiled)
{
var sortString = string.Join(',', sortArray);
source = source.OrderBy(sortString);
}
else
{
var propName = string.Empty;
if (string.IsNullOrWhiteSpace(pageInput.SortField)) if (string.IsNullOrWhiteSpace(pageInput.SortField))
{ {
@ -52,7 +61,7 @@ namespace IRaCIS.Core.Infrastructure.Extention
} }
else else
{ {
propName= propertyNameList.Contains("Id") ? "Id" : propertyNameList.FirstOrDefault(); propName = propertyNameList.Contains("Id") ? "Id" : propertyNameList.FirstOrDefault();
} }
} }
@ -62,18 +71,9 @@ namespace IRaCIS.Core.Infrastructure.Extention
propName = pageInput.SortField; propName = pageInput.SortField;
} }
if (!isMultiSortFiled)
{
source = pageInput.Asc ? source.OrderBy(propName) : source.OrderBy(propName + " desc"); source = pageInput.Asc ? source.OrderBy(propName) : source.OrderBy(propName + " desc");
} }
else
{
var sortString = string.Join(',', sortArray);
source = source.OrderBy(sortString);
}
source = source.Skip((pageInput.PageIndex - 1) * pageInput.PageSize); source = source.Skip((pageInput.PageIndex - 1) * pageInput.PageSize);
var items = await source var items = await source