change insigniaTypeId เป็น optional
Some checks failed
release-dev / release-dev (push) Failing after 11s
Some checks failed
release-dev / release-dev (push) Failing after 11s
This commit is contained in:
parent
8ce58201e9
commit
0b407f3c68
4 changed files with 116 additions and 78 deletions
|
|
@ -4,8 +4,10 @@ using BMA.EHR.Application.Requests;
|
|||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Models.Insignias;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using BMA.EHR.Insignia.Service.Requests;
|
||||
using Elasticsearch.Net;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
|
@ -583,8 +585,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("reclaim/{year}/{insigniaTypeId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> ListReclaimInsignia(int year, Guid insigniaTypeId)
|
||||
[HttpPost("reclaim-list")]
|
||||
public async Task<ActionResult<ResponseObject>> ListReclaimInsignia([FromBody] GetReclaimListRequest req)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_RECLAIM");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
|
|
@ -592,10 +594,16 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var insigniaType = await _context.InsigniaTypes
|
||||
.FirstOrDefaultAsync(x => x.Id == insigniaTypeId);
|
||||
if (insigniaType == null)
|
||||
return Error(GlobalMessages.InsigniaTypeNotFound);
|
||||
|
||||
InsigniaType? insigniaType = null;
|
||||
if (req.InsigniaTypeId != null)
|
||||
{
|
||||
insigniaType = await _context.InsigniaTypes
|
||||
.FirstOrDefaultAsync(x => x.Id == req.InsigniaTypeId);
|
||||
if (insigniaType == null)
|
||||
return Error(GlobalMessages.InsigniaTypeNotFound);
|
||||
}
|
||||
|
||||
|
||||
string role = jsonData["result"];
|
||||
var nodeId = string.Empty;
|
||||
|
|
@ -623,8 +631,11 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
var node = profileAdmin?.Node;
|
||||
|
||||
var rawData = await _context.InsigniaReclaimProfiles.AsQueryable()
|
||||
.Where(x => x.InsigniaNoteProfile.RequestInsignia.InsigniaType == insigniaType)
|
||||
.Where(x => year == 0 ? x.Id != null : x.ReclaimDate!.Value.Year == year)
|
||||
.Include(x => x.InsigniaNoteProfile)
|
||||
.ThenInclude(x => x.RequestInsignia)
|
||||
.ThenInclude(x => x.InsigniaType)
|
||||
//.Where(x => x.InsigniaNoteProfile.RequestInsignia.InsigniaType == insigniaType)
|
||||
.Where(x => req.Year == 0 ? x.Id != null : x.ReclaimDate!.Value.Year == req.Year)
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Select(p => new
|
||||
{
|
||||
|
|
@ -668,9 +679,15 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
Child3DnaId = p.InsigniaNoteProfile.Child3DnaId,
|
||||
Child4DnaId = p.InsigniaNoteProfile.Child4DnaId,
|
||||
|
||||
InsigniaTypeId = p.InsigniaNoteProfile.RequestInsignia.InsigniaType.Id
|
||||
|
||||
}).ToListAsync();
|
||||
|
||||
|
||||
if (req.InsigniaTypeId != null)
|
||||
{
|
||||
rawData = rawData.Where(x => x.InsigniaTypeId == req.InsigniaTypeId).ToList();
|
||||
}
|
||||
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
|
|
@ -946,7 +963,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
})
|
||||
.ToListAsync();
|
||||
|
||||
if(role == "OWNER")
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue