Merge branch 'dev' into working
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m56s
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m56s
This commit is contained in:
commit
513956c861
8 changed files with 404 additions and 26 deletions
|
|
@ -2134,6 +2134,45 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API ลบรายการการลา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("admin/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteLeaveRequestForAdminAsync(Guid id)
|
||||
{
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("DELETE", "SYS_LEAVE_LIST");
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// ตรวจสอบว่า role ต้องเป็น OWNER เท่านั้น
|
||||
if (jsonData.result.privilege != "OWNER")
|
||||
{
|
||||
return Error("ไม่มีสิทธิ์ในการลบรายการขอลา", StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
var deleted = await _leaveRequestRepository.GetByIdAsync(id);
|
||||
if (deleted == null)
|
||||
return Error(GlobalMessages.DataNotFound);
|
||||
|
||||
// ห้ามลบเฉพาะสถานะ APPROVE, DELETING, DELETE
|
||||
if (new[] { "APPROVE", "DELETING", "DELETE" }.Contains(deleted.LeaveStatus))
|
||||
{
|
||||
return Error("ไม่สามารถลบรายการขอลาสถานะนี้ได้");
|
||||
}
|
||||
|
||||
await _leaveRequestRepository.DeleteAsync(deleted);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_014 - รายการขอยกเลิกการลา (ADMIN)
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue