From 155d24fafb1a9a72f121344b55a7e62a33cd144c Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Tue, 15 Oct 2024 10:17:00 +0800
Subject: [PATCH] =?UTF-8?q?swagger=20=E5=85=BC=E5=AE=B9minimal=20api=20?=
=?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/UploadDownLoadController.cs | 232 ++++------------
IRaCIS.Core.API/IRaCIS.Core.API.xml | 29 +-
IRaCIS.Core.API/Progranm.cs | 2 +-
.../_ServiceExtensions/SwaggerSetup.cs | 11 -
.../IRaCIS.Core.Application.xml | 23 +-
.../Service/Common/FileService.cs | 249 ++++++------------
6 files changed, 152 insertions(+), 394 deletions(-)
diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs
index c5c59db31..847a069bb 100644
--- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs
+++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs
@@ -42,11 +42,14 @@ namespace IRaCIS.Core.API.Controllers
{
#region 上传基类封装
+
[DisableFormValueModelBinding]
public abstract class UploadBaseController : ControllerBase
{
/// 流式上传 直接返回
- [Route("base")]
+ [Route("SingleFileUpload")]
+ [ApiExplorerSettings(IgnoreApi = true)]
+
public virtual async Task SingleFileUploadAsync(Func filePathFunc)
{
var boundary = HeaderUtilities.RemoveQuotes(MediaTypeHeaderValue.Parse(Request.ContentType).Boundary).Value;
@@ -81,7 +84,9 @@ namespace IRaCIS.Core.API.Controllers
/// 流式上传 通用封装 不返回任何数据,后续还有事情处理
- [Route("base")]
+ [Route("FileUpload")]
+ [ApiExplorerSettings(IgnoreApi = true)]
+
public virtual async Task FileUploadAsync(Func> filePathFunc)
{
var boundary = HeaderUtilities.RemoveQuotes(MediaTypeHeaderValue.Parse(Request.ContentType).Boundary).Value;
@@ -124,7 +129,9 @@ namespace IRaCIS.Core.API.Controllers
}
}
- [Route("base")]
+ [Route("FileUploadToOSS")]
+ [ApiExplorerSettings(IgnoreApi = true)]
+
public virtual async Task FileUploadToOSSAsync(Func> toMemoryStreamFunc)
{
var boundary = HeaderUtilities.RemoveQuotes(MediaTypeHeaderValue.Parse(Request.ContentType).Boundary).Value;
@@ -150,10 +157,10 @@ namespace IRaCIS.Core.API.Controllers
}
-
-
/// 流式上传 Dicom上传
- [Route("base")]
+ [Route("DicomFileUpload")]
+ [ApiExplorerSettings(IgnoreApi = true)]
+
public virtual async Task DicomFileUploadAsync(Func filePathFunc, string boundary)
{
@@ -215,9 +222,42 @@ namespace IRaCIS.Core.API.Controllers
#endregion
#region Dicom 影像上传 临床数据 非diocm
+ public class UploadNoneDicomFileCommand
+ {
+ [NotDefault]
+ public Guid SubjectVisitId { get; set; }
- [ApiExplorerSettings(GroupName = "Image")]
- [ApiController]
+
+ [NotDefault]
+ public Guid StudyMonitorId { get; set; }
+
+
+ public Guid? NoneDicomStudyId { get; set; }
+
+ //IR 上传的时候跟任务绑定
+ public Guid? VisitTaskId { get; set; }
+
+ public string RecordPath { get; set; }
+
+ public int FailedFileCount { get; set; }
+
+ public long FileSize { get; set; }
+
+
+ public List UploadedFileList { get; set; } = new List();
+
+
+ public class OSSFileDTO
+ {
+ public string FilePath { get; set; }
+ public string FileName { get; set; }
+ public int FileFize { get; set; }
+
+ public string FileType { get; set; }
+ }
+ }
+
+ [ApiController, ApiExplorerSettings(GroupName = "Image")]
public class StudyController(
IMediator _mediator,
QCCommon _qCCommon,
@@ -228,9 +268,6 @@ namespace IRaCIS.Core.API.Controllers
-
-
-
/// Dicom 归档
[HttpPost, Route("Study/ArchiveStudy")]
[DisableFormValueModelBinding]
@@ -382,41 +419,6 @@ namespace IRaCIS.Core.API.Controllers
}
- public class UploadNoneDicomFileCommand
- {
- [NotDefault]
- public Guid SubjectVisitId { get; set; }
-
-
- [NotDefault]
- public Guid StudyMonitorId { get; set; }
-
-
- public Guid? NoneDicomStudyId { get; set; }
-
- //IR 上传的时候跟任务绑定
- public Guid? VisitTaskId { get; set; }
-
- public string RecordPath { get; set; }
-
- public int FailedFileCount { get; set; }
-
- public long FileSize { get; set; }
-
-
- public List UploadedFileList { get; set; } = new List();
-
-
- public class OSSFileDTO
- {
- public string FilePath { get; set; }
- public string FileName { get; set; }
- public int FileFize { get; set; }
-
- public string FileType { get; set; }
- }
- }
-
///
/// 非dicom 上传预上传接口
///
@@ -462,7 +464,6 @@ namespace IRaCIS.Core.API.Controllers
///
[HttpPost("NoneDicomStudy/UploadNoneDicomFile")]
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
-
public async Task UploadNoneDicomFile(UploadNoneDicomFileCommand incommand,
[FromServices] IRepository _noneDicomStudyRepository,
[FromServices] IRepository _studyMonitorRepository,
@@ -747,146 +748,13 @@ namespace IRaCIS.Core.API.Controllers
#endregion
- #region 医生文件上传下载
- #region DTO
- public class DoctorDownloadInfo
- {
- public Guid Id { get; set; }
- public string Name { get; set; }
- public string ReviewerCode { get; set; }
-
- public List FileList { get; set; }
- }
- public class DownloadFileInfo
- {
- public string FileName { get; set; }
-
- public string Path { get; set; }
- }
-
- public class GetDoctorPathCommand
- {
- public int Language { get; set; }
-
- public List DoctorIdList { get; set; }
- }
-
- public class GetDoctoreAttachPathCommand
- {
- public Guid DoctorId { get; set; }
- public List AttachmentIdList { get; set; }
- }
- #endregion
-
-
- /// 医生文件上传下载
- [ApiExplorerSettings(GroupName = "Common")]
- [ApiController]
- public class FileController : UploadBaseController
- {
- public IMapper _mapper { get; set; }
- public IUserInfo _userInfo { get; set; }
-
-
- private readonly IWebHostEnvironment _hostEnvironment;
-
- private readonly IFileService _fileService;
-
-
- public FileController(IMapper mapper, IUserInfo userInfo, IWebHostEnvironment hostEnvironment, IFileService fileService)
- {
- _fileService = fileService;
- _hostEnvironment = hostEnvironment;
- _mapper = mapper;
- _userInfo = userInfo;
- }
-
- ///
- /// New 医生首页 多选 获取多个医生信息+文件路径列表 医生压缩包名称 doctorCode + "_" + doctorName _(时间戳或者随机的Guid)
- ///
- ///
- [HttpPost, Route("file/GetOfficialResume")]
- public async Task>> GetOfficialResume(GetDoctorPathCommand command,
- [FromServices] IRepository _attachmentrepository)
- {
-
- var list = await _attachmentrepository.Where(t => command.DoctorIdList.Contains(t.DoctorId) && command.Language == t.Language).GroupBy(t => new { Name = t.Doctor.FirstName + "_" + t.Doctor.LastName, ReviewerCode = t.Doctor.ReviewerCode, t.DoctorId })
- .Select(g => new DoctorDownloadInfo()
- {
- Id = g.Key.DoctorId,
- Name = g.Key.Name,
- ReviewerCode = g.Key.ReviewerCode,
- FileList = g.Select(t => new DownloadFileInfo() { FileName = t.FileName, Path = t.Path }).ToList()
- }).ToListAsync();
-
- return ResponseOutput.Ok(list);
-
- }
-
- ///
- /// New 项目入组 勾选获取简历路径
- ///
- ///
- ///
- ///
- ///
- [HttpPost, Route("file/GetTrialDoctorOfficialResume")]
- public async Task>> GetTrialDoctorOfficialResume(GetDoctorPathCommand command,
- [FromServices] IDoctorService _doctorService,
- [FromServices] IRepository _attachmentrepository)
- {
-
- var list = await _attachmentrepository.Where(t => command.DoctorIdList.Contains(t.DoctorId) && command.Language == t.Language && t.IsOfficial && t.Type.Equals("Resume")).GroupBy(t => new { Name = t.Doctor.FirstName + "_" + t.Doctor.LastName, ReviewerCode = t.Doctor.ReviewerCode, t.DoctorId })
- .Select(g => new DoctorDownloadInfo()
- {
- Id = g.Key.DoctorId,
- Name = g.Key.Name,
- ReviewerCode = g.Key.ReviewerCode,
- FileList = g.Select(t => new DownloadFileInfo() { FileName = t.FileName, Path = t.Path }).ToList()
- }).ToListAsync();
-
- return ResponseOutput.Ok(list);
-
- }
-
- ///
- /// new 医生详情 勾选或者下载文件路径
- ///
- ///
- ///
- ///
- ///
- [HttpPost, Route("file/GetDoctorAttachment")]
- public async Task> GetDoctorAttachment(GetDoctoreAttachPathCommand command,
- [FromServices] IDoctorService _doctorService,
- [FromServices] IRepository _attachmentrepository)
- {
-
- var find = await _attachmentrepository.Where(t => command.DoctorId == t.DoctorId && command.AttachmentIdList.Contains(t.Id)).GroupBy(t => new { Name = t.Doctor.FirstName + "_" + t.Doctor.LastName, ReviewerCode = t.Doctor.ReviewerCode, t.DoctorId })
- .Select(g => new DoctorDownloadInfo()
- {
- Id = g.Key.DoctorId,
- Name = g.Key.Name,
- ReviewerCode = g.Key.ReviewerCode,
- FileList = g.Select(t => new DownloadFileInfo() { FileName = t.FileName, Path = t.Path }).ToList()
- }).FirstOrDefaultAsync();
-
- return ResponseOutput.Ok(find);
-
- }
-
-
-
- }
- #endregion
-
#region 项目 系统 基本文件 上传 下载 预览
- [ApiExplorerSettings(GroupName = "Common")]
- [ApiController]
+ [ApiController, ApiExplorerSettings(GroupName = "Common")]
+
public class UploadDownLoadController : UploadBaseController
{
public IMapper _mapper { get; set; }
diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.xml b/IRaCIS.Core.API/IRaCIS.Core.API.xml
index 061f40bcc..216f82c9a 100644
--- a/IRaCIS.Core.API/IRaCIS.Core.API.xml
+++ b/IRaCIS.Core.API/IRaCIS.Core.API.xml
@@ -290,7 +290,7 @@
-
+
上传非Dicom 文件 支持压缩包 多文件上传
@@ -310,33 +310,6 @@
-
- 医生文件上传下载
-
-
-
- New 医生首页 多选 获取多个医生信息+文件路径列表 医生压缩包名称 doctorCode + "_" + doctorName _(时间戳或者随机的Guid)
-
-
-
-
-
- New 项目入组 勾选获取简历路径
-
-
-
-
-
-
-
-
- new 医生详情 勾选或者下载文件路径
-
-
-
-
-
-
通用文件下载
diff --git a/IRaCIS.Core.API/Progranm.cs b/IRaCIS.Core.API/Progranm.cs
index bb8659dfc..5f3f2b534 100644
--- a/IRaCIS.Core.API/Progranm.cs
+++ b/IRaCIS.Core.API/Progranm.cs
@@ -108,7 +108,7 @@ builder.Services.AddEFSetup(_configuration, enviromentName);
//Http 响应压缩
builder.Services.AddResponseCompressionSetup();
//Swagger Api 文档
-builder.Services.AddSwaggerSetupOld();
+builder.Services.AddSwaggerSetup();
//JWT Token 验证
builder.Services.AddJWTAuthSetup(_configuration);
diff --git a/IRaCIS.Core.API/_ServiceExtensions/SwaggerSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/SwaggerSetup.cs
index 1632056c7..4b0642670 100644
--- a/IRaCIS.Core.API/_ServiceExtensions/SwaggerSetup.cs
+++ b/IRaCIS.Core.API/_ServiceExtensions/SwaggerSetup.cs
@@ -128,17 +128,6 @@ public static class SwaggerSetup
// 接口排序
options.OrderActionsBy(o => o.GroupName);
- options.DocInclusionPredicate((docName, apiDes) =>
- {
- if (!apiDes.TryGetMethodInfo(out MethodInfo methodInfo)) return false;
- var versions = methodInfo.DeclaringType.GetCustomAttributes(true)
- .OfType()
- .Select(attr => attr.GroupName);
-
- return versions.Any(v => v.ToString() == docName);
- });
-
-
//添加注释
var basePath = AppContext.BaseDirectory;
var xmlPath1 = Path.Combine(basePath, "IRaCIS.Core.Application.xml");
diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
index 5114fbdc4..e74a68289 100644
--- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
+++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
@@ -986,19 +986,28 @@
ExploreRecommendService
-
+
- 打包医生官方简历
+ New 医生首页 多选 获取多个医生信息+文件路径列表 医生压缩包名称 doctorCode + "_" + doctorName _(时间戳或者随机的Guid)
-
-
-
+
- 打包医生的所有附件
+ New 项目入组 勾选获取简历路径
-
+
+
+
+
+
+
+
+ new 医生详情 勾选或者下载文件路径
+
+
+
+
diff --git a/IRaCIS.Core.Application/Service/Common/FileService.cs b/IRaCIS.Core.Application/Service/Common/FileService.cs
index 90f0b29d2..94913e8c8 100644
--- a/IRaCIS.Core.Application/Service/Common/FileService.cs
+++ b/IRaCIS.Core.Application/Service/Common/FileService.cs
@@ -2,203 +2,122 @@
using IRaCIS.Core.Application.Helper;
using IRaCIS.Core.Infrastructure;
using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Hosting;
using System.Text;
namespace IRaCIS.Core.Application.Service
{
- public class FileService(
- IDoctorService _doctorService,
- IAttachmentService _attachmentService,
- IWebHostEnvironment _hostEnvironment) : IFileService
-
+ [ApiExplorerSettings(GroupName = "Common")]
+ public class FileService : BaseService
{
- private string defaultUploadFilePath = FileStoreHelper.GetIRaCISRootPath(_hostEnvironment);
+
///
- /// 打包医生官方简历
+ /// New 医生首页 多选 获取多个医生信息+文件路径列表 医生压缩包名称 doctorCode + "_" + doctorName _(时间戳或者随机的Guid)
///
- ///
- ///
///
- public async Task CreateOfficialResumeZip(int language, Guid[] doctorIds)
+ [HttpPost]
+ public async Task>> GetOfficialResume(GetDoctorPathCommand command,
+ [FromServices] IRepository _attachmentrepository)
{
- //准备下载文件的临时路径
- var guidStr = Guid.NewGuid().ToString();
-
- string uploadFolderPath = Path.Combine(FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment), "UploadFile");
-
-
-
- var tempSavePath = Path.Combine(uploadFolderPath, "temp", guidStr); //待压缩的文件夹,将需要下载的文件拷贝到此文件夹
- if (!Directory.Exists(tempSavePath))
- {
- Directory.CreateDirectory(tempSavePath);
- }
-
- //找到服务器简历路径 循环拷贝简历到临时路径
- foreach (var doctorId in doctorIds)
- {
- var doctor = await _doctorService.GetBasicInfo(doctorId);
- var doctorName = doctor.FirstName + "_" + doctor.LastName;
-
- //找官方简历存在服务器的相对路径
- var sourceCvPath = await _attachmentService.GetDoctorOfficialCV(language, doctorId);
- if (!string.IsNullOrWhiteSpace(sourceCvPath))
+ var list = await _attachmentrepository.Where(t => command.DoctorIdList.Contains(t.DoctorId) && command.Language == t.Language).GroupBy(t => new { Name = t.Doctor.FirstName + "_" + t.Doctor.LastName, ReviewerCode = t.Doctor.ReviewerCode, t.DoctorId })
+ .Select(g => new DoctorDownloadInfo()
{
- //服务器简历文件实际路径
- //var sourceCvFullPath = HostingEnvironment.MapPath(sourceCvPath);
- var sourceCvPathTemp = sourceCvPath.Substring(1, sourceCvPath.Length - 1);//.Replace('/','\\');
- string sourceCvFullPath = Path.Combine(defaultUploadFilePath, sourceCvPathTemp);
+ Id = g.Key.DoctorId,
+ Name = g.Key.Name,
+ ReviewerCode = g.Key.ReviewerCode,
+ FileList = g.Select(t => new DownloadFileInfo() { FileName = t.FileName, Path = t.Path }).ToList()
+ }).ToListAsync();
- var arr = sourceCvPath.Split('.');
- string extensionName = arr[arr.Length - 1]; //得到扩展名
+ return ResponseOutput.Ok(list);
- //需要拷贝到的路径
- var doctorPath = Path.Combine(tempSavePath, doctor.ReviewerCode.ToString() + "_" + doctorName + "." + extensionName);
-
- if (File.Exists(sourceCvFullPath))
- {
- File.Copy(sourceCvFullPath, doctorPath, true);
- }
- }
- }
-
- //创建ZIP
- DateTime now = DateTime.Now;
- StringBuilder sb = new StringBuilder();
- sb.Append(now.Year).Append(now.Month.ToString().PadLeft(2, '0')).Append(now.Day.ToString().PadLeft(2, '0'))
- .Append(now.Hour.ToString().PadLeft(2, '0')).Append(now.Minute.ToString().PadLeft(2, '0'))
- .Append(now.Second.ToString().PadLeft(2, '0')).Append(now.Millisecond.ToString().PadLeft(3, '0'));
-
- string targetZipPath = Path.Combine(uploadFolderPath, "CV_" + sb.ToString() + ".zip");
- ZipHelper.CreateZip(tempSavePath, targetZipPath);
-
- //返回Zip路径
- return Path.Combine("/IRaCISData/UploadFile/", "CV_" + sb.ToString() + ".zip");
}
///
- /// 打包医生的所有附件
+ /// New 项目入组 勾选获取简历路径
///
- ///
+ ///
+ ///
+ ///
///
- public async Task CreateDoctorsAllAttachmentZip(Guid[] doctorIds)
+ [HttpPost]
+ public async Task>> GetTrialDoctorOfficialResume(GetDoctorPathCommand command,
+ [FromServices] IDoctorService _doctorService,
+ [FromServices] IRepository _attachmentrepository)
{
- #region 老版本 存储在服务器
- //准备下载文件的临时路径
- var guidStr = Guid.NewGuid().ToString();
- //string uploadFolderPath = HostingEnvironment.MapPath("/UploadFile/");
- string uploadFolderPath = Path.Combine(FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment), "UploadFile");
- var tempSavePath = Path.Combine(uploadFolderPath, "temp", guidStr); //待压缩的文件夹,将需要下载的文件拷贝到此文件夹
- if (!Directory.Exists(tempSavePath))
- {
- Directory.CreateDirectory(tempSavePath);
- }
-
- foreach (var doctorId in doctorIds)
- {
- //获取医生基本信息
- var doctor = await _doctorService.GetBasicInfo(doctorId);
- var doctorName = doctor.FirstName + "_" + doctor.LastName;
- var doctorCode = doctor.ReviewerCode;
-
- var doctorDestPath = Path.Combine(tempSavePath, doctorCode + "_" + doctorName);
- if (!Directory.Exists(doctorDestPath))
+ var list = await _attachmentrepository.Where(t => command.DoctorIdList.Contains(t.DoctorId) && command.Language == t.Language && t.IsOfficial && t.Type.Equals("Resume")).GroupBy(t => new { Name = t.Doctor.FirstName + "_" + t.Doctor.LastName, ReviewerCode = t.Doctor.ReviewerCode, t.DoctorId })
+ .Select(g => new DoctorDownloadInfo()
{
- Directory.CreateDirectory(doctorDestPath);
- }
+ Id = g.Key.DoctorId,
+ Name = g.Key.Name,
+ ReviewerCode = g.Key.ReviewerCode,
+ FileList = g.Select(t => new DownloadFileInfo() { FileName = t.FileName, Path = t.Path }).ToList()
+ }).ToListAsync();
- //服务器上传后的源路径
- string doctorFileSourcePath = Path.Combine(uploadFolderPath, doctorId.ToString());
-
- if (Directory.Exists(doctorFileSourcePath))
- {
- CopyDirectory(doctorFileSourcePath, doctorDestPath);
- }
- }
- string target = Guid.NewGuid().ToString();
- string targetPath = Path.Combine(uploadFolderPath, target + ".zip");
- ZipHelper.CreateZip(tempSavePath, targetPath);
- return Path.Combine("/IRaCISData/UploadFile/", target + ".zip");
- #endregion
+ return ResponseOutput.Ok(list);
}
-
- public async Task CreateZipPackageByAttachment(Guid doctorId, Guid[] attachmentIds)
- {
- var doctor = await _doctorService.GetBasicInfo(doctorId);
- var doctorName = doctor.FirstName + "_" + doctor.LastName;
-
- Guid temp = Guid.NewGuid();
- //string root = HostingEnvironment.MapPath("/UploadFile/"); //文件根目录
- string root = Path.Combine(defaultUploadFilePath, "UploadFile");
-
- var tempPath = Path.Combine(root, "temp", temp.ToString(), doctor.ReviewerCode + doctorName); //待压缩的文件夹,将需要下载的文件拷贝到此文件夹
- var packagePath = Path.Combine(root, "temp", temp.ToString()); //打包目录
- if (!Directory.Exists(tempPath))
- {
- Directory.CreateDirectory(tempPath);
- }
- var attachemnts = (await _attachmentService.GetAttachments(doctorId)).Where(a => attachmentIds.Contains(a.Id));
-
- foreach (var item in attachemnts)
- {
- var arr = item.Path.Trim().Split('/');
- var myPath = string.Empty;
- var myFile = string.Empty;
- //需要改进
- if (arr.Length > 0)
- {
- myFile = arr[arr.Length - 1];
- foreach (var arrItem in arr)
- {
- if (arrItem != string.Empty && !"UploadFile".Equals(arrItem))
- {
- myPath += (arrItem + "/");
- }
- }
- myPath = myPath.TrimEnd('/');
- }
- var sourcePath = Path.Combine(root, myPath);
-
- if (!string.IsNullOrWhiteSpace(sourcePath) && File.Exists(sourcePath))
- {
- File.Copy(sourcePath, Path.Combine(tempPath, myFile), true);
- }
- }
- string target = Guid.NewGuid().ToString();
- string targetPath = Path.Combine(root, target + ".zip");
- ZipHelper.CreateZip(packagePath, targetPath);
-
- return Path.Combine("/IRaCISData/UploadFile/", target + ".zip");
- }
-
- private static void CopyDirectory(string srcPath, string destPath)
+ ///
+ /// new 医生详情 勾选或者下载文件路径
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetDoctorAttachment(GetDoctoreAttachPathCommand command,
+ [FromServices] IDoctorService _doctorService,
+ [FromServices] IRepository _attachmentrepository)
{
- DirectoryInfo dir = new DirectoryInfo(srcPath);
- FileSystemInfo[] fileInfoArray = dir.GetFileSystemInfos(); //获取目录下(不包含子目录)的文件和子目录
- foreach (FileSystemInfo fileInfo in fileInfoArray)
- {
- if (fileInfo is DirectoryInfo) //判断是否文件夹
+ var find = await _attachmentrepository.Where(t => command.DoctorId == t.DoctorId && command.AttachmentIdList.Contains(t.Id)).GroupBy(t => new { Name = t.Doctor.FirstName + "_" + t.Doctor.LastName, ReviewerCode = t.Doctor.ReviewerCode, t.DoctorId })
+ .Select(g => new DoctorDownloadInfo()
{
- if (!Directory.Exists(destPath + "\\" + fileInfo.Name))
- {
- Directory.CreateDirectory(destPath + "\\" + fileInfo.Name); //目标目录下不存在此文件夹即创建子文件夹
- }
- CopyDirectory(fileInfo.FullName, destPath + "\\" + fileInfo.Name); //递归调用复制子文件夹
- }
- else
- {
- File.Copy(fileInfo.FullName, destPath + "\\" + fileInfo.Name, true); //不是文件夹即复制文件,true表示可以覆盖同名文件
- }
- }
+ Id = g.Key.DoctorId,
+ Name = g.Key.Name,
+ ReviewerCode = g.Key.ReviewerCode,
+ FileList = g.Select(t => new DownloadFileInfo() { FileName = t.FileName, Path = t.Path }).ToList()
+ }).FirstOrDefaultAsync();
+
+ return ResponseOutput.Ok(find);
}
+
}
+
+ #region DTO
+ public class DoctorDownloadInfo
+ {
+ public Guid Id { get; set; }
+ public string Name { get; set; }
+ public string ReviewerCode { get; set; }
+
+ public List FileList { get; set; }
+ }
+ public class DownloadFileInfo
+ {
+ public string FileName { get; set; }
+
+ public string Path { get; set; }
+ }
+
+ public class GetDoctorPathCommand
+ {
+ public int Language { get; set; }
+
+ public List DoctorIdList { get; set; }
+ }
+
+ public class GetDoctoreAttachPathCommand
+ {
+ public Guid DoctorId { get; set; }
+ public List AttachmentIdList { get; set; }
+ }
+ #endregion
}