Update เอกสารแนบท้าย

This commit is contained in:
Suphonchai Phoonsawat 2023-07-28 16:30:03 +07:00
parent 7fa7304954
commit dbcf1d31b6
4 changed files with 125 additions and 7 deletions

View file

@ -1,5 +1,4 @@
using Amazon.S3.Model.Internal.MarshallTransformations;
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Repositories.Commands;
using BMA.EHR.Command.Service.Requests;
using BMA.EHR.Domain.Common;
@ -9,9 +8,8 @@ using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Swashbuckle.AspNetCore.Annotations;
using System.Security.Claims;
@ -469,7 +467,6 @@ namespace BMA.EHR.Command.Service.Controllers
/// <summary>
/// PM7-32 : บันทึกช่องทางการส่งสำเนาคำสั่ง
/// </summary>
/// <param name="orderId">Record Id ของคำสั่ง</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
@ -484,7 +481,7 @@ namespace BMA.EHR.Command.Service.Controllers
{
// transform
var deploys = new List<CommandDeployment>();
foreach(var p in req)
foreach (var p in req)
{
var updated = await _repository.GetCommandDeploymentById(p.PersonalId);
updated!.IsSendInbox = p.InboxChannel;
@ -527,6 +524,75 @@ namespace BMA.EHR.Command.Service.Controllers
}
}
#region " Documents "
/// <summary>
/// PM7-34 : ข้อมูลรายละเอียดคำสั่งและแนบท้าย
/// </summary>
/// <param name="orderId">Record Id ของคำสั่ง</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("attachment/{orderId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandAttatchmentAsync(Guid orderId)
{
try
{
var command = await _repository.GetByIdAsync(orderId);
if(command == null)
throw new Exception(GlobalMessages.CommandNotFound);
var documents = await _repository.GetCommandDocumentAsync(orderId);
var cover = documents.Where(x => x.Category.Trim().ToLower() == "cover").FirstOrDefault();
var attach = documents.Where(x => x.Category.Trim().ToLower() == "attachment").FirstOrDefault();
var result = new
{
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),
};
return Success(result);
}
catch
{
throw;
}
}
#endregion
/// <summary>
/// PM7-37 : บันทึกข้อมูลคำสั่งและแนบท้าย
/// </summary>
/// <param name="orderId">Record Id ของคำสั่ง</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("attachment/{orderId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> UpdateCommandExecuteAsync(Guid orderId, [FromBody] UpdateCommandExecuteRequest req)
{
try
{
await _repository.UpdateCommandInfo(orderId, req.OrderNo, req.OrderYear, req.SignDate);
return Success();
}
catch
{
throw;
}
}
#endregion
}