From cc088900b6630b38de32af253304fa098e5a9bd1 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 7 Jun 2024 10:52:50 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E4=B8=AD=E5=BF=83=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Institution/DTO/SiteModel.cs | 7 ++++++ .../Service/Institution/SiteService.cs | 23 +++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Institution/DTO/SiteModel.cs b/IRaCIS.Core.Application/Service/Institution/DTO/SiteModel.cs index 2700f5141..fb05d4d47 100644 --- a/IRaCIS.Core.Application/Service/Institution/DTO/SiteModel.cs +++ b/IRaCIS.Core.Application/Service/Institution/DTO/SiteModel.cs @@ -47,6 +47,13 @@ namespace IRaCIS.Application.Contracts } + public class TrialSiteInQuery:PageInput + { + public string? TrialSiteName { get; set; } + + public string? TrialCode { get; set; } + } + public class TrialSiteAddView { public Guid TrialSiteId { get; set; } diff --git a/IRaCIS.Core.Application/Service/Institution/SiteService.cs b/IRaCIS.Core.Application/Service/Institution/SiteService.cs index 32df16d12..33ccf3180 100644 --- a/IRaCIS.Core.Application/Service/Institution/SiteService.cs +++ b/IRaCIS.Core.Application/Service/Institution/SiteService.cs @@ -50,16 +50,21 @@ namespace IRaCIS.Application.Services return await _siteRepository.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); } - - public async Task> GetTrialSiteList() + [HttpPost] + public async Task> GetTrialSiteList(TrialSiteInQuery inQuery) { - return _repository.Where(t => t.SiteId == null).Select(t => new TrialSiteAddView() - { - TrialCode = t.Trial.TrialCode, - TrialSiteAliasName = t.TrialSiteAliasName, - TrialSiteId = t.Id, - TrialSiteName = t.TrialSiteName - }).ToList(); + var query = _repository.Where(t => t.SiteId == null) + .WhereIf(string.IsNullOrEmpty(inQuery.TrialSiteName), t => t.TrialSiteName.Contains(inQuery.TrialSiteName) || t.TrialSiteAliasName.Contains(inQuery.TrialSiteName)) + .WhereIf(string.IsNullOrEmpty(inQuery.TrialCode), t => t.Trial.TrialCode.Contains(inQuery.TrialCode)) + .Select(t => new TrialSiteAddView() + { + TrialCode = t.Trial.TrialCode, + TrialSiteAliasName = t.TrialSiteAliasName, + TrialSiteId = t.Id, + TrialSiteName = t.TrialSiteName + }); + + return await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? nameof(TrialSiteAddView.TrialCode) : inQuery.SortField, inQuery.Asc); } /// 添加研究中心