no message

This commit is contained in:
kittapath 2024-11-06 10:20:17 +07:00
parent b98b02ac98
commit e7728d71bd
8 changed files with 242 additions and 298 deletions

View file

@ -71,6 +71,27 @@ namespace BMA.EHR.Application.Repositories
} }
} }
public async Task<dynamic> GetPermissionOrgAPIAsync(string action, string system, string profileId)
{
try
{
var apiPath = $"{_configuration["API"]}/org/permission/dotnet-org/{action}/{system}/{profileId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = await client.GetAsync(apiPath);
var res = await req.Content.ReadAsStringAsync();
return res;
}
}
catch
{
throw;
}
}
public async Task<dynamic> GetPermissionAPIWorkflowAsync(string refId, string sysName) public async Task<dynamic> GetPermissionAPIWorkflowAsync(string refId, string sysName)
{ {
try try

View file

@ -68,17 +68,26 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response> /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response> /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet()] [HttpGet()]
// public async Task<ActionResult<ResponseObject>> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "")
public async Task<ActionResult<ResponseObject>> GetListByAdmin() public async Task<ActionResult<ResponseObject>> GetListByAdmin()
{ {
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_PROMOTION_OFFICER"); var getPermission = await _permission.GetPermissionOrgAPIAsync("LIST", "SYS_PROMOTION_OFFICER", UserId);
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission); var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
if (jsonData["status"]?.ToString() != "200") if (jsonData["status"]?.ToString() != "200")
{ {
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
} }
// string?[] rootId = jsonData?.result?.rootId ?? null;
// string?[] child1Id = jsonData?.result?.child1Id ?? null;
// string?[] child2Id = jsonData?.result?.child2Id ?? null;
// string?[] child3Id = jsonData?.result?.child3Id ?? null;
// string?[] child4Id = jsonData?.result?.child4Id ?? null;
var placementAppointments = await _context.PlacementAppointments.AsQueryable() var placementAppointments = await _context.PlacementAppointments.AsQueryable()
.Where(x => x.type == "OFFICER") .Where(x => x.type == "OFFICER")
// .Where(x => rootId == null ? true : rootId.Contains(x.rootOldId))
// .Where(x => child1Id == null ? true : child1Id.Contains(x.child1OldId))
// .Where(x => child2Id == null ? true : child2Id.Contains(x.child2OldId))
// .Where(x => child3Id == null ? true : child3Id.Contains(x.child3OldId))
// .Where(x => child4Id == null ? true : child4Id.Contains(x.child4OldId))
.OrderByDescending(x => x.CreatedAt) .OrderByDescending(x => x.CreatedAt)
.Select(p => new .Select(p => new
{ {
@ -141,7 +150,6 @@ namespace BMA.EHR.Placement.Service.Controllers
p.Status, p.Status,
p.Amount, p.Amount,
// p.RecruitDate,
p.ReportingDate, p.ReportingDate,
p.IsActive, p.IsActive,
@ -259,7 +267,6 @@ namespace BMA.EHR.Placement.Service.Controllers
p.AmountOld, p.AmountOld,
p.OrganizationOld, p.OrganizationOld,
p.positionOld, p.positionOld,
// PlacementAppointmentDocs = p.PlacementAppointmentDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
p.typeCommand, p.typeCommand,
p.posmasterId, p.posmasterId,
}) })
@ -267,16 +274,6 @@ namespace BMA.EHR.Placement.Service.Controllers
if (data == null) if (data == null)
return Error(GlobalMessages.DataNotFound, 404); return Error(GlobalMessages.DataNotFound, 404);
// var placementAppointmentDocs = new List<dynamic>();
// foreach (var doc in data.PlacementAppointmentDocs)
// {
// var _doc = new
// {
// doc.FileName,
// PathName = await _documentService.ImagesPath(doc.Id)
// };
// placementAppointmentDocs.Add(_doc);
// }
var _data = new var _data = new
{ {
data.Id, data.Id,

View file

@ -68,16 +68,25 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response> /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet()] [HttpGet()]
public async Task<ActionResult<ResponseObject>> GetListByAdmin() public async Task<ActionResult<ResponseObject>> GetListByAdmin()
// public async Task<ActionResult<ResponseObject>> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "")
{ {
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_PROMOTION_EMP"); var getPermission = await _permission.GetPermissionOrgAPIAsync("LIST", "SYS_PROMOTION_EMP", UserId);
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission); var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
if (jsonData["status"]?.ToString() != "200") if (jsonData["status"]?.ToString() != "200")
{ {
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
} }
// string?[] rootId = jsonData?.result?.rootId ?? null;
// string?[] child1Id = jsonData?.result?.child1Id ?? null;
// string?[] child2Id = jsonData?.result?.child2Id ?? null;
// string?[] child3Id = jsonData?.result?.child3Id ?? null;
// string?[] child4Id = jsonData?.result?.child4Id ?? null;
var placementAppointments = await _context.PlacementAppointments.AsQueryable() var placementAppointments = await _context.PlacementAppointments.AsQueryable()
.Where(x => x.type == "EMPLOYEE") .Where(x => x.type == "EMPLOYEE")
// .Where(x => rootId == null ? true : rootId.Contains(x.rootOldId))
// .Where(x => child1Id == null ? true : child1Id.Contains(x.child1OldId))
// .Where(x => child2Id == null ? true : child2Id.Contains(x.child2OldId))
// .Where(x => child3Id == null ? true : child3Id.Contains(x.child3OldId))
// .Where(x => child4Id == null ? true : child4Id.Contains(x.child4OldId))
.OrderByDescending(x => x.CreatedAt) .OrderByDescending(x => x.CreatedAt)
.Select(p => new .Select(p => new
{ {

View file

@ -69,83 +69,66 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response> /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet()] [HttpGet()]
public async Task<ActionResult<ResponseObject>> GetListByAdmin() public async Task<ActionResult<ResponseObject>> GetListByAdmin()
// public async Task<ActionResult<ResponseObject>> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "")
{ {
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_TEMPDUTY"); var getPermission = await _permission.GetPermissionOrgAPIAsync("LIST", "SYS_TEMPDUTY", UserId);
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission); var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
if (jsonData["status"]?.ToString() != "200") if (jsonData["status"]?.ToString() != "200")
{ {
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
} }
var rootId = ""; // string?[] rootId = jsonData?.result?.rootId ?? null;
var child1Id = ""; // string?[] child1Id = jsonData?.result?.child1Id ?? null;
var child2Id = ""; // string?[] child2Id = jsonData?.result?.child2Id ?? null;
var child3Id = ""; // string?[] child3Id = jsonData?.result?.child3Id ?? null;
var child4Id = ""; // string?[] child4Id = jsonData?.result?.child4Id ?? null;
var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; var placementOfficers = await _context.PlacementOfficers.AsQueryable()
using (var client = new HttpClient()) // .Where(x => rootId == null ? true : rootId.Contains(x.rootOldId))
{ // .Where(x => child1Id == null ? true : child1Id.Contains(x.child1OldId))
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); // .Where(x => child2Id == null ? true : child2Id.Contains(x.child2OldId))
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); // .Where(x => child3Id == null ? true : child3Id.Contains(x.child3OldId))
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); // .Where(x => child4Id == null ? true : child4Id.Contains(x.child4OldId))
var _res = await client.SendAsync(_req); .OrderByDescending(x => x.CreatedAt)
var _result = await _res.Content.ReadAsStringAsync(); .Select(p => new
{
p.Id,
p.citizenId,
p.profileId,
p.prefix,
p.firstName,
p.lastName,
p.rootOld,
p.rootOldId,
p.rootShortNameOld,
p.child1Old,
p.child1OldId,
p.child1ShortNameOld,
p.child2Old,
p.child2OldId,
p.child2ShortNameOld,
p.child3Old,
p.child3OldId,
p.child3ShortNameOld,
p.child4Old,
p.child4OldId,
p.child4ShortNameOld,
p.PositionOld,
p.posMasterNoOld,
p.posTypeOldId,
p.posTypeNameOld,
p.posLevelOldId,
p.posLevelNameOld,
p.CreatedAt,
p.Reason,
p.Status,
p.DateStart,
p.DateEnd,
p.Organization,
p.OrganizationPositionOld,
p.IsActive,
})
.ToListAsync();
var org = JsonConvert.DeserializeObject<OrgRequest>(_result); return Success(placementOfficers);
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
rootId = org.result.rootId == null ? "" : org.result.rootId;
child1Id = org.result.child1Id == null ? "" : org.result.child1Id;
child2Id = org.result.child2Id == null ? "" : org.result.child2Id;
child3Id = org.result.child3Id == null ? "" : org.result.child3Id;
child4Id = org.result.child4Id == null ? "" : org.result.child4Id;
var placementOfficers = await _context.PlacementOfficers.AsQueryable()
.OrderByDescending(x => x.CreatedAt)
.Where(x => rootId == "" ? true : (child1Id == "" ? x.rootOldId == rootId : (child2Id == "" ? x.child1OldId == child1Id : (child3Id == "" ? x.child2OldId == child2Id : (child4Id == "" ? x.child3OldId == child3Id : x.child4OldId == child4Id)))))
.Select(p => new
{
p.Id,
p.citizenId,
p.profileId,
p.prefix,
p.firstName,
p.lastName,
p.rootOld,
p.rootOldId,
p.rootShortNameOld,
p.child1Old,
p.child1OldId,
p.child1ShortNameOld,
p.child2Old,
p.child2OldId,
p.child2ShortNameOld,
p.child3Old,
p.child3OldId,
p.child3ShortNameOld,
p.child4Old,
p.child4OldId,
p.child4ShortNameOld,
p.PositionOld,
p.posMasterNoOld,
p.posTypeOldId,
p.posTypeNameOld,
p.posLevelOldId,
p.posLevelNameOld,
p.CreatedAt,
p.Reason,
p.Status,
p.DateStart,
p.DateEnd,
p.Organization,
p.OrganizationPositionOld,
p.IsActive,
})
.ToListAsync();
return Success(placementOfficers);
}
} }
/// <summary> /// <summary>

View file

@ -70,40 +70,25 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response> /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet()] [HttpGet()]
public async Task<ActionResult<ResponseObject>> GetListByAdmin() public async Task<ActionResult<ResponseObject>> GetListByAdmin()
// public async Task<ActionResult<ResponseObject>> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "")
{ {
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_TRANSFER_RECEIVE"); var getPermission = await _permission.GetPermissionOrgAPIAsync("LIST", "SYS_TRANSFER_RECEIVE", UserId);
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission); var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
if (jsonData["status"]?.ToString() != "200") if (jsonData["status"]?.ToString() != "200")
{ {
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
} }
// var rootId = ""; // string?[] rootId = jsonData?.result?.rootId ?? null;
// var child1Id = ""; // string?[] child1Id = jsonData?.result?.child1Id ?? null;
// var child2Id = ""; // string?[] child2Id = jsonData?.result?.child2Id ?? null;
// var child3Id = ""; // string?[] child3Id = jsonData?.result?.child3Id ?? null;
// var child4Id = ""; // string?[] child4Id = jsonData?.result?.child4Id ?? null;
// var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position";
// using (var client = new HttpClient())
// {
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
// var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
// var _res = await client.SendAsync(_req);
// var _result = await _res.Content.ReadAsStringAsync();
// var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
// if (org == null || org.result == null)
// return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
// rootId = org.result.rootId == null ? "" : org.result.rootId;
// child1Id = org.result.child1Id == null ? "" : org.result.child1Id;
// child2Id = org.result.child2Id == null ? "" : org.result.child2Id;
// child3Id = org.result.child3Id == null ? "" : org.result.child3Id;
// child4Id = org.result.child4Id == null ? "" : org.result.child4Id;
var placementReceives = await _context.PlacementReceives.AsQueryable() var placementReceives = await _context.PlacementReceives.AsQueryable()
// .Where(x => rootId == null ? true : rootId.Contains(x.rootOldId))
// .Where(x => child1Id == null ? true : child1Id.Contains(x.child1OldId))
// .Where(x => child2Id == null ? true : child2Id.Contains(x.child2OldId))
// .Where(x => child3Id == null ? true : child3Id.Contains(x.child3OldId))
// .Where(x => child4Id == null ? true : child4Id.Contains(x.child4OldId))
.OrderByDescending(x => x.CreatedAt) .OrderByDescending(x => x.CreatedAt)
// .Where(x => PlacementAdmin == true ? true : (rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))))
.Select(p => new .Select(p => new
{ {
p.Id, p.Id,

View file

@ -70,108 +70,69 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response> /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet()] [HttpGet()]
public async Task<ActionResult<ResponseObject>> GetListByAdmin() public async Task<ActionResult<ResponseObject>> GetListByAdmin()
// public async Task<ActionResult<ResponseObject>> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "")
{ {
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_TEMPDUTY2"); var getPermission = await _permission.GetPermissionOrgAPIAsync("LIST", "SYS_TEMPDUTY2", UserId);
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission); var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
if (jsonData["status"]?.ToString() != "200") if (jsonData["status"]?.ToString() != "200")
{ {
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
} }
var rootId = ""; // string?[] rootId = jsonData?.result?.rootId ?? null;
var child1Id = ""; // string?[] child1Id = jsonData?.result?.child1Id ?? null;
var child2Id = ""; // string?[] child2Id = jsonData?.result?.child2Id ?? null;
var child3Id = ""; // string?[] child3Id = jsonData?.result?.child3Id ?? null;
var child4Id = ""; // string?[] child4Id = jsonData?.result?.child4Id ?? null;
var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; var placementRepatriations = await _context.PlacementRepatriations.AsQueryable()
using (var client = new HttpClient()) // .Where(x => rootId == null ? true : rootId.Contains(x.rootOldId))
{ // .Where(x => child1Id == null ? true : child1Id.Contains(x.child1OldId))
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); // .Where(x => child2Id == null ? true : child2Id.Contains(x.child2OldId))
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); // .Where(x => child3Id == null ? true : child3Id.Contains(x.child3OldId))
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); // .Where(x => child4Id == null ? true : child4Id.Contains(x.child4OldId))
var _res = await client.SendAsync(_req); .OrderByDescending(x => x.CreatedAt)
var _result = await _res.Content.ReadAsStringAsync(); .Select(p => new
{
var org = JsonConvert.DeserializeObject<OrgRequest>(_result); p.Id,
p.citizenId,
if (org == null || org.result == null) p.profileId,
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404); p.prefix,
rootId = org.result.rootId == null ? "" : org.result.rootId; p.firstName,
child1Id = org.result.child1Id == null ? "" : org.result.child1Id; p.lastName,
child2Id = org.result.child2Id == null ? "" : org.result.child2Id; p.rootOld,
child3Id = org.result.child3Id == null ? "" : org.result.child3Id; p.rootOldId,
child4Id = org.result.child4Id == null ? "" : org.result.child4Id; p.rootShortNameOld,
p.child1Old,
var placementRepatriations = await _context.PlacementRepatriations.AsQueryable() p.child1OldId,
.OrderByDescending(x => x.CreatedAt) p.child1ShortNameOld,
.Where(x => rootId == "" ? true : (child1Id == "" ? x.rootOldId == rootId : (child2Id == "" ? x.child1OldId == child1Id : (child3Id == "" ? x.child2OldId == child2Id : (child4Id == "" ? x.child3OldId == child3Id : x.child4OldId == child4Id))))) p.child2Old,
.Select(p => new p.child2OldId,
{ p.child2ShortNameOld,
p.Id, p.child3Old,
p.citizenId, p.child3OldId,
p.profileId, p.child3ShortNameOld,
p.prefix, p.child4Old,
p.firstName, p.child4OldId,
p.lastName, p.child4ShortNameOld,
p.rootOld, p.PositionOld,
p.rootOldId, p.posMasterNoOld,
p.rootShortNameOld, p.posTypeOldId,
p.child1Old, p.posTypeNameOld,
p.child1OldId, p.posLevelOldId,
p.child1ShortNameOld, p.posLevelNameOld,
p.child2Old, p.CreatedAt,
p.child2OldId, p.Organization,
p.child2ShortNameOld, p.Reason,
p.child3Old, p.Status,
p.child3OldId, p.Date,
p.child3ShortNameOld, salary = p.AmountOld,
p.child4Old, p.PositionTypeOld,
p.child4OldId, p.PositionLevelOld,
p.child4ShortNameOld, p.PositionNumberOld,
p.PositionOld, p.OrganizationPositionOld,
p.posMasterNoOld, p.IsActive,
p.posTypeOldId, p.DateRepatriation,
p.posTypeNameOld, })
p.posLevelOldId, .ToListAsync();
p.posLevelNameOld, return Success(placementRepatriations);
p.CreatedAt,
p.Organization,
p.Reason,
p.Status,
p.Date,
salary = p.AmountOld,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.IsActive,
p.DateRepatriation,
})
.ToListAsync();
// if (keyword != "")
// {
// var data = placementRepatriations.Where(x =>
// (x.prefix != null && x.prefix.Contains(keyword)) ||
// (x.firstName != null && x.firstName.Contains(keyword)) ||
// (x.lastName != null && x.lastName.Contains(keyword)) ||
// (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) ||
// (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) ||
// (x.PositionOld != null && x.PositionOld.Contains(keyword)) ||
// (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) ||
// (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) ||
// (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) ||
// (x.Organization != null && x.Organization.Contains(keyword)))
// .OrderByDescending(x => x.CreatedAt)
// .Skip((page - 1) * pageSize)
// .Take(pageSize)
// .ToList();
// placementRepatriations = data;
// }
return Success(placementRepatriations);
}
} }
/// <summary> /// <summary>

View file

@ -158,102 +158,69 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response> /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet()] [HttpGet()]
public async Task<ActionResult<ResponseObject>> GetListByAdmin() public async Task<ActionResult<ResponseObject>> GetListByAdmin()
// public async Task<ActionResult<ResponseObject>> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "")
{ {
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_TRANSFER_REQ"); var getPermission = await _permission.GetPermissionOrgAPIAsync("LIST", "SYS_TRANSFER_REQ", UserId);
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission); var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
if (jsonData["status"]?.ToString() != "200") if (jsonData["status"]?.ToString() != "200")
{ {
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
} }
var rootId = ""; // var data = JsonConvert.DeserializeObject<OrgPermissionRequest>(getPermission);
var child1Id = ""; // string?[]? root = data?.Result?.Root ?? null;
var child2Id = ""; // string?[]? child1 = data?.Result?.Child1 ?? null;
var child3Id = ""; // string?[]? child2 = data?.Result?.Child2 ?? null;
var child4Id = ""; // string?[]? child3 = data?.Result?.Child3 ?? null;
var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; // string?[]? child4 = data?.Result?.Child4 ?? null;
using (var client = new HttpClient()) var placementTransfers = await _context.PlacementTransfers.AsQueryable()
{ // .Where(x => root == null ? true : root.Contains(x.rootOldId))
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); // .Where(x => child1 == null ? true : child1.Contains(x.child1OldId))
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); // .Where(x => child2 == null ? true : child2.Contains(x.child2OldId))
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); // .Where(x => child3 == null ? true : child3.Contains(x.child3OldId))
var _res = await client.SendAsync(_req); // .Where(x => child4 == null ? true : child4.Contains(x.child4OldId))
var _result = await _res.Content.ReadAsStringAsync(); .OrderByDescending(x => x.CreatedAt)
.Select(p => new
var org = JsonConvert.DeserializeObject<OrgRequest>(_result); {
p.Id,
if (org == null || org.result == null) p.citizenId,
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404); p.profileId,
rootId = org.result.rootId == null ? "" : org.result.rootId; p.prefix,
child1Id = org.result.child1Id == null ? "" : org.result.child1Id; p.firstName,
child2Id = org.result.child2Id == null ? "" : org.result.child2Id; p.lastName,
child3Id = org.result.child3Id == null ? "" : org.result.child3Id; p.rootOld,
child4Id = org.result.child4Id == null ? "" : org.result.child4Id; p.rootOldId,
p.rootShortNameOld,
var placementTransfers = await _context.PlacementTransfers.AsQueryable() p.child1Old,
.OrderByDescending(x => x.CreatedAt) p.child1OldId,
.Where(x => rootId == "" ? true : (child1Id == "" ? x.rootOldId == rootId : (child2Id == "" ? x.child1OldId == child1Id : (child3Id == "" ? x.child2OldId == child2Id : (child4Id == "" ? x.child3OldId == child3Id : x.child4OldId == child4Id))))) p.child1ShortNameOld,
.Select(p => new p.child2Old,
{ p.child2OldId,
p.Id, p.child2ShortNameOld,
p.citizenId, p.child3Old,
p.profileId, p.child3OldId,
p.prefix, p.child3ShortNameOld,
p.firstName, p.child4Old,
p.lastName, p.child4OldId,
p.rootOld, p.child4ShortNameOld,
p.rootOldId, p.PositionOld,
p.rootShortNameOld, p.posMasterNoOld,
p.child1Old, p.posTypeOldId,
p.child1OldId, p.posTypeNameOld,
p.child1ShortNameOld, p.posLevelOldId,
p.child2Old, p.posLevelNameOld,
p.child2OldId, p.CreatedAt,
p.child2ShortNameOld, p.Organization,
p.child3Old, p.Reason,
p.child3OldId, p.Status,
p.child3ShortNameOld, p.Date,
p.child4Old, salary = p.AmountOld,
p.child4OldId, p.PositionTypeOld,
p.child4ShortNameOld, p.PositionLevelOld,
p.PositionOld, p.PositionNumberOld,
p.posMasterNoOld, p.OrganizationPositionOld,
p.posTypeOldId, p.IsActive,
p.posTypeNameOld, })
p.posLevelOldId, .ToListAsync();
p.posLevelNameOld, return Success(placementTransfers);
p.CreatedAt,
p.Organization,
p.Reason,
p.Status,
p.Date,
salary = p.AmountOld,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.IsActive,
})
.ToListAsync();
// if (keyword != "")
// {
// var data = placementTransfers.Where(x =>
// (x.prefix != null && x.prefix.Contains(keyword)) ||
// (x.firstName != null && x.firstName.Contains(keyword)) ||
// (x.lastName != null && x.lastName.Contains(keyword)) ||
// (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) ||
// (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)))
// .OrderByDescending(x => x.CreatedAt)
// .Skip((page - 1) * pageSize)
// .Take(pageSize)
// .ToList();
// placementTransfers = data;
// }
return Success(placementTransfers);
}
} }
/// <summary> /// <summary>

View file

@ -0,0 +1,21 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Placement.Service.Requests
{
public class OrgPermissionRequest
{
public int Status { get; set; }
public string Message { get; set; }
public OrgPermissionRequestData? Result { get; set; }
}
public class OrgPermissionRequestData
{
public string?[]? Root { get; set; }
public string?[]? Child1 { get; set; }
public string?[]? Child2 { get; set; }
public string?[]? Child3 { get; set; }
public string?[]? Child4 { get; set; }
public string? Privilege { get; set; }
}
}