add API จัดการปฏิทินวันหยุด ขรก

This commit is contained in:
Suphonchai Phoonsawat 2024-01-09 10:25:18 +07:00
parent 0e22e3886f
commit 77410d9fa3
4 changed files with 81 additions and 10 deletions

View file

@ -5,6 +5,7 @@ using BMA.EHR.Domain.Models.Leave.TimeAttendants;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Leave.Service.DTOs.AdditionalCheck;
using BMA.EHR.Leave.Service.DTOs.Calendar;
using BMA.EHR.Leave.Service.DTOs.ChangeRound;
using BMA.EHR.Leave.Service.DTOs.CheckIn;
using BMA.EHR.Leave.Service.DTOs.DutyTime;
@ -38,6 +39,8 @@ namespace BMA.EHR.Leave.Service.Controllers
private readonly UserDutyTimeRepository _userDutyTimeRepository;
private readonly AdditionalCheckRequestRepository _additionalCheckRequestRepository;
private readonly UserCalendarRepository _userCalendarRepository;
private readonly string _bucketName = "check-in";
#endregion
@ -54,7 +57,8 @@ namespace BMA.EHR.Leave.Service.Controllers
MinIOService minIOService,
ProcessUserTimeStampRepository processUserTimeStampRepository,
UserDutyTimeRepository userDutyTimeRepository,
AdditionalCheckRequestRepository additionalCheckRequestRepository)
AdditionalCheckRequestRepository additionalCheckRequestRepository,
UserCalendarRepository userCalendarRepository)
{
_dutyTimeRepository = dutyTimeRepository;
_context = context;
@ -67,6 +71,7 @@ namespace BMA.EHR.Leave.Service.Controllers
_processUserTimeStampRepository = processUserTimeStampRepository;
_userDutyTimeRepository = userDutyTimeRepository;
_additionalCheckRequestRepository = additionalCheckRequestRepository;
_userCalendarRepository = userCalendarRepository;
}
#endregion
@ -1490,6 +1495,65 @@ namespace BMA.EHR.Leave.Service.Controllers
#endregion
#endregion
#region " ปฏิทินการทำงานของ ขรก. "
/// <summary>
/// LV1_023 - แสดงปฏิทินวันทำงานรายคน (ADMIN)
/// </summary>
/// <returns>
/// </returns>
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("admin/work/{id:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCalendarByProfileAsync(Guid id)
{
var data = await _userCalendarRepository.GetExist(id);
if (data == null)
return Success(new { Work = "NORMAL" });
else
return Success(new { Work = data.Calendar });
}
/// <summary>
/// LV1_024 - บันทึกแก้ไขปฏิทินวันทำงาน (ADMIN)
/// </summary>
/// <returns>
/// </returns>
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("admin/work/{id:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> UpdateCalendarByProfileAsync(Guid id, [FromBody] UpdateCalendarDto req)
{
var data = await _userCalendarRepository.GetExist(id);
if (data != null)
{
data.Calendar = req.Work;
await _userCalendarRepository.UpdateAsync(data);
return Success();
}
else
{
data = new UserCalendar
{
ProfileId = id,
Calendar = req.Work
};
await _userCalendarRepository.AddAsync(data);
return Success();
}
#endregion
#endregion
}
}
}