apu upload file
This commit is contained in:
parent
08ff366b4c
commit
2f49a5b87e
13 changed files with 301 additions and 254 deletions
|
|
@ -36,6 +36,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BMA.EHR.API.Command\BMA.EHR.API.Command.csproj" />
|
||||
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,10 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using BMA.EHR.Placement.Service.Requests;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Sentry;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Security.Claims;
|
||||
|
||||
|
|
@ -20,20 +13,23 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
[Route("api/[controller]/placement")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
[Authorize]
|
||||
//[Authorize]
|
||||
[SwaggerTag("ระบบบรรจุ")]
|
||||
public class PlacementController : BaseController
|
||||
{
|
||||
private readonly PlacementRepository _repository;
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public PlacementController(PlacementRepository repository,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_repository = repository;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
|
|
@ -206,17 +202,24 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
return Success(placement);
|
||||
}
|
||||
|
||||
[HttpPost("pass/deferment")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdatePersonDeferment([FromBody] PersonDefermentRequest req)
|
||||
[HttpPost("pass/deferment"), DisableRequestSizeLimit]
|
||||
public async Task<ActionResult<ResponseObject>> UpdatePersonDeferment()
|
||||
{
|
||||
var person = await _context.PlacementProfiles.FindAsync(req.PersonalId);
|
||||
var person = await _context.PlacementProfiles.FindAsync(Request.Form.ContainsKey("personalId") ? Guid.Parse(Request.Form["personalId"]) : Guid.Parse("00000000-0000-0000-0000-000000000000"));
|
||||
if (person == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
person.IsRelief = true;
|
||||
person.ReliefReason = req.Note;
|
||||
person.ReliefReason = Request.Form.ContainsKey("note") ? Request.Form["note"] : "";
|
||||
person.PlacementStatus = "UN-CONTAIN";
|
||||
//person.ReliefDoc = req.UploadFile;xxxxxxxxxxxxxx
|
||||
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||
{
|
||||
var file = Request.Form.Files[0];
|
||||
var fileExtension = Path.GetExtension(file.FileName);
|
||||
|
||||
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
||||
person.ReliefDoc = doc;
|
||||
}
|
||||
person.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
person.LastUpdateUserId = UserId ?? "";
|
||||
person.LastUpdatedAt = DateTime.Now;
|
||||
|
|
@ -245,14 +248,13 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
[HttpGet("pass/deferment/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetPersonDeferment(Guid personalId)
|
||||
{
|
||||
var person = await _context.PlacementProfiles.FindAsync(personalId);
|
||||
var person = await _context.PlacementProfiles.Include(x => x.ReliefDoc).FirstOrDefaultAsync(x => x.Id == personalId);
|
||||
if (person == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
var data = new
|
||||
{
|
||||
ReliefReason = person.ReliefReason,
|
||||
ReliefDoc = person.ReliefReason,
|
||||
//ReliefDoc = person.ReliefDoc == null ? null : await _documentService.ImagesPath(person.ReliefDoc.Id),xxxxxxxxxxxxxx
|
||||
ReliefDoc = person.ReliefDoc == null ? null : await _documentService.ImagesPath(person.ReliefDoc.Id),
|
||||
};
|
||||
|
||||
return Success(data);
|
||||
|
|
@ -272,7 +274,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
return Success(data);
|
||||
}
|
||||
|
||||
[HttpPost("pass/stat/{personalId:length(36)}")]
|
||||
[HttpPost("pass")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdatePositionByPerson(Guid personalId)
|
||||
{
|
||||
var person = await _context.PlacementProfiles.FindAsync(personalId);
|
||||
|
|
@ -281,5 +283,6 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
|
||||
return Success();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,5 +30,6 @@
|
|||
"AccessKey": "frappet",
|
||||
"SecretKey": "P@ssw0rd",
|
||||
"BucketName": "bma-recruit"
|
||||
}
|
||||
},
|
||||
"Protocol": "HTTPS"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue