แก้ list พ้น
This commit is contained in:
parent
bebd9620a5
commit
817f7a91ac
8 changed files with 92 additions and 77 deletions
|
|
@ -81,39 +81,25 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
[HttpGet()]
|
||||
public async Task<ActionResult<ResponseObject>> GetList()
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_PASSAWAY");
|
||||
var getPermission = await _permission.GetPermissionOrgAPIAsync("LIST", "SYS_PASSAWAY", 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();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<Requests.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 retirementDeceaseds = await _context.RetirementDeceaseds.AsQueryable()
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id)))))
|
||||
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 retirementDeceaseds = await _context.RetirementDeceaseds.AsQueryable()
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Where(x => rootId == null ? true : rootId.Contains(x.rootId))
|
||||
.Where(x => child1Id == null ? true : child1Id.Contains(x.child1Id))
|
||||
.Where(x => child2Id == null ? true : child2Id.Contains(x.child2Id))
|
||||
.Where(x => child3Id == null ? true : child3Id.Contains(x.child3Id))
|
||||
.Where(x => child4Id == null ? true : child4Id.Contains(x.child4Id))
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
|
|
@ -140,36 +126,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
p.IsActive,
|
||||
})
|
||||
.ToListAsync();
|
||||
// var _retirementDeceaseds = new List<dynamic>();
|
||||
// foreach (var data in retirementDeceaseds)
|
||||
// {
|
||||
// var _data = new
|
||||
// {
|
||||
// data.Id,
|
||||
// data.ProfileId,
|
||||
// data.Prefix,
|
||||
// data.FirstName,
|
||||
// data.LastName,
|
||||
// data.Position,
|
||||
// data.PositionExecutive,
|
||||
// data.PositionType,
|
||||
// data.PositionLine,
|
||||
// data.PositionLevel,
|
||||
// data.Organization,
|
||||
// data.Number,
|
||||
// data.Date,
|
||||
// data.Location,
|
||||
// data.Reason,
|
||||
// data.FileName,
|
||||
// PathName = data.PathName == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.PathName),
|
||||
// data.IsActive,
|
||||
// data.CreatedAt,
|
||||
// };
|
||||
// _retirementDeceaseds.Add(_data);
|
||||
// }
|
||||
return Success(retirementDeceaseds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue