add api เพิ่มเติมระบบลงเวลา
This commit is contained in:
parent
8782aec4c3
commit
19bcc6bed2
11 changed files with 291 additions and 11 deletions
|
|
@ -8,6 +8,7 @@ using BMA.EHR.Domain.Shared;
|
|||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Sentry;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Security.Claims;
|
||||
|
||||
|
|
@ -342,7 +343,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
EndTimeAfternoon = duty == null ? "00:00" : duty.EndTimeAfternoon,
|
||||
Description = duty == null ? "-" : duty.Description,
|
||||
CheckInTime = data.CheckIn,
|
||||
CheckInId = data.CheckOut == null ? null : data.Id,
|
||||
CheckInId = data.Id,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -415,6 +416,75 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
return Success(new { date = currentDate });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV1_007 - ประวัติการลงเวลา (USER)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("check-in/history")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> CheckInHistoryAsync(int year, int page = 1, int pageSize = 10, string keyword = "")
|
||||
{
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
var data = (await _userTimeStampRepository.GetTimeStampHistoryAsync(userId, year, page, pageSize, keyword))
|
||||
.Select(d => new CheckInHistoryDto
|
||||
{
|
||||
CheckInId = d.Id,
|
||||
|
||||
CheckInDate = d.CheckIn.Date,
|
||||
CheckInTime = d.CheckIn.ToString("HH:mm"),
|
||||
CheckInLocation = d.CheckInPOI,
|
||||
CheckInStatus = "NORMAL", // TODO : เอาจากที่ประมวลแล้ว
|
||||
|
||||
CheckOutDate = d.CheckOut == null ? null : d.CheckOut.Value.Date,
|
||||
CheckOutTime = d.CheckOut == null ? "" : d.CheckOut.Value.ToString("HH:mm"),
|
||||
CheckOutLocation = d.CheckOutPOI ?? "",
|
||||
CheckOutStatus = d.CheckOut == null ? "" : "NORMAL" // TODO : เอาจากที่ประมวลแล้ว
|
||||
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("log-record")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> LogRecordAsync(DateTime startDate, DateTime endDate, int page = 1, int pageSize = 10, string keyword = "")
|
||||
{
|
||||
var imgUrl = $"{_configuration["MinIO:Endpoint"]}{_configuration["MinIO:BucketName"]}";
|
||||
var data = (await _userTimeStampRepository.GetTimeStampHistoryForAdminAsync(startDate, endDate, page, pageSize, keyword))
|
||||
.Select(d => new CheckInHistoryForAdminDto
|
||||
{
|
||||
CheckInId = d.Id,
|
||||
FullName = _userProfileRepository.GetUserFullName(d.KeycloakUserId),
|
||||
|
||||
CheckInDate = d.CheckIn.Date,
|
||||
CheckInTime = d.CheckIn.ToString("HH:mm"),
|
||||
CheckInLocation = d.CheckInPOI,
|
||||
CheckInLat = d.CheckInLat,
|
||||
CheckInLon = d.CheckInLon,
|
||||
CheckInImageUrl = $"{imgUrl}/{d.CheckInImageUrl}",
|
||||
|
||||
CheckOutDate = d.CheckOut == null ? null : d.CheckOut.Value.Date,
|
||||
CheckOutTime = d.CheckOut == null ? "" : d.CheckOut.Value.ToString("HH:mm"),
|
||||
CheckOutLocation = d.CheckOut == null ? "" : d.CheckOutPOI,
|
||||
CheckOutLat = d.CheckOut == null ? null : d.CheckOutLat,
|
||||
CheckOutLon = d.CheckOut == null ? null : d.CheckOutLon,
|
||||
CheckOutImageUrl = d.CheckOut == null ? "" : $"{imgUrl}/{d.CheckOutImageUrl}",
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue