From 0c9ec3dd433c7b3a919ac805c0b8d326dc2c8c7d Mon Sep 17 00:00:00 2001 From: kittapath <> Date: Fri, 1 Aug 2025 17:08:11 +0700 Subject: [PATCH] lock insignia --- .github/workflows/release_insignia.yaml | 72 +++++++++---------- .../Repositories/UserProfileRepository.cs | 23 ++++++ .../Profiles/GetOrgProfileByProfileIdDto.cs | 11 +++ .../GetOrgProfileByProfileIdResultDto.cs | 11 +++ .../Controllers/InsigniaRequestController.cs | 52 +++++--------- 5 files changed, 99 insertions(+), 70 deletions(-) create mode 100644 BMA.EHR.Application/Responses/Profiles/GetOrgProfileByProfileIdDto.cs create mode 100644 BMA.EHR.Application/Responses/Profiles/GetOrgProfileByProfileIdResultDto.cs diff --git a/.github/workflows/release_insignia.yaml b/.github/workflows/release_insignia.yaml index 124d1e9c..b9197d5b 100644 --- a/.github/workflows/release_insignia.yaml +++ b/.github/workflows/release_insignia.yaml @@ -68,40 +68,40 @@ jobs: docker compose pull docker compose up -d echo "${{ steps.gen_ver.outputs.image_ver }}"> success - - name: Notify Discord Success - if: success() - run: | - curl -H "Content-Type: application/json" \ - -X POST \ - -d '{ - "embeds": [{ - "title": "✅ Deployment Success!", - "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`", - "color": 3066993, - "footer": { - "text": "Release Notification", - "icon_url": "https://example.com/success-icon.png" - }, - "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" - }] - }' \ - ${{ secrets.DISCORD_WEBHOOK }} + # - name: Notify Discord Success + # if: success() + # run: | + # curl -H "Content-Type: application/json" \ + # -X POST \ + # -d '{ + # "embeds": [{ + # "title": "✅ Deployment Success!", + # "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`", + # "color": 3066993, + # "footer": { + # "text": "Release Notification", + # "icon_url": "https://example.com/success-icon.png" + # }, + # "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" + # }] + # }' \ + # ${{ secrets.DISCORD_WEBHOOK }} - - name: Notify Discord Failure - if: failure() - run: | - curl -H "Content-Type: application/json" \ - -X POST \ - -d '{ - "embeds": [{ - "title": "❌ Deployment Failed!", - "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`", - "color": 15158332, - "footer": { - "text": "Release Notification", - "icon_url": "https://example.com/failure-icon.png" - }, - "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" - }] - }' \ - ${{ secrets.DISCORD_WEBHOOK }} + # - name: Notify Discord Failure + # if: failure() + # run: | + # curl -H "Content-Type: application/json" \ + # -X POST \ + # -d '{ + # "embeds": [{ + # "title": "❌ Deployment Failed!", + # "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`", + # "color": 15158332, + # "footer": { + # "text": "Release Notification", + # "icon_url": "https://example.com/failure-icon.png" + # }, + # "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" + # }] + # }' \ + # ${{ secrets.DISCORD_WEBHOOK }} diff --git a/BMA.EHR.Application/Repositories/UserProfileRepository.cs b/BMA.EHR.Application/Repositories/UserProfileRepository.cs index c5f0dfa7..d45660a3 100644 --- a/BMA.EHR.Application/Repositories/UserProfileRepository.cs +++ b/BMA.EHR.Application/Repositories/UserProfileRepository.cs @@ -1188,6 +1188,29 @@ namespace BMA.EHR.Application.Repositories throw; } } + + public GetOrgProfileByProfileIdDto GetOrgProfileByProfileId(Guid id, string? accessToken) + { + try + { + var apiPath = $"{_configuration["API"]}/org/profile/org-user/{id}"; + var apiKey = _configuration["API_KEY"]; + + var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey); + if (apiResult.Result != null) + { + var raw = JsonConvert.DeserializeObject(apiResult.Result); + if (raw != null) + return raw.Result; + } + + return null; + } + catch + { + throw; + } + } #endregion } } diff --git a/BMA.EHR.Application/Responses/Profiles/GetOrgProfileByProfileIdDto.cs b/BMA.EHR.Application/Responses/Profiles/GetOrgProfileByProfileIdDto.cs new file mode 100644 index 00000000..da2ccf1a --- /dev/null +++ b/BMA.EHR.Application/Responses/Profiles/GetOrgProfileByProfileIdDto.cs @@ -0,0 +1,11 @@ +namespace BMA.EHR.Application.Responses.Profiles +{ + public class GetOrgProfileByProfileIdDto + { + 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; } + } +} diff --git a/BMA.EHR.Application/Responses/Profiles/GetOrgProfileByProfileIdResultDto.cs b/BMA.EHR.Application/Responses/Profiles/GetOrgProfileByProfileIdResultDto.cs new file mode 100644 index 00000000..ce08c298 --- /dev/null +++ b/BMA.EHR.Application/Responses/Profiles/GetOrgProfileByProfileIdResultDto.cs @@ -0,0 +1,11 @@ +namespace BMA.EHR.Application.Responses.Profiles +{ + public class GetOrgProfileByProfileIdResultDto + { + public string Message { get; set; } = string.Empty; + + public int Status { get; set; } = -1; + + public GetOrgProfileByProfileIdDto? Result { get; set; } + } +} diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index fc4b68a8..27c77f5c 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -336,14 +336,8 @@ namespace BMA.EHR.Insignia.Service.Controllers //} if (role.Trim().ToLower() == "officer") { - /* resend.Items = (await _repository.InsigniaHasProfile(result.PeriodId, ocId, status, type)) - .Where(x => x.ProfileType!.ToLower() == type.ToLower()).ToList();*/ - var items = await _repository.InsigniaHasProfile(result.PeriodId, ocId, status, type); - - resend.Items = (items ?? new List()) - .Where(x => x != null && !string.IsNullOrEmpty(x.ProfileType) && x.ProfileType.ToLower() == type.ToLower()) - .ToList(); - + resend.Items = (await _repository.InsigniaHasProfile(result.PeriodId, ocId, status, type)) + .Where(x => x.ProfileType!.ToLower() == type.ToLower()).ToList(); return Success(resend); } else @@ -1318,9 +1312,7 @@ namespace BMA.EHR.Insignia.Service.Controllers if (profileOld.ProfileId == null) continue; - var pf = _userProfileRepository.GetOfficerProfileById(profileOld.ProfileId, AccessToken); - if (pf == null) - pf = _userProfileRepository.GetEmployeeProfileById(profileOld.ProfileId, AccessToken); + var pf = _userProfileRepository.GetOrgProfileByProfileId(profileOld.ProfileId, AccessToken); var orgSend = ""; var orgRecv = ""; @@ -1340,27 +1332,19 @@ namespace BMA.EHR.Insignia.Service.Controllers if (pf != null) { - var kk = pf.Keycloak == null ? Guid.Empty : pf.Keycloak.Value; - var pfData = await _userProfileRepository.GetProfileByKeycloakIdAsync(kk, AccessToken); - if (pfData != null) - { - if (pfData.Child4 != null || pfData.Child4 != "") - orgRecv += $"{pfData.Child4}"; - if (pfData.Child3 != null || pfData.Child3 != "") - orgRecv += $" {pfData.Child3}"; - if (pfData.Child2 != null || pfData.Child2 != "") - orgRecv += $" {pfData.Child2}"; - if (pfData.Child1 != null || pfData.Child1 != "") - orgRecv += $" {pfData.Child1}"; - if (pfData.Root != null || pfData.Root != "") - orgRecv += $" {pfData.Root}"; - - - orgRecv = orgRecv.Trim(); - } + if (pf.Child4 != null || pf.Child4 != "") + orgRecv += $"{pf.Child4}"; + if (pf.Child3 != null || pf.Child3 != "") + orgRecv += $" {pf.Child3}"; + if (pf.Child2 != null || pf.Child2 != "") + orgRecv += $" {pf.Child2}"; + if (pf.Child1 != null || pf.Child1 != "") + orgRecv += $" {pf.Child1}"; + if (pf.Root != null || pf.Root != "") + orgRecv += $" {pf.Root}"; + orgRecv = orgRecv.Trim(); } - await _context.InsigniaNoteProfiles.AddAsync(new InsigniaNoteProfile { RequestDate = profileOld.RequestDate, @@ -2484,11 +2468,11 @@ namespace BMA.EHR.Insignia.Service.Controllers receiveDate = profile.DateReceive!.Value, dateAnnounce = profile.Date!.Value, insigniaId = profile.RequestInsignia!.Id, - issue = profile!.Issue ?? "", + issue = "", note = "", refCommandDate = null, refCommandNo = "", - volume = profile!.VolumeNo ?? "", + volume = "", }; await _userProfileRepository.PostProfileInsigniaAsync(profileInsigniaBody, AccessToken); @@ -2506,11 +2490,11 @@ namespace BMA.EHR.Insignia.Service.Controllers receiveDate = profile.DateReceive!.Value, dateAnnounce = profile.Date!.Value, insigniaId = profile.RequestInsignia!.Id, - issue = profile!.Issue ?? "", + issue = "", note = "", refCommandDate = null, refCommandNo = "", - volume = profile!.VolumeNo ?? "", + volume = "", }; await _userProfileRepository.PostProfileEmpInsigniaAsync(profileInsigniaBody, AccessToken);