From 0c80c69b1234805eaf1657de6049b18fcdf629c4 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 27 Sep 2024 17:42:03 +0700 Subject: [PATCH] =?UTF-8?q?fix=20=E0=B9=80=E0=B8=84=E0=B8=A3=E0=B8=B7?= =?UTF-8?q?=E0=B9=88=E0=B8=AD=E0=B8=87=E0=B8=A3=E0=B8=B2=E0=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/InsigniaManageController.cs | 4 +- .../Controllers/InsigniaRequestController.cs | 142 ++++++++++++++++++ 2 files changed, 144 insertions(+), 2 deletions(-) diff --git a/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs b/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs index 1cce1e65..93189ac1 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs @@ -307,7 +307,7 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPost("org")] public async Task> PostOrganization([FromBody] InsigniaManageOrganizationRequest req) { - var getPermission = await _permission.GetPermissionAPIAsync("CREATE", "SYS_INSIGNIA_ALLOCATE"); + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_INSIGNIA_ALLOCATE"); var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { @@ -370,7 +370,7 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpDelete("org/{insigniaManageOrgId:length(36)}")] public async Task> DeleteOrganization(Guid insigniaManageOrgId) { - var getPermission = await _permission.GetPermissionAPIAsync("DELETE", "SYS_INSIGNIA_ALLOCATE"); + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_INSIGNIA_ALLOCATE"); var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index 3559ae03..8096bb67 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -1594,6 +1594,148 @@ namespace BMA.EHR.Insignia.Service.Controllers return Success(_insigniaNoteProfiles); } + + /// + /// list รายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ ไม่ validate สิทธิ์ + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("note-list/search")] + public async Task> GetListNoteProfileNonValidateRole([FromBody] InsigniaNoteSearchRequest req) + { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_RECORD"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + var insigniaNote = await _context.InsigniaNotes + .FirstOrDefaultAsync(x => x.Id == req.InsigniaNoteId); + if (insigniaNote == null) + return Error(GlobalMessages.InsigniaRequestNotFound); + var insigniaType = await _context.InsigniaTypes + .FirstOrDefaultAsync(x => x.Id == req.InsigniaTypeId); + if (insigniaType == null) + return Error(GlobalMessages.InsigniaTypeNotFound); + + var rawNoteProfiles = await _context.InsigniaNoteProfiles + .Where(x => x.InsigniaNote == insigniaNote) + .Where(x => x.RequestInsignia.InsigniaType == insigniaType) + .Where(x => req.InsigniaId == null ? x.RequestInsignia != null : (x.RequestInsignia.Id == req.InsigniaId)) + .Select(x => new + { + Id = x.Id, + Profile = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken), + OcId = Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), // TODO: ต้องมาแก้ไข + RequestInsignia = x.RequestInsignia.Name, + RequestInsigniaId = x.RequestInsignia.Id, + RequestInsigniaShortName = x.RequestInsignia.ShortName, + DateReceive = x.DateReceive, + OrganizationOrganizationSend = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode + OrganizationOrganizationReceive = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode + Status = x.Status, + Issue = x.Issue, + Date = x.Date, + VolumeNo = x.VolumeNo, + Section = x.Section, + Page = x.Page, + No = x.No, + DatePayment = x.DatePayment, + TypePayment = x.TypePayment, + Address = x.Address, + Number = x.Number, + Salary = x.Salary, + DateReceiveInsignia = x.DateReceiveInsignia, + DocReceiveInsignia = x.DocReceiveInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReceiveInsignia.Id, + OrgReceiveInsignia = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode + DateReturnInsignia = x.DateReturnInsignia, + DocReturnInsignia = x.DocReturnInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReturnInsignia.Id, + OrgReturnInsignia = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode + }) + .ToListAsync(); + + var insigniaNoteProfiles = rawNoteProfiles + .Select(x => new + { + Id = x.Id, + Prefix = x.Profile == null ? "" : x.Profile.Prefix, + Position = x.Profile == null ? "" : x.Profile.Position, + ProfileType = x.Profile == null ? "" : x.Profile.ProfileType, + x.OcId, + CitizenId = x.Profile == null ? "" : x.Profile.CitizenId, + FullName = x.Profile == null ? "" : $"{x.Profile.Prefix}{x.Profile.FirstName} {x.Profile.LastName}", + RequestInsignia = x.RequestInsignia, + RequestInsigniaId = x.RequestInsigniaId, + RequestInsigniaShortName = x.RequestInsigniaShortName, + DateReceive = x.DateReceive, + OrganizationOrganizationSend = x.OrganizationOrganizationSend, + OrganizationOrganizationReceive = x.OrganizationOrganizationReceive, + Status = x.Status, + Issue = x.Issue, + Date = x.Date, + VolumeNo = x.VolumeNo, + Section = x.Section, + Page = x.Page, + No = x.No, + DatePayment = x.DatePayment, + TypePayment = x.TypePayment, + Address = x.Address, + Number = x.Number, + Salary = x.Salary, + DateReceiveInsignia = x.DateReceiveInsignia, + DocReceiveInsignia = x.DocReceiveInsignia, + OrgReceiveInsignia = x.OrgReceiveInsignia, + DateReturnInsignia = x.DateReturnInsignia, + DocReturnInsignia = x.DocReturnInsignia, + OrgReturnInsignia = x.OrgReturnInsignia, + }) + .ToList(); + + var _insigniaNoteProfiles = new List(); + foreach (var insigniaNoteProfile in insigniaNoteProfiles) + { + _insigniaNoteProfiles.Add( + new + { + insigniaNoteProfile.Id, + insigniaNoteProfile.Prefix, + insigniaNoteProfile.Position, + insigniaNoteProfile.CitizenId, + insigniaNoteProfile.ProfileType, + insigniaNoteProfile.FullName, + insigniaNoteProfile.RequestInsignia, + insigniaNoteProfile.RequestInsigniaId, + insigniaNoteProfile.RequestInsigniaShortName, + insigniaNoteProfile.DateReceive, + insigniaNoteProfile.OrganizationOrganizationSend, + insigniaNoteProfile.OrganizationOrganizationReceive, + insigniaNoteProfile.Status, + insigniaNoteProfile.Issue, + insigniaNoteProfile.Date, + insigniaNoteProfile.VolumeNo, + insigniaNoteProfile.Section, + insigniaNoteProfile.Page, + insigniaNoteProfile.No, + insigniaNoteProfile.DatePayment, + insigniaNoteProfile.TypePayment, + insigniaNoteProfile.Address, + insigniaNoteProfile.Number, + insigniaNoteProfile.Salary, + insigniaNoteProfile.DateReceiveInsignia, + DocReceiveInsignia = insigniaNoteProfile.DocReceiveInsignia == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaNoteProfile.DocReceiveInsignia), + insigniaNoteProfile.OrgReceiveInsignia, + insigniaNoteProfile.DateReturnInsignia, + DocReturnInsignia = insigniaNoteProfile.DocReturnInsignia == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaNoteProfile.DocReturnInsignia), + insigniaNoteProfile.OrgReturnInsignia, + } + ); + } + + return Success(_insigniaNoteProfiles); + } /// /// Get รายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ