From cc902536d65dc5fe039a86c304e7f38763ba7755 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Fri, 18 Aug 2023 10:53:44 +0700 Subject: [PATCH 1/2] fix bug and add approver position --- .../Commands/CommandRepository.cs | 32 ++++++++++++++----- .../Responses/OrganizationApproverResponse.cs | 11 +++++++ BMA.EHR.Command.Service/appsettings.json | 2 +- BMA.EHR.Command.Service/wwwroot/keycloak.json | 2 +- 4 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 BMA.EHR.Application/Responses/OrganizationApproverResponse.cs diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index eff28826..eee37b45 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -1220,7 +1220,7 @@ namespace BMA.EHR.Application.Repositories.Commands if (data == null) throw new Exception(GlobalMessages.OrganizationNotFound); - return data.OrganizationAgencyId!.Value; + return data.OrganizationAgencyId == null ? ocId : data.OrganizationAgencyId!.Value; } catch { @@ -1260,12 +1260,12 @@ namespace BMA.EHR.Application.Repositories.Commands } } - public async Task> GetOrgApproverAsync(Guid ocId) + public async Task> GetOrgApproverAsync(Guid ocId) { try { if (ocId == Guid.Empty) - return new List() { new KeyValueItemResponse { Id = Guid.Empty, Name = "ปลัดกรุงเทพมหานคร" } }; + return new List() { new OrganizationApproverResponse { Id = Guid.Empty, Name = "", PositionName = "ปลัดกรุงเทพมหานคร" } }; else { //var ret = new List(); @@ -1278,12 +1278,20 @@ namespace BMA.EHR.Application.Repositories.Commands .ThenInclude(x => x!.Organization) .Include(x => x.OrganizationPosition) .ThenInclude(x => x!.PositionMaster) + .ThenInclude(x => x!.PositionPath) + .Include(x => x.OrganizationPosition) + .ThenInclude(x => x!.PositionMaster) + .ThenInclude(x => x!.PositionExecutive) .Where(x => x.OrganizationPosition!.Organization!.Id == ocId && x.OrganizationPosition!.PositionMaster!.IsDirector == true) - .Select(x => new KeyValueItemResponse + .Select(x => new OrganizationApproverResponse { Id = x.Profile!.Id, - Name = $"{x.Profile!.Prefix!.Name}{x.Profile!.FirstName} {x.Profile!.LastName}" + Name = $"{x.Profile!.Prefix!.Name}{x.Profile!.FirstName} {x.Profile!.LastName}", + PositionName = x.OrganizationPosition!.PositionMaster!.PositionExecutive != null ? + x.OrganizationPosition!.PositionMaster!.PositionExecutive!.Name + : + x.OrganizationPosition!.PositionMaster!.PositionPath == null ? "" : x.OrganizationPosition!.PositionMaster!.PositionPath!.Name }) .ToListAsync(); @@ -1302,19 +1310,27 @@ namespace BMA.EHR.Application.Repositories.Commands .ThenInclude(x => x!.Organization) .Include(x => x.OrganizationPosition) .ThenInclude(x => x!.PositionMaster) + .ThenInclude(x => x!.PositionPath) + .Include(x => x.OrganizationPosition) + .ThenInclude(x => x!.PositionMaster) + .ThenInclude(x => x!.PositionExecutive) .Where(x => x.OrganizationPosition!.Organization!.Id == oc.Parent.Id && x.OrganizationPosition!.PositionMaster!.IsDirector == true) - .Select(x => new KeyValueItemResponse + .Select(x => new OrganizationApproverResponse { Id = x.Profile!.Id, - Name = $"{x.Profile!.Prefix!.Name}{x.Profile!.FirstName} {x.Profile!.LastName}" + Name = $"{x.Profile!.Prefix!.Name}{x.Profile!.FirstName} {x.Profile!.LastName}", + PositionName = x.OrganizationPosition!.PositionMaster!.PositionExecutive != null ? + x.OrganizationPosition!.PositionMaster!.PositionExecutive!.Name + : + x.OrganizationPosition!.PositionMaster!.PositionPath == null ? "" : x.OrganizationPosition!.PositionMaster!.PositionPath!.Name }) .ToListAsync(); return parentProfilePosition; } else - return new List(); + return new List(); } } } diff --git a/BMA.EHR.Application/Responses/OrganizationApproverResponse.cs b/BMA.EHR.Application/Responses/OrganizationApproverResponse.cs new file mode 100644 index 00000000..e963c570 --- /dev/null +++ b/BMA.EHR.Application/Responses/OrganizationApproverResponse.cs @@ -0,0 +1,11 @@ +namespace BMA.EHR.Application.Responses +{ + public class OrganizationApproverResponse + { + public Guid Id { get; set; } = Guid.Empty; + + public string Name { get; set; } = string.Empty; + + public string PositionName { get; set; } = string.Empty; + } +} diff --git a/BMA.EHR.Command.Service/appsettings.json b/BMA.EHR.Command.Service/appsettings.json index c8cd1ab9..ddc81996 100644 --- a/BMA.EHR.Command.Service/appsettings.json +++ b/BMA.EHR.Command.Service/appsettings.json @@ -18,7 +18,7 @@ }, "Jwt": { "Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI", - "Issuer": "https://identity.frappet.com/realms/bma-ehr" + "Issuer": "https://id.frappet.synology.me/realms/bma-ehr" }, "EPPlus": { "ExcelPackage": { diff --git a/BMA.EHR.Command.Service/wwwroot/keycloak.json b/BMA.EHR.Command.Service/wwwroot/keycloak.json index 9eba3b39..a023eb38 100644 --- a/BMA.EHR.Command.Service/wwwroot/keycloak.json +++ b/BMA.EHR.Command.Service/wwwroot/keycloak.json @@ -1,6 +1,6 @@ { "realm": "bma-ehr", - "auth-server-url": "https://identity.frappet.com", + "auth-server-url": "https://id.frappet.synology.me", "ssl-required": "external", "resource": "bma-ehr", "public-client": true From 8ee7dc94a2567c6ca6ceb806bfe5880df7dd84d8 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Fri, 18 Aug 2023 14:23:11 +0700 Subject: [PATCH 2/2] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=9A?= =?UTF-8?q?=E0=B8=B1=E0=B8=99=E0=B8=97=E0=B8=B6=E0=B8=81=E0=B9=81=E0=B8=A5?= =?UTF-8?q?=E0=B8=B0=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82=E0=B9=80?= =?UTF-8?q?=E0=B8=A5=E0=B8=82=E0=B8=97=E0=B8=B5=E0=B9=88=E0=B8=84=E0=B8=B3?= =?UTF-8?q?=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87=20=E0=B8=88=E0=B8=B2?= =?UTF-8?q?=E0=B8=81=20int=20to=20str?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BMA.EHR.Application/Repositories/GenericRepository.cs | 6 +----- BMA.EHR.Command.Service/Controllers/OrderController.cs | 4 ++-- BMA.EHR.Command.Service/Requests/CreateCommandRequest.cs | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/BMA.EHR.Application/Repositories/GenericRepository.cs b/BMA.EHR.Application/Repositories/GenericRepository.cs index 2f2a6e58..29354dc1 100644 --- a/BMA.EHR.Application/Repositories/GenericRepository.cs +++ b/BMA.EHR.Application/Repositories/GenericRepository.cs @@ -14,7 +14,6 @@ namespace BMA.EHR.Application.Repositories private readonly DbSet _dbSet; private readonly IHttpContextAccessor _httpContextAccessor; - #endregion #region " Constructor and Destructor " @@ -36,9 +35,7 @@ namespace BMA.EHR.Application.Repositories protected string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value; - protected bool? IsPlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1"); - - + protected bool? IsPlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1"); #endregion @@ -63,7 +60,6 @@ namespace BMA.EHR.Application.Repositories (entity as EntityBase).CreatedAt = DateTime.Now; } - await _dbSet.AddAsync(entity); await _dbContext.SaveChangesAsync(); diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index b3b1be0d..365ade86 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -381,7 +381,7 @@ namespace BMA.EHR.Command.Service.Controllers { var inserted = new Domain.Models.Commands.Core.Command { - CommandNo = req.orderNo.ToString(), + CommandNo = req.orderNo, CommandYear = req.orderYear.ToString(), CommandSubject = req.orderTitle, PositionName = req.registerPosition, @@ -433,7 +433,7 @@ namespace BMA.EHR.Command.Service.Controllers var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue); var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId); - order.CommandNo = req.orderNo.ToString(); + order.CommandNo = req.orderNo; order.CommandYear = req.orderYear.ToString(); order.CommandSubject = req.orderTitle; order.PositionName = req.registerPosition; diff --git a/BMA.EHR.Command.Service/Requests/CreateCommandRequest.cs b/BMA.EHR.Command.Service/Requests/CreateCommandRequest.cs index c14accfd..15db35af 100644 --- a/BMA.EHR.Command.Service/Requests/CreateCommandRequest.cs +++ b/BMA.EHR.Command.Service/Requests/CreateCommandRequest.cs @@ -4,9 +4,9 @@ { public Guid orderTypeValue { get; set; } - public string orderTitle { get; set; } + public string orderTitle { get; set; } = string.Empty; - public int orderNo { get; set; } + public string orderNo { get; set; } = string.Empty; public int orderYear { get; set; }