Add CreateLeaveProcessJobDto and implement CreateProcessTaskAsync in LeaveController
This commit is contained in:
parent
de1773880b
commit
c1ac687101
2 changed files with 71 additions and 2 deletions
|
|
@ -74,6 +74,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
private readonly LeaveProcessJobStatusRepository _leaveProcessJobStatusRepository;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constuctor and Destructor "
|
||||
|
|
@ -97,7 +99,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
NotificationRepository notificationRepository,
|
||||
CheckInJobStatusRepository checkInJobStatusRepository,
|
||||
HttpClient httpClient,
|
||||
ApplicationDBContext appDbContext)
|
||||
ApplicationDBContext appDbContext,
|
||||
LeaveProcessJobStatusRepository leaveProcessJobStatusRepository)
|
||||
{
|
||||
_dutyTimeRepository = dutyTimeRepository;
|
||||
_context = context;
|
||||
|
|
@ -116,7 +119,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
_leaveRequestRepository = leaveRequestRepository;
|
||||
_notificationRepository = notificationRepository;
|
||||
_checkInJobStatusRepository = checkInJobStatusRepository;
|
||||
|
||||
_leaveProcessJobStatusRepository = leaveProcessJobStatusRepository;
|
||||
_objectPool = objectPool;
|
||||
_permission = permission;
|
||||
|
||||
|
|
@ -4156,6 +4159,49 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
#endregion
|
||||
|
||||
#region " Process - Leave and Absence "
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// สร้าง Task สำหรับ Process ข้อมูลวันลาและขาดราชการ (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("admin/leave-task/process")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> CreateProcessTaskAsync([FromBody] CreateLeaveProcessJobDto req)
|
||||
{
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(userId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var task = new LeaveProcessJobStatus
|
||||
{
|
||||
RootDnaId = profile.RootDnaId ?? Guid.Empty,
|
||||
CreatedUserId = profile.Keycloak?.ToString("D") ?? "",
|
||||
CreatedFullName = profile.FirstName + " " + profile.LastName,
|
||||
CreatedAt = DateTime.Now,
|
||||
Status = "PENDING",
|
||||
StartDate = req.StartDate,
|
||||
EndDate = req.EndDate
|
||||
};
|
||||
|
||||
await _leaveProcessJobStatusRepository.AddAsync(task);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
|
|
|||
23
BMA.EHR.Leave/DTOs/LeaveRequest/CreateLeaveProcessJobDto.cs
Normal file
23
BMA.EHR.Leave/DTOs/LeaveRequest/CreateLeaveProcessJobDto.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// ข้อมูลสำหรับสร้าง Job ประมวลผลวันลา โดยมีช่วงวันที่เริ่มต้นและสิ้นสุดของการประมวลผลวันลา
|
||||
/// </summary>
|
||||
public class CreateLeaveProcessJobDto
|
||||
{
|
||||
/// <summary>
|
||||
/// วันที่เริ่มต้นของการประมวลผลวันลา
|
||||
/// </summary>
|
||||
public DateTime StartDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// วันที่สิ้นสุดของการประมวลผลวันลา
|
||||
/// </summary>
|
||||
public DateTime EndDate { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue