add
LV2_015 - รายการขอยกเลิกการลา (ADMIN) LV2_008 - ขอยกเลิกการลา (USER)
This commit is contained in:
parent
1a4d03cdd9
commit
0c2814e53b
13 changed files with 3320 additions and 14 deletions
|
|
@ -582,6 +582,92 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Success(new { data = pageResult, total = result.Count });
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// LV2_008 - ขอยกเลิกการลา (USER)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("user/delete/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> CancelLeaveRequestAsync([FromForm] CancelLeaveRequestDto req, Guid id)
|
||||
{
|
||||
var data = await _leaveRequestRepository.GetByIdAsync(id);
|
||||
if (data == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
// change status to delete
|
||||
data.LeaveStatus = "DELETE";
|
||||
|
||||
// add cancel status to new
|
||||
data.LeaveCancelStatus = "NEW";
|
||||
data.LeaveCancelComment = req.Reason ?? "";
|
||||
|
||||
// upload leave cancel document
|
||||
if (req.Doc != null)
|
||||
{
|
||||
var doc = await _minIOService.UploadFileAsync(req.Doc);
|
||||
if (doc != null)
|
||||
{
|
||||
data.LeaveCancelDocument = doc;
|
||||
}
|
||||
}
|
||||
|
||||
// save to database
|
||||
await _leaveRequestRepository.UpdateAsync(data);
|
||||
|
||||
return Success();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_015 - รายการขอยกเลิกการลา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("admin/delete")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetCancelLeaveRequestForAdminAsync([FromBody] GetLeaveRequestForAdminDto req)
|
||||
{
|
||||
var rawData = await _leaveRequestRepository.GetCancelLeaveRequestForAdminAsync(req.Year, req.Type, req.Status);
|
||||
|
||||
var result = new List<GetLeaveCancelRequestResultDto>();
|
||||
|
||||
foreach (var item in rawData)
|
||||
{
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId);
|
||||
var res = new GetLeaveCancelRequestResultDto
|
||||
{
|
||||
Id = item.Id,
|
||||
LeaveTypeId = item.Type.Id,
|
||||
LeaveTypeName = item.Type.Name,
|
||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
||||
DateSendLeave = item.CreatedAt.Date,
|
||||
Status = item.LeaveCancelStatus
|
||||
};
|
||||
result.Add(res);
|
||||
}
|
||||
|
||||
if (req.Keyword != "")
|
||||
result = result.Where(x => x.FullName.Contains(req.Keyword)).ToList();
|
||||
|
||||
var pageResult = result.Skip((req.Page - 1) * req.PageSize).Take(req.PageSize).ToList();
|
||||
|
||||
return Success(new { data = pageResult, total = result.Count });
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue