From fa8dfc51e42f1e4ed8d2b99f412def943d612f7d Mon Sep 17 00:00:00 2001 From: "DESKTOP-2S5P7D1\\Windows 10" Date: Tue, 5 Sep 2023 20:24:15 +0700 Subject: [PATCH] =?UTF-8?q?api=20=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=AB?= =?UTF-8?q?=E0=B8=B2=E0=B8=9C=E0=B8=B9=E0=B9=89=E0=B9=80=E0=B8=81=E0=B8=B5?= =?UTF-8?q?=E0=B9=88=E0=B8=A2=E0=B8=A7=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=87?= =?UTF-8?q?=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/CommandRepository.cs | 32 +++++++++++++++++-- .../Commands/SearchProfileCommandRequest.cs | 11 +++++++ .../Controllers/OrderController.cs | 27 +++++++++++++++- BMA.EHR.Domain/Shared/GlobalMessages.cs | 1 + 4 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 BMA.EHR.Application/Requests/Commands/SearchProfileCommandRequest.cs diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index d0890b6c..eef0eae1 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -1465,7 +1465,7 @@ namespace BMA.EHR.Application.Repositories.Commands await ExecuteCommand12Async(command); break; case "C-PM-17": - await ExecuteCommand17Async(command); + await ExecuteCommand17Async(command); break; case "C-PM-18": await ExecuteCommand18Async(command); @@ -2030,7 +2030,7 @@ namespace BMA.EHR.Application.Repositories.Commands { foreach (var recv in command.Receivers) { - var data = await _dbContext.Set() + var data = await _dbContext.Set() .Include(x => x.Salaries) .ThenInclude(x => x.PositionLevel) .FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId); @@ -3737,6 +3737,34 @@ namespace BMA.EHR.Application.Repositories.Commands #endregion + public async Task GetCommandProfileAsync(Guid commandTypeId, int year, string? posno) + { + try + { + var commandType = await _dbContext.Set() + .FirstOrDefaultAsync(x => x.Id == commandTypeId); + + if (commandType == null) + throw new Exception(GlobalMessages.CommandTypeNotFound); + + var profile = await _dbContext.Set() + .Where(x => x.CitizenId == "0000000000001") + .Select(x => new + { + Id = x.Id, + CitizenId = x.CitizenId, + FullName = $"{x.Prefix.Name}{x.FirstName} {x.LastName}", + PosNo = x.PosNo == null ? null : x.PosNo.Name, + Position = x.Position == null ? null : x.Position.Name, + }) + .ToListAsync(); + return profile; + } + catch + { + throw; + } + } #endregion } diff --git a/BMA.EHR.Application/Requests/Commands/SearchProfileCommandRequest.cs b/BMA.EHR.Application/Requests/Commands/SearchProfileCommandRequest.cs new file mode 100644 index 00000000..1af7fb64 --- /dev/null +++ b/BMA.EHR.Application/Requests/Commands/SearchProfileCommandRequest.cs @@ -0,0 +1,11 @@ +namespace BMA.EHR.Application.Requests.Commands +{ + public class SearchProfileCommandRequest + { + public Guid CommandTypeId { get; set; } + + public int Year { get; set; } + + public string? Posno { get; set; } + } +} diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 90e005f8..75235641 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -233,7 +233,7 @@ namespace BMA.EHR.Command.Service.Controllers } } - + } catch { @@ -3424,6 +3424,31 @@ namespace BMA.EHR.Command.Service.Controllers } } + /// + /// แสดงชื่อผู้เกี่ยวข้องกับคำสั่ง + /// + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("search/profile/command")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetCommandProfileAsync([FromBody] SearchProfileCommandRequest req) + { + try + { + var data = await _repository.GetCommandProfileAsync(req.CommandTypeId, req.Year, req.Posno); + + return Success(data); + } + catch + { + throw; + } + } + #endregion } } diff --git a/BMA.EHR.Domain/Shared/GlobalMessages.cs b/BMA.EHR.Domain/Shared/GlobalMessages.cs index ed9e9a72..2678c379 100644 --- a/BMA.EHR.Domain/Shared/GlobalMessages.cs +++ b/BMA.EHR.Domain/Shared/GlobalMessages.cs @@ -110,6 +110,7 @@ #region " Command " public static readonly string CommandNotFound = "ไม่พบรายการคำสั่งนี้ในระบบ โปรดตรวจความถูกต้อง"; + public static readonly string CommandTypeNotFound = "ไม่พบรายการประเภทคำสั่งนี้ในระบบ โปรดตรวจความถูกต้อง"; public static readonly string MethodForCommandTypeNotImplement = "Method for this command type not implement!";