From a7429c1739aa9ad5f433b15fb01f5e74cdb61a81 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 6 Nov 2023 13:58:34 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=94=A8=E6=96=87=E6=A1=A3=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/UploadDownLoadController.cs | 122 ++---------------- .../Service/Common/CommonDocumentService.cs | 8 ++ 2 files changed, 17 insertions(+), 113 deletions(-) diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs index d8028d2b1..0a7430625 100644 --- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs @@ -1083,122 +1083,18 @@ namespace IRaCIS.Core.API.Controllers } - #region 废弃 + /// 通用文件下载 + [AllowAnonymous] + [HttpGet("CommonDocument/DownloadCommonDoc")] + public async Task DownloadCommonFile(string code, [FromServices] IRepository _commonDocumentRepository) + { + var (filePath, fileName) = await FileStoreHelper.GetCommonDocPhysicalFilePathAsync(_hostEnvironment, _commonDocumentRepository, code); - ///// 缩略图 - //[AllowAnonymous] - //[HttpGet("Common/LocalFilePreview")] - //public async Task LocalFilePreview(string relativePath) - //{ - - // var _fileStorePath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, relativePath); - - // var storePreviewPath = _fileStorePath + ".preview.jpeg"; - - // if (!System.IO.File.Exists(storePreviewPath)) - // { - // ImageHelper.ResizeSave(_fileStorePath, storePreviewPath); - // } - - // return new FileContentResult(await System.IO.File.ReadAllBytesAsync(storePreviewPath), "image/jpeg"); - - //} - - - ///// 通用文件下载 - //[AllowAnonymous] - //[HttpGet("CommonDocument/DownloadCommonDoc")] - //public async Task DownloadCommonFile(string code, [FromServices] IRepository _commonDocumentRepository) - //{ - // var (filePath, fileName) = await FileStoreHelper.GetCommonDocPhysicalFilePathAsync(_hostEnvironment, _commonDocumentRepository, code); - - // new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType); - - // return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName); - - //} - - ///// - ///// 下载项目临床数据文件 - ///// - ///// - ///// - ///// - //[AllowAnonymous] - //[HttpGet("CommonDocument/DownloadTrialClinicalFile")] - //public async Task DownloadTrialClinicalFile(Guid clinicalDataTrialSetId, [FromServices] IRepository _clinicalDataTrialSetRepository) - //{ - // var (filePath, fileName) = await FileStoreHelper.GetTrialClinicalPathAsync(_hostEnvironment, _clinicalDataTrialSetRepository, clinicalDataTrialSetId); - - // new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType); - - // return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName); - - //} - - - ///// - ///// 下载系统临床数据文件 - ///// - ///// - ///// - ///// - //[AllowAnonymous] - //[HttpGet("CommonDocument/DownloadSystemClinicalFile")] - //public async Task DownloadSystemClinicalFile(Guid clinicalDataSystemSetId, [FromServices] IRepository _clinicalDataSystemSetRepository) - //{ - // var (filePath, fileName) = await FileStoreHelper.GetSystemClinicalPathAsync(_hostEnvironment, _clinicalDataSystemSetRepository, clinicalDataSystemSetId); - - // new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType); - - // return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName); - - //} - - ///// - /////上传项目签名文档 - ///// - ///// - ///// - //[HttpPost("TrialDocument/UploadTrialDoc/{trialId:guid}")] - //[DisableRequestSizeLimit] - //[DisableFormValueModelBinding] - //public async Task UploadTrialDoc(Guid trialId) - //{ - - // return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetTrialSignDocPath(_hostEnvironment, trialId, fileName)); - - //} - - ///// - ///// 上传系统签名文档 - ///// - ///// - //[HttpPost("TrialDocument/UploadSystemDoc")] - //[DisableRequestSizeLimit] - //[DisableFormValueModelBinding] - //public async Task UploadSysTemDoc() - //{ - - // return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemSignDocPath(_hostEnvironment, fileName)); - - //} - ///// - ///// 上传系统通知文档 - ///// - ///// - //[HttpPost("SystemNotice/UploadSystemNoticeDoc")] - //[DisableRequestSizeLimit] - //[DisableFormValueModelBinding] - //public async Task UploadSystemNoticeDoc() - //{ - - // return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemNoticePath(_hostEnvironment, fileName)); - - //} - #endregion + new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType); + return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName); + } /// /// 上传通用文档 比如一致性核查的 比如导出的excel 模板 diff --git a/IRaCIS.Core.Application/Service/Common/CommonDocumentService.cs b/IRaCIS.Core.Application/Service/Common/CommonDocumentService.cs index d9e1cfe9f..7b1ab197b 100644 --- a/IRaCIS.Core.Application/Service/Common/CommonDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Common/CommonDocumentService.cs @@ -110,5 +110,13 @@ namespace IRaCIS.Core.Application.Service } + + [HttpDelete("{commonDocumentId:guid}")] + public async Task DeleteCommonDocument(Guid commonDocumentId) + { + var success = await _commonDocumentRepository.DeleteFromQueryAsync(t => t.Id == commonDocumentId, true); + return ResponseOutput.Ok(); + } + } }