swagger 兼容minimal api 调整

This commit is contained in:
2024-10-15 10:17:00 +08:00
parent 08f4a0877b
commit 155d24fafb
6 changed files with 152 additions and 394 deletions
@@ -42,11 +42,14 @@ namespace IRaCIS.Core.API.Controllers
{
#region
[DisableFormValueModelBinding]
public abstract class UploadBaseController : ControllerBase
{
/// <summary> 流式上传 直接返回</summary>
[Route("base")]
[Route("SingleFileUpload")]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual async Task<IResponseOutput> SingleFileUploadAsync(Func<string, (string, string)> filePathFunc)
{
var boundary = HeaderUtilities.RemoveQuotes(MediaTypeHeaderValue.Parse(Request.ContentType).Boundary).Value;
@@ -81,7 +84,9 @@ namespace IRaCIS.Core.API.Controllers
/// <summary> 流式上传 通用封装 不返回任何数据,后续还有事情处理 </summary>
[Route("base")]
[Route("FileUpload")]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual async Task FileUploadAsync(Func<string, Task<string>> 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<string, Stream, Task<string>> toMemoryStreamFunc)
{
var boundary = HeaderUtilities.RemoveQuotes(MediaTypeHeaderValue.Parse(Request.ContentType).Boundary).Value;
@@ -150,10 +157,10 @@ namespace IRaCIS.Core.API.Controllers
}
/// <summary> 流式上传 Dicom上传 </summary>
[Route("base")]
[Route("DicomFileUpload")]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual async Task DicomFileUploadAsync(Func<string, Stream, int, Task> 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<OSSFileDTO> UploadedFileList { get; set; } = new List<OSSFileDTO>();
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
/// <summary>Dicom 归档</summary>
[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<OSSFileDTO> UploadedFileList { get; set; } = new List<OSSFileDTO>();
public class OSSFileDTO
{
public string FilePath { get; set; }
public string FileName { get; set; }
public int FileFize { get; set; }
public string FileType { get; set; }
}
}
/// <summary>
/// 非dicom 上传预上传接口
/// </summary>
@@ -462,7 +464,6 @@ namespace IRaCIS.Core.API.Controllers
/// <returns></returns>
[HttpPost("NoneDicomStudy/UploadNoneDicomFile")]
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
public async Task<IResponseOutput> UploadNoneDicomFile(UploadNoneDicomFileCommand incommand,
[FromServices] IRepository<NoneDicomStudy> _noneDicomStudyRepository,
[FromServices] IRepository<StudyMonitor> _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<DownloadFileInfo> 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<Guid> DoctorIdList { get; set; }
}
public class GetDoctoreAttachPathCommand
{
public Guid DoctorId { get; set; }
public List<Guid> AttachmentIdList { get; set; }
}
#endregion
/// <summary>医生文件上传下载</summary>
[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;
}
/// <summary>
/// New 医生首页 多选 获取多个医生信息+文件路径列表 医生压缩包名称 doctorCode + "_" + doctorName _(时间戳或者随机的Guid)
/// </summary>
/// <returns></returns>
[HttpPost, Route("file/GetOfficialResume")]
public async Task<IResponseOutput<List<DoctorDownloadInfo>>> GetOfficialResume(GetDoctorPathCommand command,
[FromServices] IRepository<Attachment> _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);
}
/// <summary>
/// New 项目入组 勾选获取简历路径
/// </summary>
/// <param name="command"></param>
/// <param name="_doctorService"></param>
/// <param name="_attachmentrepository"></param>
/// <returns></returns>
[HttpPost, Route("file/GetTrialDoctorOfficialResume")]
public async Task<IResponseOutput<List<DoctorDownloadInfo>>> GetTrialDoctorOfficialResume(GetDoctorPathCommand command,
[FromServices] IDoctorService _doctorService,
[FromServices] IRepository<Attachment> _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);
}
/// <summary>
/// new 医生详情 勾选或者下载文件路径
/// </summary>
/// <param name="command"></param>
/// <param name="_doctorService"></param>
/// <param name="_attachmentrepository"></param>
/// <returns></returns>
[HttpPost, Route("file/GetDoctorAttachment")]
public async Task<IResponseOutput<DoctorDownloadInfo>> GetDoctorAttachment(GetDoctoreAttachPathCommand command,
[FromServices] IDoctorService _doctorService,
[FromServices] IRepository<Attachment> _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; }