diff --git a/BMA.EHR.Application/Repositories/UserProfileRepository.cs b/BMA.EHR.Application/Repositories/UserProfileRepository.cs index db36e5c9..f4e3fad3 100644 --- a/BMA.EHR.Application/Repositories/UserProfileRepository.cs +++ b/BMA.EHR.Application/Repositories/UserProfileRepository.cs @@ -367,6 +367,100 @@ namespace BMA.EHR.Application.Repositories } } + public async Task> GetProfileWithKeycloakAllOfficerAndRevision(string? accessToken, int? node, string? nodeId, bool isAll, string? revisionId) + { + try + { + var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak-all-officer"; + var apiKey = _configuration["API_KEY"]; + var body = new + { + node = node, + nodeId = nodeId, + isAll = isAll, + }; + + var profiles = new List(); + + var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + } + + return null; + } + catch + { + throw; + } + } + + public async Task> GetProfileWithKeycloakAllOfficerRetireFilterAndRevision(string? accessToken, int? node, string? nodeId, bool isAll, bool? isRetirement, string? revisionId) + { + try + { + var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak-all-officer"; + var apiKey = _configuration["API_KEY"]; + var body = new + { + node = node, + nodeId = nodeId, + isAll = isAll, + isRetirement = isRetirement, + }; + + var profiles = new List(); + + var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + } + + return null; + } + catch + { + throw; + } + } + + public async Task> GetProfileWithKeycloakAllEmployeeAndRevision(string? accessToken, int? node, string? nodeId, bool isAll, string? revisionId) + { + try + { + var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak-all-employee"; + var apiKey = _configuration["API_KEY"]; + var body = new + { + node = node, + nodeId = nodeId, + isAll = isAll, + }; + + var profiles = new List(); + + var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + } + + return null; + } + catch + { + throw; + } + } + public async Task> SearchProfile(string? citizenId, string? firstName, string? lastName, string accessToken) { try diff --git a/BMA.EHR.Leave/Controllers/LeaveReportController.cs b/BMA.EHR.Leave/Controllers/LeaveReportController.cs index 16e0c2e8..1568fdeb 100644 --- a/BMA.EHR.Leave/Controllers/LeaveReportController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveReportController.cs @@ -758,11 +758,11 @@ namespace BMA.EHR.Leave.Service.Controllers var profile = new List(); if (type.Trim().ToUpper() == "OFFICER") { - profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD"); + profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficerAndRevision(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.revisionId); } else { - profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD"); + profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployeeAndRevision(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.revisionId); } // get leave day var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRange(req.StartDate, req.EndDate); @@ -914,6 +914,7 @@ namespace BMA.EHR.Leave.Service.Controllers headerText = type.Trim().ToUpper() == "OFFICER" ? "ข้าราชการสามัญ" : "ลูกจ้างประจำ", leaveTitleType = leaveTitleType, employees = employees, + profile = profile } }; @@ -949,7 +950,7 @@ namespace BMA.EHR.Leave.Service.Controllers return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); } var profile = new List(); - profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficerRetireFilter(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.isRetirement??true); + profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficerRetireFilterAndRevision(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.isRetirement??true, req.revisionId); // get leave day var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRange(req.StartDate, req.EndDate); diff --git a/BMA.EHR.Leave/DTOs/Reports/GetLeaveDetailByNodeReportDto.cs b/BMA.EHR.Leave/DTOs/Reports/GetLeaveDetailByNodeReportDto.cs index 6d00f073..2216f9bc 100644 --- a/BMA.EHR.Leave/DTOs/Reports/GetLeaveDetailByNodeReportDto.cs +++ b/BMA.EHR.Leave/DTOs/Reports/GetLeaveDetailByNodeReportDto.cs @@ -8,5 +8,7 @@ namespace BMA.EHR.Leave.Service.DTOs.Reports public int node { get; set; } public string nodeId { get; set; } public bool? isRetirement { get; set; } = false; + + public string? revisionId { get; set; } } } \ No newline at end of file