Merge branch 'develop' into adiDev
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 1m55s
Build & Deploy Retirement Service / build (push) Successful in 1m46s

This commit is contained in:
Adisak 2026-06-04 09:38:03 +07:00
commit 077b60b1c3
12 changed files with 569 additions and 53 deletions

View file

@ -151,7 +151,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
var retirementResigns = await _context.RetirementResigns.AsQueryable()
.Where(x => x.profileId == org.result.profileId)
.Where(x => x.Status != "DELETE" && x.profileId == org.result.profileId)
.OrderByDescending(x => x.CreatedAt)
.Select(p => new
{
@ -1811,6 +1811,47 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Success();
}
/// <summary>
/// API ลบรายการลาออก (ADMIN)
/// </summary>
/// <param name="id">Id ลาออก</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpDelete("admin/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> DeleteForAdminAsync(Guid id)
{
var jsonData = await _permission.GetPermissionWithActingAPIAsync("DELETE", "SYS_RESIGN");
if (jsonData!.status != 200)
{
return Error(jsonData.message, StatusCodes.Status403Forbidden);
}
// ตรวจสอบว่า role ต้องเป็น OWNER เท่านั้น
if (jsonData.result.privilege != "OWNER")
{
return Error("ไม่มีสิทธิ์ในการลบรายการลาออก", StatusCodes.Status403Forbidden);
}
var deleted = await _context.RetirementResigns.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == id);
if (deleted == null)
return Error(GlobalMessages.RetirementResignNotFound, 404);
// ห้ามลบเฉพาะสถานะ REPORT, WAITING, DONE, CANCELING, CANCEL
if (new[] { "REPORT", "WAITING", "DONE", "CANCELING", "CANCEL" }.Contains(deleted.Status))
{
return Error("ไม่สามารถลบรายการลาออกสถานะนี้ได้");
}
deleted.Status = "DELETE";
deleted.LastUpdateFullName = FullName ?? "System Administrator";
deleted.LastUpdateUserId = UserId ?? "";
deleted.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
/// <summary>
/// อนุมัติคำลาออก
/// </summary>