migrate + api บันทึกผู้ตรวจสอบและส่งไปพิจาณา #2109
Some checks failed
release-dev / release-dev (push) Failing after 12s
Some checks failed
release-dev / release-dev (push) Failing after 12s
This commit is contained in:
parent
59fd20c879
commit
0a58075428
8 changed files with 1722 additions and 4 deletions
|
|
@ -159,6 +159,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
FirstName = r.FirstName,
|
||||
LastName = r.LastName,
|
||||
PositionName = r.PositionName,
|
||||
PositionSign = r.PositionSign,
|
||||
ProfileId = r.ProfileId,
|
||||
KeycloakId = r.KeycloakId,
|
||||
ApproveStatus = "PENDING",
|
||||
|
|
@ -1944,6 +1945,73 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Success(result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// เพิ่มชื่อผู้ส่งไปพิจารณา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("admin/sender/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> SenderLeaveRequestAsync(Guid id)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(Guid.Parse(UserId!), AccessToken);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var rawData = await _leaveRequestRepository.GetByIdAsync(id);
|
||||
|
||||
if (rawData == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var sender = rawData.Approvers
|
||||
.Where(x => x.ApproveType!.ToUpper() == "SENDER")
|
||||
.FirstOrDefault();
|
||||
|
||||
if (sender == null)
|
||||
{
|
||||
await _leaveRequestRepository.AddApproversAsync(id, new List<LeaveRequestApprover>
|
||||
{
|
||||
new LeaveRequestApprover
|
||||
{
|
||||
Prefix = profile.Prefix,
|
||||
FirstName = profile.FirstName,
|
||||
LastName = profile.LastName,
|
||||
PositionName = profile.Position,
|
||||
ProfileId = profile.Id,
|
||||
KeycloakId = Guid.Parse(UserId!),
|
||||
ApproveType = "SENDER",
|
||||
|
||||
CreatedFullName = FullName ?? "",
|
||||
CreatedUserId = UserId!,
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "",
|
||||
LastUpdateUserId = UserId!,
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_018 - ผู้มีอำนาจอนุมัติขอยกเลิกการลา(ADMIN)
|
||||
/// </summary>
|
||||
|
|
@ -2460,6 +2528,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
FirstName = x.FirstName,
|
||||
LastName = x.LastName,
|
||||
PositionName = x.PositionName,
|
||||
PositionSign = x.PositionSign,
|
||||
ApproveStatus = x.ApproveStatus,
|
||||
Comment = x.Comment,
|
||||
ProfileId = x.ProfileId,
|
||||
|
|
@ -2474,6 +2543,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
FirstName = x.FirstName,
|
||||
LastName = x.LastName,
|
||||
PositionName = x.PositionName,
|
||||
PositionSign = x.PositionSign,
|
||||
ApproveStatus = x.ApproveStatus,
|
||||
Comment = x.Comment,
|
||||
ProfileId = x.ProfileId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue