This commit is contained in:
AdisakKanthawilang 2025-03-11 17:33:10 +07:00
parent 3882e11454
commit 7a9053f5ce
3 changed files with 100 additions and 3 deletions

View file

@ -367,6 +367,100 @@ namespace BMA.EHR.Application.Repositories
}
}
public async Task<List<GetProfileByKeycloakIdRootDto>> 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<SearchProfileDto>();
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
if (apiResult != null)
{
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
if (raw != null)
return raw.Result;
}
return null;
}
catch
{
throw;
}
}
public async Task<List<GetProfileByKeycloakIdRootDto>> 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<SearchProfileDto>();
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
if (apiResult != null)
{
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
if (raw != null)
return raw.Result;
}
return null;
}
catch
{
throw;
}
}
public async Task<List<GetProfileByKeycloakIdRootDto>> 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<SearchProfileDto>();
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
if (apiResult != null)
{
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
if (raw != null)
return raw.Result;
}
return null;
}
catch
{
throw;
}
}
public async Task<List<SearchProfileDto>> SearchProfile(string? citizenId, string? firstName, string? lastName, string accessToken)
{
try

View file

@ -758,11 +758,11 @@ namespace BMA.EHR.Leave.Service.Controllers
var profile = new List<GetProfileByKeycloakIdRootDto>();
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<GetProfileByKeycloakIdRootDto>();
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);

View file

@ -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; }
}
}