fix upload attatchment
This commit is contained in:
parent
aff4dcd38d
commit
68c9ed1ad9
3 changed files with 68 additions and 18 deletions
|
|
@ -1,7 +1,6 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Requests.Commands;
|
||||
using BMA.EHR.Application.Responses;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Commands.Core;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Organizations;
|
||||
|
|
@ -48,7 +47,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
case "C-PM-01":
|
||||
case "C-PM-02":
|
||||
case "C-PM-03":
|
||||
result = await GetReceiver01(command);
|
||||
result = await GetReceiver01Async(command);
|
||||
break;
|
||||
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
|
||||
}
|
||||
|
|
@ -61,7 +60,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<CommandReceiver>> GetReceiver01(Command command)
|
||||
private async Task<List<CommandReceiver>> GetReceiver01Async(Command command)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -120,6 +119,32 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
|
||||
#region " Execute and Deploy "
|
||||
|
||||
private async Task ExecuteCommandByTypeAsync(Command command)
|
||||
{
|
||||
switch (command.CommandType.CommandCode.Trim().ToUpper())
|
||||
{
|
||||
case "C-PM-01":
|
||||
case "C-PM-02":
|
||||
case "C-PM-03":
|
||||
await ExecuteCommand01Async(command);
|
||||
break;
|
||||
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async Task ExecuteCommand01Async(Command command)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -579,17 +604,21 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
{
|
||||
try
|
||||
{
|
||||
var command = await _dbContext.Set<Command>().Include(x => x.Documents).FirstOrDefaultAsync(c => c.Id == id);
|
||||
var command = await _dbContext.Set<Command>()
|
||||
.Include(x => x.Documents)
|
||||
//.ThenInclude(x =>x.Document)
|
||||
.FirstOrDefaultAsync(c => c.Id == id);
|
||||
|
||||
if (command == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
|
||||
// insert new record to comand Document
|
||||
var exist = command.Documents.Where(x => x.Category == category).ToList();
|
||||
if (exist.Any())
|
||||
{
|
||||
_dbContext.Set<CommandDocument>().RemoveRange(exist);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
//var exist = command.Documents.Where(x => x.Category == category).ToList();
|
||||
//if (exist.Any())
|
||||
//{
|
||||
// _dbContext.Set<CommandDocument>().RemoveRange(exist);
|
||||
// await _dbContext.SaveChangesAsync();
|
||||
//}
|
||||
|
||||
// insert new Record
|
||||
command.Documents.Add(document);
|
||||
|
|
|
|||
|
|
@ -601,7 +601,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> SaveCommandSelectReceiverAsync(Guid orderId,[FromBody] List<Guid> selected)
|
||||
public async Task<ActionResult<ResponseObject>> SaveCommandSelectReceiverAsync(Guid orderId, [FromBody] List<Guid> selected)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -853,8 +853,8 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
orderNo = command.CommandNo,
|
||||
orderYear = command.CommandYear,
|
||||
signDate = command.CommandExcecuteDate,
|
||||
orderFileUrl = cover == null ? null : _documentService.ImagesPath(cover.Document.ObjectRefId),
|
||||
attachmentFileUrl = attach == null ? null : _documentService.ImagesPath(attach.Document.ObjectRefId),
|
||||
orderFileUrl = cover == null ? null : await _documentService.ImagesPath(cover.Document.Id),
|
||||
attachmentFileUrl = attach == null ? null : await _documentService.ImagesPath(attach.Document.Id),
|
||||
};
|
||||
|
||||
return Success(result);
|
||||
|
|
@ -875,6 +875,16 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("attachment/order-file/{orderId}"), DisableRequestSizeLimit]
|
||||
[Consumes("multipart/form-data")]
|
||||
[SwaggerOperation(
|
||||
Summary = "Upload a file",
|
||||
Description = "Upload a file using multipart/form-data",
|
||||
OperationId = "UploadCommandCoverAsync"
|
||||
//Tags = new[] { "File" }
|
||||
)]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> UploadCommandCoverAsync(Guid orderId)
|
||||
{
|
||||
try
|
||||
|
|
@ -893,7 +903,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
// delete exist document from s3
|
||||
foreach (var doc in docs)
|
||||
{
|
||||
await _documentService.DeleteFileAsync(doc.Document.ObjectRefId);
|
||||
await _documentService.DeleteFileAsync(doc.Document.Id);
|
||||
}
|
||||
|
||||
// upload new document to s3
|
||||
|
|
@ -926,6 +936,16 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("attachment/file/{orderId}"), DisableRequestSizeLimit]
|
||||
[Consumes("multipart/form-data")]
|
||||
[SwaggerOperation(
|
||||
Summary = "Upload a file",
|
||||
Description = "Upload a file using multipart/form-data",
|
||||
OperationId = "UploadCommandAttachmentAsync"
|
||||
//Tags = new[] { "File" }
|
||||
)]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> UploadCommandAttachmentAsync(Guid orderId)
|
||||
{
|
||||
try
|
||||
|
|
@ -942,9 +962,10 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
var docs = await _repository.GetExistDocument(orderId, GlobalConstants.TYPE_ATTACHMENT);
|
||||
|
||||
// delete exist document from s3
|
||||
|
||||
foreach (var doc in docs)
|
||||
{
|
||||
await _documentService.DeleteFileAsync(doc.Document.ObjectRefId);
|
||||
await _documentService.DeleteFileAsync(doc.Document.Id);
|
||||
}
|
||||
|
||||
// upload new document to s3
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@
|
|||
}
|
||||
},
|
||||
"MinIO": {
|
||||
"Endpoint": "https://s3.frappet.com/",
|
||||
"Endpoint": "https://s3cluster.frappet.com/",
|
||||
"AccessKey": "frappet",
|
||||
"SecretKey": "P@ssw0rd",
|
||||
"BucketName": "bma-recruit"
|
||||
"SecretKey": "FPTadmin2357",
|
||||
"BucketName": "bma-ehr-fpt"
|
||||
},
|
||||
"Protocol": "HTTPS"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue