no message
This commit is contained in:
parent
b98b02ac98
commit
e7728d71bd
8 changed files with 242 additions and 298 deletions
|
|
@ -69,83 +69,66 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet()]
|
||||
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);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var rootId = "";
|
||||
var child1Id = "";
|
||||
var child2Id = "";
|
||||
var child3Id = "";
|
||||
var child4Id = "";
|
||||
var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
// 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 placementOfficers = await _context.PlacementOfficers.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)
|
||||
.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);
|
||||
|
||||
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);
|
||||
}
|
||||
return Success(placementOfficers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue