From 970319e8c2daada5aa4ecb5723ac1a331aa21584 Mon Sep 17 00:00:00 2001 From: harid Date: Wed, 4 Feb 2026 11:05:02 +0700 Subject: [PATCH] =?UTF-8?q?API=20=E0=B8=AD=E0=B8=B1=E0=B8=9E=E0=B9=80?= =?UTF-8?q?=E0=B8=94=E0=B8=97=E0=B8=AA=E0=B8=96=E0=B8=B2=E0=B8=99=E0=B8=B0?= =?UTF-8?q?=E0=B9=80=E0=B8=9B=E0=B9=87=E0=B8=99=E0=B8=9A=E0=B8=A3=E0=B8=A3?= =?UTF-8?q?=E0=B8=88=E0=B8=B8=20=E0=B9=80=E0=B8=89=E0=B8=9E=E0=B8=B2?= =?UTF-8?q?=E0=B8=B0=20Super=5Fadmin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PlacementController.cs | 35 ++++++++++++++++++- .../Requests/PersonUpdateStatusRequest.cs | 10 ++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 BMA.EHR.Placement.Service/Requests/PersonUpdateStatusRequest.cs diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index a485a42d..1a9260ef 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -62,9 +62,9 @@ namespace BMA.EHR.Placement.Service.Controllers #region " Properties " private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value; - private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value; private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"]; + private bool isSuperAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("SUPER_ADMIN") ?? false; #endregion @@ -852,6 +852,39 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// API อัพเดทสถานะเป็นบรรจุ + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("pass/update-status")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PersonUpdateStatus([FromBody] PersonUpdateStatusRequest req) + { + if (isSuperAdmin == false) + return Success(); + + var person = await _context.PlacementProfiles + .FirstOrDefaultAsync(x => x.Id == req.PersonalId); + if (person == null) + return Error(GlobalMessages.DataNotFound, 404); + + person.PlacementStatus = "DONE"; + person.LastUpdateFullName = FullName ?? "System Administrator"; + person.LastUpdateUserId = UserId ?? ""; + person.LastUpdatedAt = DateTime.Now; + + await _context.SaveChangesAsync(); + + return Success(); + } + [HttpGet("pass/deferment/{personalId:length(36)}")] public async Task> GetPersonDeferment(Guid personalId) { diff --git a/BMA.EHR.Placement.Service/Requests/PersonUpdateStatusRequest.cs b/BMA.EHR.Placement.Service/Requests/PersonUpdateStatusRequest.cs new file mode 100644 index 00000000..aef70fb5 --- /dev/null +++ b/BMA.EHR.Placement.Service/Requests/PersonUpdateStatusRequest.cs @@ -0,0 +1,10 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Placement.Service.Requests +{ + public class PersonUpdateStatusRequest + { + public Guid PersonalId { get; set; } + } +}