From ee99818b6d020b32cc73aa38af4c8df6280241ab Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Wed, 1 Jun 2022 09:38:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/UploadDownLoadController.cs | 42 +++++++++++++------ IRaCIS.Core.API/IRaCIS.Core.API.xml | 2 +- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs index 41d760195..170aae99a 100644 --- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs @@ -402,22 +402,40 @@ namespace IRaCIS.Core.API.Controllers /// /// /// - [HttpPost("ClinicalData/UploadClinicalData/{trialId:guid}/{subjectId:guid}")] + [HttpPost("ClinicalData/UploadClinicalData/{id:guid}/{isVisit:bool}")] [DisableRequestSizeLimit] - public async Task UploadClinicalData(Guid trialId,Guid subjectId) + public async Task UploadClinicalData(Guid id, bool isVisit) { - - var filerelativePath = string.Empty; - await FileUploadAsync(async (fileName) => + if (isVisit) { - var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetClinicalDataPath(_hostEnvironment, fileName, trialId, subjectId); - filerelativePath = relativePath; - - return relativePath; - }); - - await _repository.SaveChangesAsync(); + var sv = _repository.Where(t => t.Id == id).Select(t => new { t.TrialId, t.SiteId, t.SubjectId }).FirstOrDefault().IfNullThrowException(); + await FileUploadAsync(async (fileName) => + { + var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetClinicalDataPath(_hostEnvironment, fileName, sv.TrialId, sv.SiteId, sv.SubjectId, id); + //插入临床pdf 路径 + filerelativePath = relativePath; + return serverFilePath; + }); + } + else + { + var subjectId = await _repository.Where(x => x.Id == id).Select(x => + x.SubjectId + ).FirstOrDefaultAsync(); + var subject = await _repository.Where(x => x.Id == subjectId).Select(x => new + { + x.TrialId, + x.SiteId, + }).FirstOrDefaultAsync(); + await FileUploadAsync(async (fileName) => + { + var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetClinicalDataPath(_hostEnvironment, fileName, subject.TrialId, subject.SiteId, subjectId.Value, id); + //插入临床pdf 路径 + filerelativePath = relativePath; + return serverFilePath; + }); + } return ResponseOutput.Ok(filerelativePath); } diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.xml b/IRaCIS.Core.API/IRaCIS.Core.API.xml index 6bdc70cca..d0ea724ec 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.xml +++ b/IRaCIS.Core.API/IRaCIS.Core.API.xml @@ -171,7 +171,7 @@ - + 上传临床数据