From 23d86f632e092ddfc3f6c9da09e447b548cd492e Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 31 Jul 2025 14:52:04 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=20API=20=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=80=E0=B8=88=E0=B9=89?= =?UTF-8?q?=E0=B8=B2=E0=B8=AB=E0=B8=99=E0=B9=89=E0=B8=B2=E0=B8=97=E0=B8=B5?= =?UTF-8?q?=E0=B9=88=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82=E0=B8=82?= =?UTF-8?q?=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9=E0=B8=A5=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B8=82=E0=B8=AD=E0=B8=A5=E0=B8=B2=E0=B8=AD=E0=B8=AD?= =?UTF-8?q?=E0=B8=81=E0=B9=84=E0=B8=94=E0=B9=89=E0=B8=AB=E0=B8=B2=E0=B8=81?= =?UTF-8?q?=20=E0=B8=AA=E0=B8=96=E0=B8=B2=E0=B8=99=E0=B8=B0=E0=B9=80?= =?UTF-8?q?=E0=B8=9B=E0=B9=87=E0=B8=99=20=E0=B9=83=E0=B8=AB=E0=B8=A1?= =?UTF-8?q?=E0=B9=88=20(NEW)=20#1714?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/RetirementResignController.cs | 37 +++++++++++++++++++ .../RetirementResignEmployeeController.cs | 37 +++++++++++++++++++ .../RetirementUpdateResignInfoRequest.cs | 14 +++++++ 3 files changed, 88 insertions(+) create mode 100644 BMA.EHR.Retirement.Service/Requests/RetirementUpdateResignInfoRequest.cs diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index dc8e94df..c8053ed5 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -3563,6 +3563,43 @@ namespace BMA.EHR.Retirement.Service.Controllers } } + + /// + /// แก้ไขข้อมูลการลาออกของข้าราชการ + /// + /// Id ลาออก + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPut("admin-update/resign-info/{id:length(36)}")] + public async Task> UpdateResignInfo([FromBody] RetirementUpdateResignInfoRequest req, Guid id) + { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_RESIGN"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + var updated = await _context.RetirementResigns.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == id); + if (updated == null) + return Error(GlobalMessages.RetirementResignNotFound, 404); + + updated.Location = !string.IsNullOrEmpty(req.Location) ? req.Location : updated.Location; + updated.ReasonResign = !string.IsNullOrEmpty(req.ReasonResign) ? req.ReasonResign : updated.ReasonResign; + updated.Remark = !string.IsNullOrEmpty(req.ReasonResign) && req.ReasonResign == "อื่น ๆ" && !string.IsNullOrEmpty(req.Remark) + ? req.Remark + : null; + updated.SendDate = req.SendDate.HasValue ? req.SendDate : updated.SendDate; + updated.ActiveDate = req.ActiveDate.HasValue ? req.ActiveDate : updated.ActiveDate; + updated.LastUpdateFullName = FullName ?? "System Administrator"; + updated.LastUpdateUserId = UserId ?? ""; + updated.LastUpdatedAt = DateTime.Now; + await _context.SaveChangesAsync(); + return Success(); + } #endregion } } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs index 60bf379a..cb9d382c 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs @@ -3030,5 +3030,42 @@ namespace BMA.EHR.Retirement.Service.Controllers } } + + /// + /// แก้ไขข้อมูลการลาออกของลูกจ้างประจำ + /// + /// Id ลาออก + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPut("admin-update/resign-info/{id:length(36)}")] + public async Task> UpdateResignInfo([FromBody] RetirementUpdateResignInfoRequest req, Guid id) + { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_RESIGN_EMP"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + var updated = await _context.RetirementResignEmployees.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == id); + if (updated == null) + return Error(GlobalMessages.RetirementResignNotFound, 404); + + updated.Location = !string.IsNullOrEmpty(req.Location) ? req.Location : updated.Location; + updated.ReasonResign = !string.IsNullOrEmpty(req.ReasonResign) ? req.ReasonResign : updated.ReasonResign; + updated.Remark = !string.IsNullOrEmpty(req.ReasonResign) && req.ReasonResign == "อื่น ๆ" && !string.IsNullOrEmpty(req.Remark) + ? req.Remark + : null; + updated.SendDate = req.SendDate.HasValue ? req.SendDate : updated.SendDate; + updated.ActiveDate = req.ActiveDate.HasValue ? req.ActiveDate : updated.ActiveDate; + updated.LastUpdateFullName = FullName ?? "System Administrator"; + updated.LastUpdateUserId = UserId ?? ""; + updated.LastUpdatedAt = DateTime.Now; + await _context.SaveChangesAsync(); + return Success(); + } } } diff --git a/BMA.EHR.Retirement.Service/Requests/RetirementUpdateResignInfoRequest.cs b/BMA.EHR.Retirement.Service/Requests/RetirementUpdateResignInfoRequest.cs new file mode 100644 index 00000000..c4dfb304 --- /dev/null +++ b/BMA.EHR.Retirement.Service/Requests/RetirementUpdateResignInfoRequest.cs @@ -0,0 +1,14 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Retirement.Service.Requests +{ + public class RetirementUpdateResignInfoRequest + { + public string? Location { get; set; } + public string? ReasonResign { get; set; } + public string? Remark { get; set; } + public DateTime? SendDate { get; set; } + public DateTime? ActiveDate { get; set; } + } +}