แก้ defect

add send noti when create ลงเวลากรณีพิเศษ
This commit is contained in:
Suphonchai Phoonsawat 2024-01-17 12:42:19 +07:00
parent bb637bca36
commit ee4ef41547
8 changed files with 144 additions and 12 deletions

View file

@ -119,7 +119,7 @@ namespace BMA.EHR.Leave.Service.Controllers
var isDuplicate = await _leaveRequestRepository.CheckDuplicateLeave(userId, req.LeaveStartDate.Date, req.LeaveEndDate.Date);
if (isDuplicate)
{
return Error("ไม่สามารถขอลาในช่วงเวลาเดียวกันได้");
return Error("ไม่สามารถขอลาในช่วงเวลาเดียวกันได้ เนื่องจากมีการขอลาในช่วงเวลาดังกล่าวแล้ว");
}
var thisYear = DateTime.Now.Year;
@ -980,13 +980,24 @@ namespace BMA.EHR.Leave.Service.Controllers
public async Task<ActionResult<ResponseObject>> GetLeaveRequestForAdminAsync(
[FromBody] GetLeaveRequestForAdminDto req)
{
var rawData = await _leaveRequestRepository.GetLeaveRequestForAdminAsync(req.Year, req.Type, req.Status);
var rawData = await _leaveRequestRepository.GetLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate);
var result = new List<GetLeaveRequestForAdminResultDto>();
foreach (var item in rawData)
{
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId);
// Get Organization
var org = await _userProfileRepository.GetOrganizationById(profile.OcId ?? Guid.Empty);
var agency_id = org == null ? Guid.Empty : org.OrganizationAgencyId ?? Guid.Empty;
var gov_agency_id = org == null ? Guid.Empty : org.OrganizationGovernmentAgencyId ?? Guid.Empty;
var agency = await _userProfileRepository.GetOrgAgencyById(agency_id);
var gov_agency = await _userProfileRepository.GetOrgGovAgencyById(gov_agency_id);
var res = new GetLeaveRequestForAdminResultDto
{
Id = item.Id,
@ -994,7 +1005,14 @@ namespace BMA.EHR.Leave.Service.Controllers
LeaveTypeName = item.Type.Name,
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
DateSendLeave = item.CreatedAt.Date,
Status = item.LeaveStatus
Status = item.LeaveStatus,
CitizenId = profile.CitizenId ?? "",
LeaveStartDate = item.LeaveStartDate,
LeaveEndDate = item.LeaveEndDate,
Position = profile.Position == null ? "" : profile.Position.Name,
Level = profile.PositionLevel == null ? "" : profile.PositionLevel.Name,
Agency = agency == null ? "" : agency.Name,
Org = gov_agency == null ? "" : gov_agency.Name
};
result.Add(res);
}
@ -1524,17 +1542,17 @@ namespace BMA.EHR.Leave.Service.Controllers
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpDelete("user/file/document/{id:guid}")]
[HttpDelete("user/file/document/{id:guid}/{docId:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> DeleteLeaveDocumentByIdAsync(Guid id, [FromBody] DeleteLeaveDocumentDto req)
public async Task<ActionResult<ResponseObject>> DeleteLeaveDocumentByIdAsync(Guid id, Guid docId)
{
var leaveReq = await _leaveRequestRepository.GetByIdAsync(id);
if (leaveReq == null)
return Error(GlobalMessages.DataNotFound);
var doc = leaveReq.LeaveDocument.Where(x => x.Document.Id == req.DocId).FirstOrDefault();
var doc = leaveReq.LeaveDocument.Where(x => x.Document.Id == docId).FirstOrDefault();
if (doc != null)
{
await _minIOService.DeleteFileAsync(doc.Document.Id);