From e59f242427b7e918260b958f3eb528f6f530d1b9 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 13 Sep 2024 18:09:56 +0700 Subject: [PATCH 01/19] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20paging=20=E0=B8=A3=E0=B8=B0=E0=B8=9A=E0=B8=9A?= =?UTF-8?q?=E0=B8=9A=E0=B8=A3=E0=B8=A3=E0=B8=88=E0=B8=B8=20=E0=B9=81?= =?UTF-8?q?=E0=B8=95=E0=B9=88=E0=B8=87=E0=B8=95=E0=B8=B1=E0=B9=89=E0=B8=87?= =?UTF-8?q?=20=E0=B8=A2=E0=B9=89=E0=B8=B2=E0=B8=A2=20=E0=B9=82=E0=B8=AD?= =?UTF-8?q?=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlacementAppointmentController.cs | 27 +++++++++++++++++-- .../PlacementAppointmentEmployeeController.cs | 26 ++++++++++++++++-- .../Controllers/PlacementController.cs | 19 +++++++++++-- .../Controllers/PlacementOfficerController.cs | 24 +++++++++++++++-- .../Controllers/PlacementReceiveController.cs | 3 ++- .../PlacementRepatriationController.cs | 25 +++++++++++++++-- .../PlacementTransferController.cs | 20 ++++++++++++-- .../Controllers/RetirementOtherController.cs | 23 ++++++++++++++-- 8 files changed, 152 insertions(+), 15 deletions(-) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index 08022767..8c3336f1 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -69,7 +69,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet()] - public async Task> GetListByAdmin() + public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") { var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_PROMOTION_OFFICER"); var jsonData = JsonConvert.DeserializeObject(getPermission); @@ -164,7 +164,30 @@ namespace BMA.EHR.Placement.Service.Controllers // if (PlacementAdmin == true) // placementAppointments.Where(x => x.Status.Trim().ToUpper().Contains("PENDING")); - return Success(placementAppointments); + if (keyword != "") + { + var data = placementAppointments.Where(x => + (x.citizenId != null && x.citizenId.Contains(keyword)) || + (x.prefix != null && x.prefix.Contains(keyword)) || + (x.firstName != null && x.firstName.Contains(keyword)) || + (x.lastName != null && x.lastName.Contains(keyword)) || + (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || + (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || + (x.OrganizationOld != null && x.OrganizationOld.Contains(keyword)) || + (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || + (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || + (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || + (x.Reason != null && x.Reason.Contains(keyword)) || + (x.nodeName != null && x.nodeName.Contains(keyword))) + .OrderByDescending(x => x.CreatedAt) + .Skip((page - 1) * pageSize) + .Take(pageSize) + .ToList(); + + placementAppointments = data; + } + + return Success(new { data = placementAppointments, total = placementAppointments.Count }); } /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs index 351a5995..c19c1f58 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs @@ -69,7 +69,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet()] - public async Task> GetListByAdmin() + public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") { var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_PROMOTION_EMP"); var jsonData = JsonConvert.DeserializeObject(getPermission); @@ -161,8 +161,30 @@ namespace BMA.EHR.Placement.Service.Controllers p.typeCommand, }) .ToListAsync(); + if (keyword != "") + { + var data = placementAppointments.Where(x => + (x.citizenId != null && x.citizenId.Contains(keyword)) || + (x.prefix != null && x.prefix.Contains(keyword)) || + (x.firstName != null && x.firstName.Contains(keyword)) || + (x.lastName != null && x.lastName.Contains(keyword)) || + (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || + (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || + (x.OrganizationOld != null && x.OrganizationOld.Contains(keyword)) || + (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || + (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || + (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || + (x.Reason != null && x.Reason.Contains(keyword)) || + (x.nodeName != null && x.nodeName.Contains(keyword))) + .OrderByDescending(x => x.CreatedAt) + .Skip((page - 1) * pageSize) + .Take(pageSize) + .ToList(); - return Success(placementAppointments); + placementAppointments = data; + } + + return Success(new { data = placementAppointments, total = placementAppointments.Count }); } /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index c70632b5..1b72205a 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -17,6 +17,8 @@ using Microsoft.Extensions.Configuration; using System.Net.Http.Headers; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Microsoft.AspNetCore.Http.HttpResults; +using System.Drawing.Drawing2D; namespace BMA.EHR.Placement.Service.Controllers { @@ -90,7 +92,7 @@ namespace BMA.EHR.Placement.Service.Controllers } [HttpGet("exam/{year}")] - public async Task> GetExam(int year) + public async Task> GetExam(int year, int page = 1, int pageSize = 10, string keyword = "") { var data = await _context.Placements.Where(x => year > 0 ? (x.Year == year) : (x.Year > 0)) .OrderByDescending(x => x.CreatedAt) @@ -107,9 +109,22 @@ namespace BMA.EHR.Placement.Service.Controllers AccountEndDate = x.EndDate, AccountExpirationDate = x.EndDate, IsExpired = x.EndDate.Date < DateTime.Now.Date, + CreatedAt = x.CreatedAt, }).ToListAsync(); + if (keyword != "") + { + var data_ = data.Where(x => + (x.ExamRound != null && x.ExamRound.Contains(keyword)) || + (x.ExamOrder != null && x.ExamOrder.Contains(keyword)) || + (x.NumberOfCandidates != null && x.NumberOfCandidates.ToString().Contains(keyword))) + .OrderByDescending(x => x.CreatedAt) + .Skip((page - 1) * pageSize) + .Take(pageSize) + .ToList(); - return Success(data); + data = data_; + } + return Success( new { data, total = data.Count }); } [HttpGet("pass/{examId:length(36)}")] diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs index 24f0b17e..70c12ae9 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs @@ -69,7 +69,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet()] - public async Task> GetListByAdmin() + public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") { var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_TEMPDUTY"); var jsonData = JsonConvert.DeserializeObject(getPermission); @@ -142,7 +142,27 @@ namespace BMA.EHR.Placement.Service.Controllers }) .ToListAsync(); - return Success(placementOfficers); + if (keyword != "") + { + var data = placementOfficers.Where(x => + (x.prefix != null && x.prefix.Contains(keyword)) || + (x.firstName != null && x.firstName.Contains(keyword)) || + (x.lastName != null && x.lastName.Contains(keyword)) || + (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || + (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || + (x.PositionOld != null && x.PositionOld.Contains(keyword)) || + (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || + (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || + (x.Organization != null && x.Organization.Contains(keyword))) + .OrderByDescending(x => x.CreatedAt) + .Skip((page - 1) * pageSize) + .Take(pageSize) + .ToList(); + + placementOfficers = data; + } + + return Success(new { data = placementOfficers, total = placementOfficers.Count }); } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index a366d428..29056249 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -180,6 +180,7 @@ namespace BMA.EHR.Placement.Service.Controllers .ToListAsync(); // if (PlacementAdmin == true) // placementReceives.Where(x => x.Status.Trim().ToUpper().Contains("PENDING")); + if (keyword != "") { var data = placementReceives.Where(x => @@ -197,7 +198,7 @@ namespace BMA.EHR.Placement.Service.Controllers placementReceives = data; } - return Success(placementReceives); + return Success(new { data = placementReceives, total = placementReceives.Count }); // } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs index c8ae57ee..0336cd3f 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs @@ -70,7 +70,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet()] - public async Task> GetListByAdmin() + public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") { var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_TEMPDUTY2"); var jsonData = JsonConvert.DeserializeObject(getPermission); @@ -148,7 +148,28 @@ namespace BMA.EHR.Placement.Service.Controllers }) .ToListAsync(); - return Success(placementRepatriations); + if (keyword != "") + { + var data = placementRepatriations.Where(x => + (x.prefix != null && x.prefix.Contains(keyword)) || + (x.firstName != null && x.firstName.Contains(keyword)) || + (x.lastName != null && x.lastName.Contains(keyword)) || + (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || + (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || + (x.PositionOld != null && x.PositionOld.Contains(keyword)) || + (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || + (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || + (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || + (x.Organization != null && x.Organization.Contains(keyword))) + .OrderByDescending(x => x.CreatedAt) + .Skip((page - 1) * pageSize) + .Take(pageSize) + .ToList(); + + placementRepatriations = data; + } + + return Success(new { data = placementRepatriations, total = placementRepatriations.Count }); } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index 38b9c196..b847e237 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -142,7 +142,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet()] - public async Task> GetListByAdmin() + public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") { var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_TRANSFER_REQ"); var jsonData = JsonConvert.DeserializeObject(getPermission); @@ -219,7 +219,23 @@ namespace BMA.EHR.Placement.Service.Controllers }) .ToListAsync(); - return Success(placementTransfers); + if (keyword != "") + { + var data = placementTransfers.Where(x => + (x.prefix != null && x.prefix.Contains(keyword)) || + (x.firstName != null && x.firstName.Contains(keyword)) || + (x.lastName != null && x.lastName.Contains(keyword)) || + (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || + (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword))) + .OrderByDescending(x => x.CreatedAt) + .Skip((page - 1) * pageSize) + .Take(pageSize) + .ToList(); + + placementTransfers = data; + } + + return Success(new { data = placementTransfers, total = placementTransfers.Count }); } } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index 3138d35e..e102e0a4 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -69,7 +69,7 @@ namespace BMA.EHR.Retirement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet()] - public async Task> GetListByAdmin() + public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") { var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_PLACEMENT_OTHER"); var jsonData = JsonConvert.DeserializeObject(getPermission); @@ -146,8 +146,27 @@ namespace BMA.EHR.Retirement.Service.Controllers CommandType = p.CommandType == null ? null : p.CommandType.Name, }) .ToListAsync(); + if (keyword != "") + { + var data = retirementOthers.Where(x => + (x.prefix != null && x.prefix.Contains(keyword)) || + (x.firstName != null && x.firstName.Contains(keyword)) || + (x.lastName != null && x.lastName.Contains(keyword)) || + (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || + (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || + (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || + (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || + (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || + (x.Reason != null && x.Reason.Contains(keyword))) + .OrderByDescending(x => x.CreatedAt) + .Skip((page - 1) * pageSize) + .Take(pageSize) + .ToList(); - return Success(retirementOthers); + retirementOthers = data; + } + + return Success(new { data = retirementOthers, total = retirementOthers.Count }); } } From e8cf09b7ac2e47bb91470aeb15d4f80b98c1ed16 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 17 Sep 2024 13:49:48 +0700 Subject: [PATCH 02/19] =?UTF-8?q?fix=20=E0=B8=AA=E0=B8=B4=E0=B8=97?= =?UTF-8?q?=E0=B8=98=E0=B8=B4=E0=B9=8C=20api=20list=20=E0=B8=84=E0=B8=B3?= =?UTF-8?q?=E0=B8=96=E0=B8=B2=E0=B8=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/RetirementResignController.cs | 72 +++++++++++++++++-- 1 file changed, 65 insertions(+), 7 deletions(-) diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index 774a529f..5013adeb 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -1453,7 +1453,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda } /// - /// list คำถาม + /// list คำถาม (USER) /// /// /// @@ -1463,12 +1463,12 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda [HttpGet("questionnaire/question")] public async Task> GetQuestionnaireQuestion() { - var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_RESIGN_INTERVIEW"); - var jsonData = JsonConvert.DeserializeObject(getPermission); - if (jsonData["status"]?.ToString() != "200") - { - return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); - } + //var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_RESIGN_INTERVIEW"); + //var jsonData = JsonConvert.DeserializeObject(getPermission); + //if (jsonData["status"]?.ToString() != "200") + //{ + // return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + //} var retirementQuestionnaireQuestion = await _context.RetirementQuestionnaireQuestions.AsQueryable() .Select(x => new { @@ -1570,5 +1570,63 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda return Success(); } + + /// + /// list คำถาม (ADMIN) + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("questionnaire/question/admin")] + public async Task> GetQuestionnaireQuestionAdmin() + { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_RESIGN_INTERVIEW"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + var retirementQuestionnaireQuestion = await _context.RetirementQuestionnaireQuestions.AsQueryable() + .Select(x => new + { + Question1Desc = x.Question1Desc, + Question1Score = x.Question1Score, + Question1Answer = x.Question1Answer == null ? null : JsonConvert.DeserializeObject>(x.Question1Answer), + Question2Desc = x.Question2Desc, + Question2Score = x.Question2Score, + Question2Answer = x.Question2Answer == null ? null : JsonConvert.DeserializeObject>(x.Question2Answer), + Question3Desc = x.Question3Desc, + Question3Score = x.Question3Score, + Question3Answer = x.Question3Answer == null ? null : JsonConvert.DeserializeObject>(x.Question3Answer), + Question4Desc = x.Question4Desc, + Question4Score = x.Question4Score, + Question4Answer = x.Question4Answer == null ? null : JsonConvert.DeserializeObject>(x.Question4Answer), + Question5Desc = x.Question5Desc, + Question5Score = x.Question5Score, + Question5Answer = x.Question5Answer == null ? null : JsonConvert.DeserializeObject>(x.Question5Answer), + Question6Desc = x.Question6Desc, + Question6Score = x.Question6Score, + Question6Answer = x.Question6Answer == null ? null : JsonConvert.DeserializeObject>(x.Question6Answer), + Question7Desc = x.Question7Desc, + Question7Score = x.Question7Score, + Question7Answer = x.Question7Answer == null ? null : JsonConvert.DeserializeObject>(x.Question7Answer), + Question8Desc = x.Question8Desc, + Question8Score = x.Question8Score, + Question8Answer = x.Question8Answer == null ? null : JsonConvert.DeserializeObject>(x.Question8Answer), + Question9Desc = x.Question9Desc, + Question9Score = x.Question9Score, + Question9Answer = x.Question9Answer == null ? null : JsonConvert.DeserializeObject>(x.Question9Answer), + Question10Desc = x.Question10Desc, + Question10Score = x.Question10Score, + Question10Answer = x.Question10Answer == null ? null : JsonConvert.DeserializeObject>(x.Question10Answer), + }) + .FirstOrDefaultAsync(); + if (retirementQuestionnaireQuestion == null) + return Error(GlobalMessages.RetirementQuestionNotFound); + + return Success(retirementQuestionnaireQuestion); + } } } From 99a3cfd0529796fb5db34273ab02764f4a4f98d0 Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 17 Sep 2024 15:48:12 +0700 Subject: [PATCH 03/19] =?UTF-8?q?=E0=B9=80=E0=B8=AD=E0=B8=B2=20paging=20?= =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlacementAppointmentController.cs | 47 ++++++++++--------- .../PlacementAppointmentEmployeeController.cs | 47 ++++++++++--------- .../Controllers/PlacementController.cs | 29 ++++++------ .../Controllers/PlacementOfficerController.cs | 41 ++++++++-------- .../Controllers/PlacementReceiveController.cs | 37 ++++++++------- .../PlacementRepatriationController.cs | 43 ++++++++--------- .../PlacementTransferController.cs | 33 ++++++------- .../Controllers/RetirementOtherController.cs | 41 ++++++++-------- 8 files changed, 163 insertions(+), 155 deletions(-) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index 8c3336f1..20d533d4 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -69,7 +69,8 @@ namespace BMA.EHR.Placement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet()] - public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") + // public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") + public async Task> GetListByAdmin() { var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_PROMOTION_OFFICER"); var jsonData = JsonConvert.DeserializeObject(getPermission); @@ -164,30 +165,30 @@ namespace BMA.EHR.Placement.Service.Controllers // if (PlacementAdmin == true) // placementAppointments.Where(x => x.Status.Trim().ToUpper().Contains("PENDING")); - if (keyword != "") - { - var data = placementAppointments.Where(x => - (x.citizenId != null && x.citizenId.Contains(keyword)) || - (x.prefix != null && x.prefix.Contains(keyword)) || - (x.firstName != null && x.firstName.Contains(keyword)) || - (x.lastName != null && x.lastName.Contains(keyword)) || - (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || - (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || - (x.OrganizationOld != null && x.OrganizationOld.Contains(keyword)) || - (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || - (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || - (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || - (x.Reason != null && x.Reason.Contains(keyword)) || - (x.nodeName != null && x.nodeName.Contains(keyword))) - .OrderByDescending(x => x.CreatedAt) - .Skip((page - 1) * pageSize) - .Take(pageSize) - .ToList(); + // if (keyword != "") + // { + // var data = placementAppointments.Where(x => + // (x.citizenId != null && x.citizenId.Contains(keyword)) || + // (x.prefix != null && x.prefix.Contains(keyword)) || + // (x.firstName != null && x.firstName.Contains(keyword)) || + // (x.lastName != null && x.lastName.Contains(keyword)) || + // (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || + // (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || + // (x.OrganizationOld != null && x.OrganizationOld.Contains(keyword)) || + // (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || + // (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || + // (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || + // (x.Reason != null && x.Reason.Contains(keyword)) || + // (x.nodeName != null && x.nodeName.Contains(keyword))) + // .OrderByDescending(x => x.CreatedAt) + // .Skip((page - 1) * pageSize) + // .Take(pageSize) + // .ToList(); - placementAppointments = data; - } + // placementAppointments = data; + // } - return Success(new { data = placementAppointments, total = placementAppointments.Count }); + return Success(placementAppointments); } /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs index c19c1f58..6a0ea4c7 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs @@ -69,7 +69,8 @@ namespace BMA.EHR.Placement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet()] - public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") + public async Task> GetListByAdmin() + // public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") { var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_PROMOTION_EMP"); var jsonData = JsonConvert.DeserializeObject(getPermission); @@ -161,30 +162,30 @@ namespace BMA.EHR.Placement.Service.Controllers p.typeCommand, }) .ToListAsync(); - if (keyword != "") - { - var data = placementAppointments.Where(x => - (x.citizenId != null && x.citizenId.Contains(keyword)) || - (x.prefix != null && x.prefix.Contains(keyword)) || - (x.firstName != null && x.firstName.Contains(keyword)) || - (x.lastName != null && x.lastName.Contains(keyword)) || - (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || - (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || - (x.OrganizationOld != null && x.OrganizationOld.Contains(keyword)) || - (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || - (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || - (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || - (x.Reason != null && x.Reason.Contains(keyword)) || - (x.nodeName != null && x.nodeName.Contains(keyword))) - .OrderByDescending(x => x.CreatedAt) - .Skip((page - 1) * pageSize) - .Take(pageSize) - .ToList(); + // if (keyword != "") + // { + // var data = placementAppointments.Where(x => + // (x.citizenId != null && x.citizenId.Contains(keyword)) || + // (x.prefix != null && x.prefix.Contains(keyword)) || + // (x.firstName != null && x.firstName.Contains(keyword)) || + // (x.lastName != null && x.lastName.Contains(keyword)) || + // (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || + // (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || + // (x.OrganizationOld != null && x.OrganizationOld.Contains(keyword)) || + // (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || + // (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || + // (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || + // (x.Reason != null && x.Reason.Contains(keyword)) || + // (x.nodeName != null && x.nodeName.Contains(keyword))) + // .OrderByDescending(x => x.CreatedAt) + // .Skip((page - 1) * pageSize) + // .Take(pageSize) + // .ToList(); - placementAppointments = data; - } + // placementAppointments = data; + // } - return Success(new { data = placementAppointments, total = placementAppointments.Count }); + return Success(placementAppointments); } /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 1b72205a..5bf3d7f4 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -92,7 +92,8 @@ namespace BMA.EHR.Placement.Service.Controllers } [HttpGet("exam/{year}")] - public async Task> GetExam(int year, int page = 1, int pageSize = 10, string keyword = "") + public async Task> GetExam(int year) + // public async Task> GetExam(int year, int page = 1, int pageSize = 10, string keyword = "") { var data = await _context.Placements.Where(x => year > 0 ? (x.Year == year) : (x.Year > 0)) .OrderByDescending(x => x.CreatedAt) @@ -111,20 +112,20 @@ namespace BMA.EHR.Placement.Service.Controllers IsExpired = x.EndDate.Date < DateTime.Now.Date, CreatedAt = x.CreatedAt, }).ToListAsync(); - if (keyword != "") - { - var data_ = data.Where(x => - (x.ExamRound != null && x.ExamRound.Contains(keyword)) || - (x.ExamOrder != null && x.ExamOrder.Contains(keyword)) || - (x.NumberOfCandidates != null && x.NumberOfCandidates.ToString().Contains(keyword))) - .OrderByDescending(x => x.CreatedAt) - .Skip((page - 1) * pageSize) - .Take(pageSize) - .ToList(); + // if (keyword != "") + // { + // var data_ = data.Where(x => + // (x.ExamRound != null && x.ExamRound.Contains(keyword)) || + // (x.ExamOrder != null && x.ExamOrder.Contains(keyword)) || + // (x.NumberOfCandidates != null && x.NumberOfCandidates.ToString().Contains(keyword))) + // .OrderByDescending(x => x.CreatedAt) + // .Skip((page - 1) * pageSize) + // .Take(pageSize) + // .ToList(); - data = data_; - } - return Success( new { data, total = data.Count }); + // data = data_; + // } + return Success(data); } [HttpGet("pass/{examId:length(36)}")] diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs index 70c12ae9..8ad0b7fa 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs @@ -69,7 +69,8 @@ namespace BMA.EHR.Placement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet()] - public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") + public async Task> GetListByAdmin() + // public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") { var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_TEMPDUTY"); var jsonData = JsonConvert.DeserializeObject(getPermission); @@ -142,27 +143,27 @@ namespace BMA.EHR.Placement.Service.Controllers }) .ToListAsync(); - if (keyword != "") - { - var data = placementOfficers.Where(x => - (x.prefix != null && x.prefix.Contains(keyword)) || - (x.firstName != null && x.firstName.Contains(keyword)) || - (x.lastName != null && x.lastName.Contains(keyword)) || - (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || - (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || - (x.PositionOld != null && x.PositionOld.Contains(keyword)) || - (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || - (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || - (x.Organization != null && x.Organization.Contains(keyword))) - .OrderByDescending(x => x.CreatedAt) - .Skip((page - 1) * pageSize) - .Take(pageSize) - .ToList(); + // if (keyword != "") + // { + // var data = placementOfficers.Where(x => + // (x.prefix != null && x.prefix.Contains(keyword)) || + // (x.firstName != null && x.firstName.Contains(keyword)) || + // (x.lastName != null && x.lastName.Contains(keyword)) || + // (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || + // (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || + // (x.PositionOld != null && x.PositionOld.Contains(keyword)) || + // (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || + // (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || + // (x.Organization != null && x.Organization.Contains(keyword))) + // .OrderByDescending(x => x.CreatedAt) + // .Skip((page - 1) * pageSize) + // .Take(pageSize) + // .ToList(); - placementOfficers = data; - } + // placementOfficers = data; + // } - return Success(new { data = placementOfficers, total = placementOfficers.Count }); + return Success(placementOfficers); } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index 29056249..7bf549b9 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -69,7 +69,8 @@ namespace BMA.EHR.Placement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet()] - public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") + public async Task> GetListByAdmin() + // public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") { var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_TRANSFER_RECEIVE"); var jsonData = JsonConvert.DeserializeObject(getPermission); @@ -181,24 +182,24 @@ namespace BMA.EHR.Placement.Service.Controllers // if (PlacementAdmin == true) // placementReceives.Where(x => x.Status.Trim().ToUpper().Contains("PENDING")); - if (keyword != "") - { - var data = placementReceives.Where(x => - (x.prefix != null && x.prefix.Contains(keyword)) || - (x.firstName != null && x.firstName.Contains(keyword)) || - (x.lastName != null && x.lastName.Contains(keyword)) || - (x.citizenId != null && x.citizenId.Contains(keyword)) || - (x.root != null && x.root.Contains(keyword)) || - (x.nodeName != null && x.nodeName.Contains(keyword)) || - (x.nodeShortName != null && x.nodeShortName.Contains(keyword))) - .OrderByDescending(x => x.CreatedAt) - .Skip((page - 1) * pageSize) - .Take(pageSize) - .ToList(); + // if (keyword != "") + // { + // var data = placementReceives.Where(x => + // (x.prefix != null && x.prefix.Contains(keyword)) || + // (x.firstName != null && x.firstName.Contains(keyword)) || + // (x.lastName != null && x.lastName.Contains(keyword)) || + // (x.citizenId != null && x.citizenId.Contains(keyword)) || + // (x.root != null && x.root.Contains(keyword)) || + // (x.nodeName != null && x.nodeName.Contains(keyword)) || + // (x.nodeShortName != null && x.nodeShortName.Contains(keyword))) + // .OrderByDescending(x => x.CreatedAt) + // .Skip((page - 1) * pageSize) + // .Take(pageSize) + // .ToList(); - placementReceives = data; - } - return Success(new { data = placementReceives, total = placementReceives.Count }); + // placementReceives = data; + // } + return Success(placementReceives); // } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs index 0336cd3f..abb7055c 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs @@ -70,7 +70,8 @@ namespace BMA.EHR.Placement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet()] - public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") + public async Task> GetListByAdmin() + // public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") { var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_TEMPDUTY2"); var jsonData = JsonConvert.DeserializeObject(getPermission); @@ -148,28 +149,28 @@ namespace BMA.EHR.Placement.Service.Controllers }) .ToListAsync(); - if (keyword != "") - { - var data = placementRepatriations.Where(x => - (x.prefix != null && x.prefix.Contains(keyword)) || - (x.firstName != null && x.firstName.Contains(keyword)) || - (x.lastName != null && x.lastName.Contains(keyword)) || - (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || - (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || - (x.PositionOld != null && x.PositionOld.Contains(keyword)) || - (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || - (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || - (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || - (x.Organization != null && x.Organization.Contains(keyword))) - .OrderByDescending(x => x.CreatedAt) - .Skip((page - 1) * pageSize) - .Take(pageSize) - .ToList(); + // if (keyword != "") + // { + // var data = placementRepatriations.Where(x => + // (x.prefix != null && x.prefix.Contains(keyword)) || + // (x.firstName != null && x.firstName.Contains(keyword)) || + // (x.lastName != null && x.lastName.Contains(keyword)) || + // (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || + // (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || + // (x.PositionOld != null && x.PositionOld.Contains(keyword)) || + // (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || + // (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || + // (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || + // (x.Organization != null && x.Organization.Contains(keyword))) + // .OrderByDescending(x => x.CreatedAt) + // .Skip((page - 1) * pageSize) + // .Take(pageSize) + // .ToList(); - placementRepatriations = data; - } + // placementRepatriations = data; + // } - return Success(new { data = placementRepatriations, total = placementRepatriations.Count }); + return Success(placementRepatriations); } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index b847e237..1649108c 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -142,7 +142,8 @@ namespace BMA.EHR.Placement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet()] - public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") + public async Task> GetListByAdmin() + // public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") { var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_TRANSFER_REQ"); var jsonData = JsonConvert.DeserializeObject(getPermission); @@ -219,23 +220,23 @@ namespace BMA.EHR.Placement.Service.Controllers }) .ToListAsync(); - if (keyword != "") - { - var data = placementTransfers.Where(x => - (x.prefix != null && x.prefix.Contains(keyword)) || - (x.firstName != null && x.firstName.Contains(keyword)) || - (x.lastName != null && x.lastName.Contains(keyword)) || - (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || - (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword))) - .OrderByDescending(x => x.CreatedAt) - .Skip((page - 1) * pageSize) - .Take(pageSize) - .ToList(); + // if (keyword != "") + // { + // var data = placementTransfers.Where(x => + // (x.prefix != null && x.prefix.Contains(keyword)) || + // (x.firstName != null && x.firstName.Contains(keyword)) || + // (x.lastName != null && x.lastName.Contains(keyword)) || + // (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || + // (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword))) + // .OrderByDescending(x => x.CreatedAt) + // .Skip((page - 1) * pageSize) + // .Take(pageSize) + // .ToList(); - placementTransfers = data; - } + // placementTransfers = data; + // } - return Success(new { data = placementTransfers, total = placementTransfers.Count }); + return Success(placementTransfers); } } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index e102e0a4..a3b2ec1a 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -69,7 +69,8 @@ namespace BMA.EHR.Retirement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet()] - public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") + public async Task> GetListByAdmin() + // public async Task> GetListByAdmin(int page = 1, int pageSize = 10, string keyword = "") { var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_PLACEMENT_OTHER"); var jsonData = JsonConvert.DeserializeObject(getPermission); @@ -146,27 +147,27 @@ namespace BMA.EHR.Retirement.Service.Controllers CommandType = p.CommandType == null ? null : p.CommandType.Name, }) .ToListAsync(); - if (keyword != "") - { - var data = retirementOthers.Where(x => - (x.prefix != null && x.prefix.Contains(keyword)) || - (x.firstName != null && x.firstName.Contains(keyword)) || - (x.lastName != null && x.lastName.Contains(keyword)) || - (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || - (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || - (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || - (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || - (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || - (x.Reason != null && x.Reason.Contains(keyword))) - .OrderByDescending(x => x.CreatedAt) - .Skip((page - 1) * pageSize) - .Take(pageSize) - .ToList(); + // if (keyword != "") + // { + // var data = retirementOthers.Where(x => + // (x.prefix != null && x.prefix.Contains(keyword)) || + // (x.firstName != null && x.firstName.Contains(keyword)) || + // (x.lastName != null && x.lastName.Contains(keyword)) || + // (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || + // (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) || + // (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || + // (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || + // (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || + // (x.Reason != null && x.Reason.Contains(keyword))) + // .OrderByDescending(x => x.CreatedAt) + // .Skip((page - 1) * pageSize) + // .Take(pageSize) + // .ToList(); - retirementOthers = data; - } + // retirementOthers = data; + // } - return Success(new { data = retirementOthers, total = retirementOthers.Count }); + return Success(retirementOthers); } } From 0456e7b727b999208d80e07372e9c0e0fb4c8584 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 20 Sep 2024 18:03:54 +0700 Subject: [PATCH 04/19] =?UTF-8?q?fix=20=E0=B8=9A=E0=B8=A3=E0=B8=A3?= =?UTF-8?q?=E0=B8=88=E0=B8=B8=20=E0=B9=81=E0=B8=A5=E0=B8=B0=20=E0=B8=A7?= =?UTF-8?q?=E0=B8=B4=E0=B8=99=E0=B8=B1=E0=B8=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DisciplineComplaintController.cs | 29 +++++++++++++++++-- .../DisciplineDisciplinaryController.cs | 20 +++++++++++-- .../DisciplineInvestigateController.cs | 25 ++++++++++++++-- .../Controllers/PlacementController.cs | 6 ++++ 4 files changed, 71 insertions(+), 9 deletions(-) diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineComplaintController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineComplaintController.cs index e8b878f7..97f01299 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineComplaintController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineComplaintController.cs @@ -14,6 +14,7 @@ using System.Runtime.Serialization; using System.Security.Claims; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Microsoft.AspNetCore.Mvc.RazorPages; namespace BMA.EHR.DisciplineComplaint.Service.Controllers { @@ -134,10 +135,32 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet("{id:guid}")] - public async Task> GetByDisciplineComplaint(Guid id) + [HttpGet("{page}/{id:guid}")] + public async Task> GetByDisciplineComplaint(string page,Guid id) { - var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_COMPLAIN"); + page = page.Trim().ToUpper(); + string getPermission; + if (page == "MAIN") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_COMPLAIN"); + } + else if (page == "INVES") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_INVESTIGATE"); + } + else if (page == "DISCIP") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_INTERROGATE"); + } + else if (page == "RESULT") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_RESULT"); + } + else + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_COMPLAIN"); + } + var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineDisciplinaryController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineDisciplinaryController.cs index a4adf867..e748b392 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineDisciplinaryController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineDisciplinaryController.cs @@ -13,6 +13,7 @@ using Swashbuckle.AspNetCore.Annotations; using System.Security.Claims; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Microsoft.AspNetCore.Mvc.RazorPages; namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers { @@ -407,10 +408,23 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet("{id:guid}")] - public async Task> GetByDisciplineDisciplinary(Guid id) + [HttpGet("{page}/{id:guid}")] + public async Task> GetByDisciplineDisciplinary(string page,Guid id) { - var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_INTERROGATE"); + page = page.Trim().ToUpper(); + string getPermission; + if (page == "MAIN") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_INTERROGATE"); + } + else if (page == "RESULT") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_RESULT"); + } + else + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_INTERROGATE"); + } var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineInvestigateController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineInvestigateController.cs index b3c89003..a6f338f0 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineInvestigateController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineInvestigateController.cs @@ -13,6 +13,7 @@ using Swashbuckle.AspNetCore.Annotations; using System.Security.Claims; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Microsoft.AspNetCore.Mvc.RazorPages; namespace BMA.EHR.DisciplineInvestigate.Service.Controllers { @@ -246,10 +247,28 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet("{id:guid}")] - public async Task> GetByDisciplineInvestigate(Guid id) + [HttpGet("{page}/{id:guid}")] + public async Task> GetByDisciplineInvestigate(string page,Guid id) { - var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_INVESTIGATE"); + page = page.Trim().ToUpper(); + string getPermission; + if (page == "MAIN") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_INVESTIGATE"); + } + else if (page == "DISCIP") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_INTERROGATE"); + } + else if (page == "RESULT") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_RESULT"); + } + else + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_INVESTIGATE"); + } + var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 5bf3d7f4..203b1604 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -95,6 +95,12 @@ namespace BMA.EHR.Placement.Service.Controllers public async Task> GetExam(int year) // public async Task> GetExam(int year, int page = 1, int pageSize = 10, string keyword = "") { + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_PLACEMENT_PASS"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var data = await _context.Placements.Where(x => year > 0 ? (x.Year == year) : (x.Year > 0)) .OrderByDescending(x => x.CreatedAt) .Select(x => new From c34399b855e1a1193f8b6b433f846aeab073638c Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 23 Sep 2024 10:04:07 +0700 Subject: [PATCH 05/19] fix bug 614 , 615 --- .../Controllers/PlacementController.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 203b1604..4700c31f 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -95,7 +95,7 @@ namespace BMA.EHR.Placement.Service.Controllers public async Task> GetExam(int year) // public async Task> GetExam(int year, int page = 1, int pageSize = 10, string keyword = "") { - var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_PLACEMENT_PASS"); + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_PLACEMENT_PASS"); var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { @@ -137,6 +137,12 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpGet("pass/{examId:length(36)}")] public async Task> GetExamByPlacement(Guid examId) { + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_PLACEMENT_PASS"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } if (PlacementAdmin == true) { var data = await _context.PlacementProfiles.Where(x => x.Placement.Id == examId).Select(x => new From 048a17224bc4e61b11484e8dd8c936caffcbdee1 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 23 Sep 2024 17:52:29 +0700 Subject: [PATCH 06/19] fix complain_Channel --- .../DisciplineComplaint_ChannelController.cs | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineComplaint_ChannelController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineComplaint_ChannelController.cs index e1612970..572ca4c8 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineComplaint_ChannelController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineComplaint_ChannelController.cs @@ -13,6 +13,7 @@ using Swashbuckle.AspNetCore.Annotations; using System.Security.Claims; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.IO; namespace BMA.EHR.DisciplineComplaint_Channel.Service.Controllers { @@ -57,10 +58,39 @@ namespace BMA.EHR.DisciplineComplaint_Channel.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet()] - public async Task> GetDiscipline(int page = 1, int pageSize = 25, string keyword = "") + [HttpGet("{path}")] + public async Task> GetDiscipline(string path, int page = 1, int pageSize = 25, string keyword = "") { - var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_DISCIPLINE_INFO"); + path = path.Trim().ToUpper(); + string getPermission; + if (path == "MAIN") + { + getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_DISCIPLINE_INFO"); + } + else if (path == "COMPLAIN") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_COMPLAIN"); + } + else if (path == "CREATE-COMPLAIN") + { + getPermission = await _permission.GetPermissionAPIAsync("CREATE", "SYS_DISCIPLINE_COMPLAIN"); + } + else if (path == "INVES") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_INVESTIGATE"); + } + else if (path == "DISCIP") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_INTERROGATE"); + } + else if (path == "RESULT") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_RESULT"); + } + else + { + getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_DISCIPLINE_INFO"); + } var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { From 1496c1a4384b3e5306ae3801cdeb85495a5928a2 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 24 Sep 2024 11:53:09 +0700 Subject: [PATCH 07/19] =?UTF-8?q?=E0=B8=AA=E0=B8=B4=E0=B8=97=E0=B8=98?= =?UTF-8?q?=E0=B8=B4=E0=B9=8C=20=E0=B8=A5=E0=B8=B2=E0=B8=A5=E0=B8=87?= =?UTF-8?q?=E0=B9=80=E0=B8=A7=E0=B8=A5=E0=B8=B2=20admin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BMA.EHR.Leave/Controllers/LeaveController.cs | 124 +++++++++++++++++- .../Controllers/LeaveReportController.cs | 19 ++- .../Controllers/LeaveRequestController.cs | 26 +++- 3 files changed, 163 insertions(+), 6 deletions(-) diff --git a/BMA.EHR.Leave/Controllers/LeaveController.cs b/BMA.EHR.Leave/Controllers/LeaveController.cs index 55493a74..6cbc93e6 100644 --- a/BMA.EHR.Leave/Controllers/LeaveController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveController.cs @@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.ObjectPool; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using RabbitMQ.Client; using Swashbuckle.AspNetCore.Annotations; using System.ComponentModel.DataAnnotations; @@ -48,8 +49,8 @@ namespace BMA.EHR.Leave.Service.Controllers private readonly UserDutyTimeRepository _userDutyTimeRepository; private readonly AdditionalCheckRequestRepository _additionalCheckRequestRepository; private readonly LeaveRequestRepository _leaveRequestRepository; - private readonly UserCalendarRepository _userCalendarRepository; + private readonly PermissionRepository _permission; private readonly CommandRepository _commandRepository; @@ -77,7 +78,8 @@ namespace BMA.EHR.Leave.Service.Controllers UserCalendarRepository userCalendarRepository, CommandRepository commandRepository, LeaveRequestRepository leaveRequestRepository, - ObjectPool objectPool) + ObjectPool objectPool, + PermissionRepository permission) { _dutyTimeRepository = dutyTimeRepository; _context = context; @@ -95,6 +97,7 @@ namespace BMA.EHR.Leave.Service.Controllers _leaveRequestRepository = leaveRequestRepository; _objectPool = objectPool; + _permission = permission; } #endregion @@ -140,6 +143,12 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> GetAllAsync() { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_WORK_ROUND"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var data = await _dutyTimeRepository.GetAllAsync(); return Success(data); @@ -178,6 +187,13 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> PostAsync([FromBody] CreateDutyTimeDto data) { + var getPermission = await _permission.GetPermissionAPIAsync("CREATE", "SYS_WORK_ROUND"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + // validate var startMorning = TimeOnly.Parse(data.StartTimeMorning); var endMorning = TimeOnly.Parse(data.EndTimeMorning); @@ -257,6 +273,13 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> PutAsync(Guid id, [FromBody] UpdateDutyTimeDto data) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_WORK_ROUND"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + var oldData = await _dutyTimeRepository.GetByIdAsync(id); if (oldData == null) { @@ -300,6 +323,13 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> DeleteAsync(Guid id) { + var getPermission = await _permission.GetPermissionAPIAsync("DELETE", "SYS_WORK_ROUND"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + var oldData = await _dutyTimeRepository.GetByIdAsync(id); if (oldData == null) { @@ -339,6 +369,12 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> GetAllActiveAsync() { + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_WORK_ROUND_EDIT"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var data = await _dutyTimeRepository.GetAllActiveAsync(); return Success(data); @@ -979,6 +1015,13 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> LogRecordAsync([Required] DateTime startDate, [Required] DateTime endDate, int page = 1, int pageSize = 10, string keyword = "") { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_CHECKIN"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + if (startDate.Date > endDate.Date) { return Error(new Exception("วันเริ่มต้นต้องมีค่าน้อยกว่าหรือเท่ากับวันสิ้นสุด"), StatusCodes.Status400BadRequest); @@ -1047,8 +1090,14 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> GetTimeRecordAsync([Required] Guid id) { - var imgUrl = $"{_configuration["MinIO:Endpoint"]}{_configuration["MinIO:BucketName"]}"; + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_CHECKIN"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + var imgUrl = $"{_configuration["MinIO:Endpoint"]}{_configuration["MinIO:BucketName"]}"; var d = (await _processUserTimeStampRepository.GetTimeStampById(id)); if (d == null) @@ -1145,6 +1194,12 @@ namespace BMA.EHR.Leave.Service.Controllers [AllowAnonymous] public async Task> GetTimeRecordAsync([Required] DateTime startDate, [Required] DateTime endDate, int page = 1, int pageSize = 10, string status = "NORMAL", string keyword = "") { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_CHECKIN"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } if (startDate.Date > endDate.Date) { return Error(new Exception("วันเริ่มต้นต้องมีค่าน้อยกว่าหรือเท่ากับวันสิ้นสุด"), StatusCodes.Status400BadRequest); @@ -1322,7 +1377,12 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> SearchProfileAsync([FromBody] DTOs.ChangeRound.SearchProfileDto req) { - + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_WORK_ROUND_EDIT"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var profile = await _userProfileRepository.SearchProfile(req.CitizenId, req.FirstName, req.LastName, AccessToken ?? ""); var pagedProfile = profile.Skip((req.Page - 1) * req.PageSize).Take(req.PageSize).ToList(); @@ -1369,6 +1429,12 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> CreateChangeRoundAsync([FromBody] CreateChangeRoundDto req) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_WORK_ROUND_EDIT"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var currentDate = DateTime.Now.Date; if (req.EffectiveDate.Date < currentDate) { @@ -1410,6 +1476,12 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> GetChangeRoundHistoryByProfileIdAsync(Guid id, int page = 1, int pageSize = 10, string keyword = "") { + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_WORK_ROUND_EDIT"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var data = await _userDutyTimeRepository.GetListByProfileIdAsync(id); var resultSet = new List(); @@ -1498,6 +1570,13 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> GetAdditionalCheckRequestAsync([Required] int year, [Required] int month, [Required] int page = 1, [Required] int pageSize = 10, string keyword = "") { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_CHECKIN_SPECIAL"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + var rawData = await _additionalCheckRequestRepository.GetAdditionalCheckRequests(year, month); var getDefaultRound = await _dutyTimeRepository.GetDefaultAsync(); @@ -1605,6 +1684,12 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> ApproveRequestAsync(Guid id, [FromBody] ApproveRequestDto req) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_CHECKIN_SPECIAL"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } if (req.Reason == null || req.Reason == string.Empty) { return Error("กรุณากรอกเหตุผล", StatusCodes.Status400BadRequest); @@ -1701,6 +1786,12 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> RejectRequestAsync(Guid id, [FromBody] RejectRequestDto req) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_CHECKIN_SPECIAL"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } if (req.Reason == null || req.Reason == string.Empty) { return Error("กรุณากรอกเหตุผล", StatusCodes.Status400BadRequest); @@ -1745,6 +1836,13 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> GetLogRecordAsync([Required] Guid id) { + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_CHECKIN"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + var imgUrl = $"{_configuration["MinIO:Endpoint"]}{_configuration["MinIO:BucketName"]}"; @@ -1963,6 +2061,12 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> GetCalendarByProfileAsync(Guid id) { + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_WORK_ROUND_EDIT"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var data = await _userCalendarRepository.GetExist(id); if (data == null) return Success(new { Work = "NORMAL" }); @@ -1984,6 +2088,12 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> UpdateCalendarByProfileAsync(Guid id, [FromBody] UpdateCalendarDto req) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_WORK_ROUND_EDIT"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var data = await _userCalendarRepository.GetExist(id); if (data != null) { @@ -2023,6 +2133,12 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> EditCheckInStatusAsync(Guid id, [FromBody] EditCheckInStatusDto req) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_CHECKIN"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var data = await _processUserTimeStampRepository.GetByIdAsync(id); if (data == null) return Error(GlobalMessages.DataNotFound); diff --git a/BMA.EHR.Leave/Controllers/LeaveReportController.cs b/BMA.EHR.Leave/Controllers/LeaveReportController.cs index 3e9a6f16..c8a2ca55 100644 --- a/BMA.EHR.Leave/Controllers/LeaveReportController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveReportController.cs @@ -10,6 +10,8 @@ using BMA.EHR.Domain.Shared; using BMA.EHR.Leave.Service.DTOs.Reports; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; using Swashbuckle.AspNetCore.Annotations; using System.Globalization; using System.Security.Claims; @@ -37,6 +39,7 @@ namespace BMA.EHR.Leave.Service.Controllers private readonly HolidayRepository _holidayRepository; private readonly UserCalendarRepository _userCalendarRepository; private readonly IHttpContextAccessor _httpContextAccessor; + private readonly PermissionRepository _permission; #endregion @@ -51,7 +54,8 @@ namespace BMA.EHR.Leave.Service.Controllers UserDutyTimeRepository userDutyTimeRepository, HolidayRepository holidayRepository, UserCalendarRepository userCalendarRepository, - IHttpContextAccessor httpContextAccessor) + IHttpContextAccessor httpContextAccessor, + PermissionRepository permission) { _leaveRequestRepository = leaveRequestRepository; _userProfileRepository = userProfileRepository; @@ -63,6 +67,7 @@ namespace BMA.EHR.Leave.Service.Controllers _holidayRepository = holidayRepository; _userCalendarRepository = userCalendarRepository; _httpContextAccessor = httpContextAccessor; + _permission = permission; } #endregion @@ -743,6 +748,12 @@ namespace BMA.EHR.Leave.Service.Controllers { try { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_LEAVE_REPORT"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } //var profile = await _userProfileRepository.SearchProfile(null, null, null); var profile = await _userProfileRepository.GetProfileWithKeycloak(AccessToken); if (profile.Count > 0) @@ -915,6 +926,12 @@ namespace BMA.EHR.Leave.Service.Controllers { try { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_LEAVE_REPORT"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var profile = await _userProfileRepository.SearchProfileEmployee(null, null, null, AccessToken ?? ""); var count = 1; var employees = new List(); diff --git a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs index 3bba1d70..9dd6664f 100644 --- a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs @@ -13,6 +13,8 @@ using BMA.EHR.Leave.Service.DTOs.LeaveRequest; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; using Swashbuckle.AspNetCore.Annotations; using System.Security.Claims; @@ -39,6 +41,7 @@ namespace BMA.EHR.Leave.Service.Controllers private readonly HolidayRepository _holidayRepository; private readonly CommandRepository _commandRepository; private readonly UserCalendarRepository _userCalendarRepository; + private readonly PermissionRepository _permission; private const string APPROVE_STEP_CREATE = "st1"; private const string APPROVE_STEP_OFFICER_APPROVE = "st2"; @@ -60,7 +63,8 @@ namespace BMA.EHR.Leave.Service.Controllers MinIOLeaveService minIOService, HolidayRepository holidayRepository, CommandRepository commandRepository, - UserCalendarRepository userCalendarRepository) + UserCalendarRepository userCalendarRepository, + PermissionRepository permission) { _context = context; _httpContextAccessor = httpContextAccessor; @@ -73,6 +77,7 @@ namespace BMA.EHR.Leave.Service.Controllers _holidayRepository = holidayRepository; _commandRepository = commandRepository; _userCalendarRepository = userCalendarRepository; + _permission = permission; } #endregion @@ -1088,6 +1093,12 @@ namespace BMA.EHR.Leave.Service.Controllers public async Task> GetLeaveRequestForAdminAsync( [FromBody] GetLeaveRequestForAdminDto req) { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_LEAVE_LIST"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var rawData = await _leaveRequestRepository.GetLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate); var result = new List(); @@ -1343,6 +1354,12 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> OfficerApproveLeaveRequestAsync(Guid id) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } await _leaveRequestRepository.OfficerApproveLeaveRequest(id); return Success(); @@ -1442,6 +1459,13 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> GetLeaveRequestForAdminByIdAsync(Guid id) { + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_LEAVE_LIST"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); var rawData = await _leaveRequestRepository.GetByIdAsync(id); From 90f3a7bfe58065838d83a82be754d3cec6d7d427 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 24 Sep 2024 15:40:07 +0700 Subject: [PATCH 08/19] add permission insignia --- .../Controllers/InsigniaManageController.cs | 62 ++++++++++++++++++- .../Controllers/InsigniaPeriodController.cs | 38 +++++++++++- .../Controllers/InsigniaRequestController.cs | 43 ++++++++++++- 3 files changed, 137 insertions(+), 6 deletions(-) diff --git a/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs b/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs index 9218d370..c6fbbf5f 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using OfficeOpenXml.Export.ToDataTable; using Swashbuckle.AspNetCore.Annotations; @@ -30,13 +31,14 @@ namespace BMA.EHR.Insignia.Service.Controllers private readonly InsigniaPeriodsRepository _repository; private readonly NotificationRepository _repositoryNoti; private readonly UserProfileRepository _userProfileRepository; - + private readonly PermissionRepository _permission; public InsigniaManageController(ApplicationDBContext context, MinIOService documentService, InsigniaPeriodsRepository repository, NotificationRepository repositoryNoti, IHttpContextAccessor httpContextAccessor, - UserProfileRepository userProfileRepository) + UserProfileRepository userProfileRepository, + PermissionRepository permission) { _context = context; _documentService = documentService; @@ -44,6 +46,7 @@ namespace BMA.EHR.Insignia.Service.Controllers _repositoryNoti = repositoryNoti; _httpContextAccessor = httpContextAccessor; _userProfileRepository = userProfileRepository; + _permission = permission; } #region " Properties " @@ -69,6 +72,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpGet("type/{year}/{insigniaTypeId:length(36)}")] public async Task> GetList(int year, Guid insigniaTypeId) { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_ALLOCATE"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var insigniaType = await _context.InsigniaTypes .FirstOrDefaultAsync(x => x.Id == insigniaTypeId); if (insigniaType == null) @@ -135,6 +144,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPost()] public async Task> Post([FromBody] InsigniaManageRequest req) { + var getPermission = await _permission.GetPermissionAPIAsync("CREATE", "SYS_INSIGNIA_ALLOCATE"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var insignia = await _context.Insignias.AsQueryable() .FirstOrDefaultAsync(x => x.Id == req.Insignia); if (insignia == null) @@ -176,6 +191,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpDelete("{insigniaManageId:length(36)}")] public async Task> Delete(Guid insigniaManageId) { + var getPermission = await _permission.GetPermissionAPIAsync("DELETE", "SYS_INSIGNIA_ALLOCATE"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var deleted = await _context.InsigniaManages.AsQueryable() .Where(x => x.Id == insigniaManageId) .FirstOrDefaultAsync(); @@ -200,6 +221,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPut("{insigniaManageId:length(36)}")] public async Task> Put([FromBody] InsigniaManageRequest req, Guid insigniaManageId) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_INSIGNIA_ALLOCATE"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var insignia = await _context.Insignias.AsQueryable() .FirstOrDefaultAsync(x => x.Id == req.Insignia); if (insignia == null) @@ -241,6 +268,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpGet("org/{insigniaManageId:length(36)}")] public async Task> GetListOrganization(Guid insigniaManageId) { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_ALLOCATE"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var insigniaManage = await _context.InsigniaManages.AsQueryable() .FirstOrDefaultAsync(x => x.Id == insigniaManageId); if (insigniaManage == null) @@ -274,6 +307,12 @@ 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 jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var organization = _userProfileRepository.GetOc(req.OrganizationOrganizationId, 0, AccessToken); @@ -331,6 +370,13 @@ 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 jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + var deleted = await _context.InsigniaManageOrganiations.AsQueryable() .FirstOrDefaultAsync(x => x.Id == insigniaManageOrgId); @@ -353,6 +399,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPut("org/{insigniaManageOrgId:length(36)}")] public async Task> PutOrganization([FromBody] InsigniaManageOrganizationUpdateRequest req, Guid insigniaManageOrgId) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_INSIGNIA_ALLOCATE"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var uppdated = await _context.InsigniaManageOrganiations.AsQueryable() //.Include(x => x.OrganizationOrganization) .Include(x => x.InsigniaManage) @@ -392,6 +444,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpGet("org/dashboard/{insigniaManageId:length(36)}")] public async Task> GetListDashboardOrganization(Guid insigniaManageId) { + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_INSIGNIA_ALLOCATE"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var insigniaManage = await _context.InsigniaManages.AsQueryable() .Include(x => x.InsigniaManageOrganiations) .Select(p => new diff --git a/BMA.EHR.Insignia/Controllers/InsigniaPeriodController.cs b/BMA.EHR.Insignia/Controllers/InsigniaPeriodController.cs index cc8868e8..baf7b1f7 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaPeriodController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaPeriodController.cs @@ -9,6 +9,8 @@ using BMA.EHR.Infrastructure.Persistence; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; using Swashbuckle.AspNetCore.Annotations; namespace BMA.EHR.Insignia.Service.Controllers @@ -27,13 +29,14 @@ namespace BMA.EHR.Insignia.Service.Controllers private readonly InsigniaPeriodsRepository _repository; private readonly NotificationRepository _repositoryNoti; private readonly UserProfileRepository _userProfileRepository; - + private readonly PermissionRepository _permission; public InsigniaPeriodController(ApplicationDBContext context, MinIOService documentService, InsigniaPeriodsRepository repository, NotificationRepository repositoryNoti, IHttpContextAccessor httpContextAccessor, - UserProfileRepository userProfileRepository) + UserProfileRepository userProfileRepository, + PermissionRepository permission) { _context = context; _documentService = documentService; @@ -41,6 +44,7 @@ namespace BMA.EHR.Insignia.Service.Controllers _repositoryNoti = repositoryNoti; _httpContextAccessor = httpContextAccessor; _userProfileRepository = userProfileRepository; + _permission = permission; } #region " Properties " @@ -64,6 +68,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpGet()] public async Task> GetList() { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_ROUND"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var insigniaPeriods = await _context.InsigniaPeriods.AsQueryable() // .Where(x => x.Type == type) .OrderByDescending(x => x.Year) @@ -116,6 +126,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpGet("{id:length(36)}")] public async Task> GetById(Guid id) { + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_INSIGNIA_ROUND"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var data = await _context.InsigniaPeriods.AsQueryable() .Where(x => x.Id == id) .Select(p => new @@ -170,6 +186,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPost()] public async Task> Post([FromForm] InsigniaPeriodRequest req) { + var getPermission = await _permission.GetPermissionAPIAsync("CREATE", "SYS_INSIGNIA_ROUND"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var revisionId = await _userProfileRepository.GetLastRevision(AccessToken); var insigniaPeriod = await _context.InsigniaPeriods.AsQueryable() @@ -225,6 +247,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpDelete("{id:length(36)}")] public async Task> Delete(Guid id) { + var getPermission = await _permission.GetPermissionAPIAsync("DELETE", "SYS_INSIGNIA_ROUND"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var deleted = await _context.InsigniaPeriods.AsQueryable() .Include(x => x.ReliefDoc) .FirstOrDefaultAsync(x => x.Id == id); @@ -258,6 +286,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPut("{id:length(36)}")] public async Task> Put([FromForm] InsigniaPeriodRequest req, Guid id) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_INSIGNIA_ROUND"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } if (req == null) return BadRequest(); diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index 56eaf696..912e88d0 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using OfficeOpenXml; using RabbitMQ.Client; using Swashbuckle.AspNetCore.Annotations; @@ -43,7 +44,7 @@ namespace BMA.EHR.Insignia.Service.Controllers private readonly InsigniaPeriodsRepository _insigniaPeriodRepository; private readonly IConfiguration _configuration; - + private readonly PermissionRepository _permission; /// /// /// @@ -64,7 +65,8 @@ namespace BMA.EHR.Insignia.Service.Controllers IHttpContextAccessor httpContextAccessor, UserProfileRepository userProfileRepository, InsigniaPeriodsRepository insigniaPeriodRepository, - IConfiguration configuration) + IConfiguration configuration, + PermissionRepository permission) { _context = context; _documentService = documentService; @@ -75,6 +77,7 @@ namespace BMA.EHR.Insignia.Service.Controllers _userProfileRepository = userProfileRepository; _insigniaPeriodRepository = insigniaPeriodRepository; _configuration = configuration; + _permission = permission; } #region " Properties " @@ -343,6 +346,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpGet("{insigniaPeriodId:length(36)}/{ocId:length(36)}/{role}/{status}")] public async Task> GetInsignaiRequestBkk(Guid insigniaPeriodId, Guid ocId, string role, string status) { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_MANAGE"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId); if (result != null) { @@ -947,6 +956,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpGet("dashboard/{insigniaPeriodId:length(36)}")] public async Task> DashboardInsigniaPeriod(Guid insigniaPeriodId) { + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_INSIGNIA_MANAGE"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var insigniaPeriod = await _context.InsigniaPeriods.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId); if (insigniaPeriod == null) return Error(GlobalMessages.InsigniaRequestNotFound); @@ -974,6 +989,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpGet("org/no-send/{insigniaPeriodId:length(36)}")] public async Task> ListOrgDontSentUser(Guid insigniaPeriodId) { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_MANAGE"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var insigniaPeriod = await _context.InsigniaPeriods.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId); if (insigniaPeriod == null) return Error(GlobalMessages.InsigniaRequestNotFound); @@ -1335,6 +1356,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpGet("note")] public async Task> GetListNote() { + 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 insigniaNotes = await _context.InsigniaNotes.AsQueryable() .OrderByDescending(x => x.Year) // .ThenByDescending(x => x.StartDate) @@ -1381,6 +1408,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPost("note/search")] public async Task> GetListNoteProfile([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) @@ -1821,6 +1854,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPut("note/doc/{insigniaNoteId:length(36)}")] public async Task> AddDocumentProfile([FromForm] InsigniaNoteDocRequest req, Guid insigniaNoteId) { + 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 == insigniaNoteId); if (insigniaNote == null) From f1ab73fd39d7fb0a7446c4599e0ee394d9b2e2fd Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 24 Sep 2024 15:54:57 +0700 Subject: [PATCH 09/19] =?UTF-8?q?fix=20=E0=B8=AA=E0=B8=B4=E0=B8=97?= =?UTF-8?q?=E0=B8=98=E0=B8=B4=E0=B9=8C=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=20?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=87=E0=B8=B2=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/InsigniaManageController.cs | 26 +++++++++++++++-- .../Controllers/InsigniaReportController.cs | 28 +++++++++++++++++-- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs b/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs index 9218d370..0559099f 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using OfficeOpenXml.Export.ToDataTable; using Swashbuckle.AspNetCore.Annotations; @@ -30,13 +31,15 @@ namespace BMA.EHR.Insignia.Service.Controllers private readonly InsigniaPeriodsRepository _repository; private readonly NotificationRepository _repositoryNoti; private readonly UserProfileRepository _userProfileRepository; + private readonly PermissionRepository _permission; public InsigniaManageController(ApplicationDBContext context, MinIOService documentService, InsigniaPeriodsRepository repository, NotificationRepository repositoryNoti, IHttpContextAccessor httpContextAccessor, - UserProfileRepository userProfileRepository) + UserProfileRepository userProfileRepository, + PermissionRepository permission) { _context = context; _documentService = documentService; @@ -44,6 +47,7 @@ namespace BMA.EHR.Insignia.Service.Controllers _repositoryNoti = repositoryNoti; _httpContextAccessor = httpContextAccessor; _userProfileRepository = userProfileRepository; + _permission = permission; } #region " Properties " @@ -424,7 +428,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPost("borrow")] public async Task> PostBorrowInsignia([FromBody] InsigniaBorrowRequest req) { - + var getPermission = await _permission.GetPermissionAPIAsync("CREATE", "SYS_INSIGNIA_BORROW"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var insigniaNoteProfile = await _context.InsigniaNoteProfiles.AsQueryable() .Include(x => x.RequestInsignia) .Include(x => x.InsigniaNote) @@ -503,7 +512,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPut("return/{insigniaManageProfileId:length(36)}")] public async Task> PutReturnInsignia([FromBody] InsigniaReturnRequest req, Guid insigniaManageProfileId) { - + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_INSIGNIA_BORROW"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var uppdated = await _context.InsigniaManageProfiles.AsQueryable() //.Include(x => x.BorrowOrganization) .FirstOrDefaultAsync(x => x.Id == insigniaManageProfileId); @@ -548,6 +562,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpGet("borrow/{year}/{insigniaTypeId:length(36)}")] public async Task> ListBorrowReturnInsignia(int year, Guid insigniaTypeId) { + var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_BORROW"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var insigniaType = await _context.InsigniaTypes .FirstOrDefaultAsync(x => x.Id == insigniaTypeId); if (insigniaType == null) diff --git a/BMA.EHR.Report.Service/Controllers/InsigniaReportController.cs b/BMA.EHR.Report.Service/Controllers/InsigniaReportController.cs index 52fdaec3..54526364 100644 --- a/BMA.EHR.Report.Service/Controllers/InsigniaReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/InsigniaReportController.cs @@ -3,9 +3,12 @@ using BMA.EHR.Domain.Common; using BMA.EHR.Domain.Extensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; using Swashbuckle.AspNetCore.Annotations; using Telerik.Reporting; using Telerik.Reporting.Processing; +using BMA.EHR.Application.Repositories; namespace BMA.EHR.Report.Service.Controllers { @@ -23,19 +26,20 @@ namespace BMA.EHR.Report.Service.Controllers private readonly IConfiguration _configuration; private readonly InsigniaReportRepository _repository; private readonly GenericReportGenerator _reportGenerator; - + private readonly PermissionRepository _permission; #endregion #region " Constuctor and Destructor " - public InsigniaReportController(IWebHostEnvironment hostingEnvironment, IConfiguration configuration, InsigniaReportRepository repository, GenericReportGenerator reportGenerator) + public InsigniaReportController(IWebHostEnvironment hostingEnvironment, IConfiguration configuration, InsigniaReportRepository repository, GenericReportGenerator reportGenerator, PermissionRepository permission) { _hostingEnvironment = hostingEnvironment; _configuration = configuration; _repository = repository; _reportGenerator = reportGenerator; + _permission = permission; } #endregion @@ -384,7 +388,12 @@ namespace BMA.EHR.Report.Service.Controllers { try { - + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_INSIGNIA_REPORT"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var mimeType = ""; switch (exportType.Trim().ToLower()) { @@ -421,6 +430,12 @@ namespace BMA.EHR.Report.Service.Controllers { try { + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_INSIGNIA_REPORT"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } var data = await _repository.GetSummaryCoinReport(id); var SummaryTotal = await _repository.GetSummaryTotalCoinReport(id); var YearInsignalPeriod = await _repository.GetYearInsigniaPeriod(id); @@ -493,6 +508,13 @@ namespace BMA.EHR.Report.Service.Controllers { try { + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_INSIGNIA_REPORT"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + //Guid ids = Guid.Parse(id); var data = await _repository.GetCoinReport(id); var YearInsignalPeriod = await _repository.GetYearInsigniaPeriod(id); From a1cd8ac9a3ead4b0daaa633d6cb2db77d713ee66 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 24 Sep 2024 16:35:49 +0700 Subject: [PATCH 10/19] =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=9A=E0=B8=9A?= =?UTF-8?q?=E0=B8=88=E0=B8=B1=E0=B8=94=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=AA?= =?UTF-8?q?=E0=B8=B4=E0=B8=97=E0=B8=98=E0=B8=B4=E0=B9=8C>>=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B8=9A=E0=B8=9A=E0=B8=A7=E0=B8=B4=E0=B8=99=E0=B8=B1?= =?UTF-8?q?=E0=B8=A2=20(=E0=B8=81=E0=B8=A3=E0=B8=93=E0=B8=B5=E0=B9=80?= =?UTF-8?q?=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1=E0=B8=A3=E0=B8=B2=E0=B8=A2?= =?UTF-8?q?=E0=B8=8A=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=81=E0=B8=A3=E0=B8=A3?= =?UTF-8?q?=E0=B8=A1=E0=B8=81=E0=B8=B2=E0=B8=A3)=20#630?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DisciplineDirectorController.cs | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineDirectorController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineDirectorController.cs index cce9df20..7c081ced 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineDirectorController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineDirectorController.cs @@ -13,6 +13,7 @@ using Swashbuckle.AspNetCore.Annotations; using System.Security.Claims; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.IO; namespace BMA.EHR.DisciplineDirector.Service.Controllers { @@ -57,10 +58,29 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet()] - public async Task> GetDiscipline(int page = 1, int pageSize = 25, string keyword = "") + [HttpGet("{path}")] + public async Task> GetDiscipline(string path, int page = 1, int pageSize = 25, string keyword = "") { - var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_DISCIPLINE_INFO"); + path = path.Trim().ToUpper(); + string getPermission; + if (path == "MAIN") + { + getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_DISCIPLINE_INFO"); + } + else if (path == "INVES") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_INVESTIGATE"); + } + else if (path == "DISCIP") + { + getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_INTERROGATE"); + } + else + { + getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_DISCIPLINE_INFO"); + } + + var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { From 7a969179268caf79687e2681bbb464e97a317991 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 25 Sep 2024 11:29:49 +0700 Subject: [PATCH 11/19] =?UTF-8?q?fix=20=E0=B8=A3=E0=B8=B2=E0=B8=A2?= =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=82=E0=B8=AD=E0=B9=82=E0=B8=AD?= =?UTF-8?q?=E0=B8=99=20=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80?= =?UTF-8?q?=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99=E0=B9=84=E0=B8=A1=E0=B9=88?= =?UTF-8?q?=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PlacementTransferController.cs | 2 +- BMA.EHR.Placement.Service/Requests/OrgRequest.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index 1649108c..000adcf0 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -532,7 +532,7 @@ namespace BMA.EHR.Placement.Service.Controllers placementTransfer.posTypeNameOld = org.result.posTypeName; placementTransfer.posLevelOldId = org.result.posLevelId; placementTransfer.posLevelNameOld = org.result.posLevelName; - + placementTransfer.AmountOld = org.result.salary; placementTransfer.PositionOld = org.result.position; placementTransfer.PositionLevelOld = org.result.posLevelName; placementTransfer.PositionTypeOld = org.result.posTypeName; diff --git a/BMA.EHR.Placement.Service/Requests/OrgRequest.cs b/BMA.EHR.Placement.Service/Requests/OrgRequest.cs index f0d858e4..54263203 100644 --- a/BMA.EHR.Placement.Service/Requests/OrgRequest.cs +++ b/BMA.EHR.Placement.Service/Requests/OrgRequest.cs @@ -40,5 +40,7 @@ namespace BMA.EHR.Placement.Service.Requests public string? posTypeName { get; set; } public string? posLevelId { get; set; } public string? posLevelName { get; set; } + public double? salary { get; set; } + } } \ No newline at end of file From 05a5897dc75bcb3e68b38ed6ad1c2e2aafb5ddd0 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 25 Sep 2024 14:48:46 +0700 Subject: [PATCH 12/19] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84?= =?UTF-8?q?=E0=B8=82=20#632=20=E0=B9=81=E0=B8=A5=E0=B8=B0=20#633?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/LeaveRequestController.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs index 9dd6664f..4e38fcae 100644 --- a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs @@ -1314,6 +1314,12 @@ namespace BMA.EHR.Leave.Service.Controllers public async Task> ApproveCancelLeaveRequestAsync(Guid id, [FromBody] CancelLeaveRequestApproveDto req) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } await _leaveRequestRepository.ApproveCancelLeaveRequestAsync(id, req.Reason ?? ""); return Success(); @@ -1335,6 +1341,12 @@ namespace BMA.EHR.Leave.Service.Controllers public async Task> RejectCancelLeaveRequestAsync(Guid id, [FromBody] CancelLeaveRequestApproveDto req) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } await _leaveRequestRepository.RejectCancelLeaveRequestAsync(id, req.Reason ?? ""); return Success(); @@ -1380,6 +1392,12 @@ namespace BMA.EHR.Leave.Service.Controllers public async Task> CommanderApproveLeaveRequestAsync(Guid id, [FromBody] LeaveRequestApproveDto req) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } await _leaveRequestRepository.CommanderApproveLeaveRequest(id, req.Reason ?? ""); return Success(); @@ -1400,6 +1418,12 @@ namespace BMA.EHR.Leave.Service.Controllers public async Task> ApproveLeaveRequestAsync(Guid id, [FromBody] LeaveRequestApproveDto req) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } await _leaveRequestRepository.ApproveLeaveRequest(id, req.Reason ?? ""); return Success(); @@ -1440,6 +1464,12 @@ namespace BMA.EHR.Leave.Service.Controllers public async Task> RejectLeaveRequestAsync(Guid id, [FromBody] LeaveRequestApproveDto req) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } await _leaveRequestRepository.RejectLeaveRequest(id, req.Reason ?? ""); return Success(); From e5bb18692526a74297cb576704a7da29876277f7 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 25 Sep 2024 17:43:55 +0700 Subject: [PATCH 13/19] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=AA?= =?UTF-8?q?=E0=B8=B4=E0=B8=97=E0=B8=98=E0=B8=B4=E0=B9=8C=20#642?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index 912e88d0..de5fe6b5 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -1854,7 +1854,7 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPut("note/doc/{insigniaNoteId:length(36)}")] public async Task> AddDocumentProfile([FromForm] InsigniaNoteDocRequest req, Guid insigniaNoteId) { - var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_RECORD"); + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_INSIGNIA_RECORD"); var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { @@ -1908,6 +1908,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpGet("note/doc/{insigniaNoteId:length(36)}")] public async Task> GetDocumentProfile(Guid insigniaNoteId) { + 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 .Include(x => x.InsigniaNoteDocs) .ThenInclude(x => x.Document) From 0cb940a927bfa447c8b9bac35615bea5f73abf05 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 25 Sep 2024 17:58:37 +0700 Subject: [PATCH 14/19] fix permission insignia #635, #636 --- .../Controllers/InsigniaRequestController.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index de5fe6b5..fa05b5d4 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -2123,6 +2123,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPut("preview/receice/{insigniaNoteId:length(36)}"), DisableRequestSizeLimit] public async Task> PreviewReceiceProfile([FromForm] ImportFileRequest req, Guid insigniaNoteId) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "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 .Include(x => x.InsigniaNoteProfiles) //.ThenInclude(x => x.Profile) @@ -2249,6 +2255,12 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPut("preview/invoice/{insigniaNoteId:length(36)}"), DisableRequestSizeLimit] public async Task> PreviewInvoiceProfile([FromForm] ImportFileRequest req, Guid insigniaNoteId) { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "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 .Include(x => x.InsigniaNoteProfiles) //.ThenInclude(x => x.Profile) From f5130a4c3c4490442ee6cf728a0c2b6730acb191 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 26 Sep 2024 09:16:15 +0700 Subject: [PATCH 15/19] =?UTF-8?q?fix=20=E0=B8=81=E0=B8=A3=E0=B8=93?= =?UTF-8?q?=E0=B8=B5=E0=B9=80=E0=B8=A3=E0=B8=B5=E0=B8=A2=E0=B8=81=E0=B9=83?= =?UTF-8?q?=E0=B8=8A=E0=B9=89=20api=20=E0=B8=A1=E0=B8=B2=E0=B8=81=E0=B8=81?= =?UTF-8?q?=E0=B8=A7=E0=B9=88=E0=B8=B2=201=20=E0=B9=80=E0=B8=A1=E0=B8=99?= =?UTF-8?q?=E0=B8=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/InsigniaPeriodController.cs | 23 ++++++++++++++++--- .../Controllers/InsigniaRequestController.cs | 23 ++++++++++++++++--- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/BMA.EHR.Insignia/Controllers/InsigniaPeriodController.cs b/BMA.EHR.Insignia/Controllers/InsigniaPeriodController.cs index baf7b1f7..fae42a5f 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaPeriodController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaPeriodController.cs @@ -65,10 +65,27 @@ namespace BMA.EHR.Insignia.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet()] - public async Task> GetList() + [HttpGet("{path}")] + public async Task> GetList(string path) { - var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_ROUND"); + path = path.Trim().ToUpper(); + string getPermission = string.Empty; + if (path == "ROUND") + { + getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_ROUND"); + } + else if (path == "MANAGE") + { + getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_MANAGE"); + } + else if (path == "REPORT") + { + getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_REPORT"); + } + else + { + getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_ROUND"); + } 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 fa05b5d4..a24ba38b 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -1353,10 +1353,27 @@ namespace BMA.EHR.Insignia.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet("note")] - public async Task> GetListNote() + [HttpGet("note/{path}")] + public async Task> GetListNote(string path) { - var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_RECORD"); + path = path.Trim().ToUpper(); + string getPermission = string.Empty; + if (path == "RECORD") + { + getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_RECORD"); + } + else if (path == "ALLOCATE") + { + getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_ALLOCATE"); + } + else if (path == "BORROW") + { + getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_BORROW"); + } + else + { + getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_RECORD"); + } var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { From e030d54b9a54d4f559c50afe2fdf15833339e44b Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 26 Sep 2024 17:24:29 +0700 Subject: [PATCH 16/19] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20revisionId=20=E0=B9=81=E0=B8=A5=E0=B8=B0=E0=B9=81?= =?UTF-8?q?=E0=B8=81=E0=B9=89=E0=B8=95=E0=B8=A3=E0=B8=A7=E0=B8=88=E0=B8=AA?= =?UTF-8?q?=E0=B8=B4=E0=B8=97=E0=B8=98=E0=B8=B4=E0=B9=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BMA.EHR.Insignia/Controllers/InsigniaPeriodController.cs | 4 +++- BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/BMA.EHR.Insignia/Controllers/InsigniaPeriodController.cs b/BMA.EHR.Insignia/Controllers/InsigniaPeriodController.cs index fae42a5f..3a9f3c6d 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaPeriodController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaPeriodController.cs @@ -65,7 +65,7 @@ namespace BMA.EHR.Insignia.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet("{path}")] + [HttpGet()] public async Task> GetList(string path) { path = path.Trim().ToUpper(); @@ -107,6 +107,7 @@ namespace BMA.EHR.Insignia.Service.Controllers period_year = p.Year, period_isActive = p.IsActive, period_doc = p.ReliefDoc == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ReliefDoc.Id, + period_revision = p.RevisionId, }) .ToListAsync(); var data = new List(); @@ -124,6 +125,7 @@ namespace BMA.EHR.Insignia.Service.Controllers period_year = insigniaPeriod.period_year, period_isActive = insigniaPeriod.period_isActive, period_doc = insigniaPeriod.period_doc == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaPeriod.period_doc), + period_revision = insigniaPeriod.period_revision, }; data.Add(_data); } diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index a24ba38b..3559ae03 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -1353,7 +1353,7 @@ namespace BMA.EHR.Insignia.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet("note/{path}")] + [HttpGet("note")] public async Task> GetListNote(string path) { path = path.Trim().ToUpper(); From c842aad1e9653c925444f1359cfc7da7f8eb57c9 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 26 Sep 2024 17:26:39 +0700 Subject: [PATCH 17/19] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20noti?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/MessageQueue/NotificationRepository.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs index 0f4b89d8..717069ce 100644 --- a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs +++ b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs @@ -97,12 +97,12 @@ namespace BMA.EHR.Application.Repositories.MessageQueue }).ToList(); var data_opens = await _dbContext.Set() - .Where(x => x.KeycloakUserId == UserId) + .Where(x => x.ReceiverUserId == Guid.Parse(profileId)) .Where(x => x.DeleteDate == null) .OrderByDescending(x => x.ReceiveDate) .Skip((page - 1) * pageSize) .Take(pageSize) - .Where(x => x.IsOpen == false) + // .Where(x => x.IsOpen == false) .ToListAsync(); foreach (var data_open in data_opens) { From 0c80c69b1234805eaf1657de6049b18fcdf629c4 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 27 Sep 2024 17:42:03 +0700 Subject: [PATCH 18/19] =?UTF-8?q?fix=20=E0=B9=80=E0=B8=84=E0=B8=A3?= =?UTF-8?q?=E0=B8=B7=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 รายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ From 04b20e49c9daa86227ad4d78ef594cb0bf3c3dfb Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 27 Sep 2024 17:42:59 +0700 Subject: [PATCH 19/19] =?UTF-8?q?fix=20=E0=B9=83=E0=B8=9A=E0=B8=AA?= =?UTF-8?q?=E0=B8=A1=E0=B8=B1=E0=B8=84=E0=B8=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reports/CandidateReportRepository.cs | 54 ++++---- .../Controllers/CandidateReportController.cs | 128 +++++++++++++----- 2 files changed, 120 insertions(+), 62 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs index bf82f92e..b6932574 100644 --- a/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs @@ -88,38 +88,38 @@ namespace BMA.EHR.Application.Repositories.Reports { p.Id, AvatarId = p.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ProfileImg.Id, - ExamIdenNumber = p.ExamIdenNumber == null ? "-" : p.ExamIdenNumber, - PositionName = p.PositionExam == null ? "-" : p.PositionExam.PositionName, - PositionLevelName = p.PositionExam == null ? "-" : p.PositionExam.PositionLevelName, - PeriodExamName = p.PeriodExam == null ? "-" : p.PeriodExam.Name, - PeriodExamRound = p.PeriodExam == null ? "-" : p.PeriodExam.Round.ToString(), - PeriodExamYear = p.PeriodExam == null ? "-" : (p.PeriodExam.Year + 543).ToString(), + ExamIdenNumber = p.ExamIdenNumber == null ? "-" : p.ExamIdenNumber.ToThaiNumber(), + PositionName = p.PositionExam == null ? "-" : p.PositionExam.PositionName.ToThaiNumber(), + PositionLevelName = p.PositionExam == null ? "-" : p.PositionExam.PositionLevelName.ToThaiNumber(), + PeriodExamName = p.PeriodExam == null ? "-" : p.PeriodExam.Name.ToThaiNumber(), + PeriodExamRound = p.PeriodExam == null ? "-" : p.PeriodExam.Round.ToString().ToThaiNumber(), + PeriodExamYear = p.PeriodExam == null ? "-" : (p.PeriodExam.Year + 543).ToString().ToThaiNumber(), FullName = $"{p.PrefixName}{p.FirstName} {p.LastName}", Religion = p.ReligionName == null ? "-" : p.ReligionName, Nationality = p.Nationality == null ? "-" : p.Nationality, - DateOfBirth = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.ToThaiFullDate2(), - Age = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.CalculateAgeStrV2(0, 0), - CitizenId = p.CitizenId == null ? "-" : p.CitizenId, + DateOfBirth = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.ToThaiFullDate2().ToThaiNumber(), + Age = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.CalculateAgeStrV2(0, 0).ToThaiNumber(), + CitizenId = p.CitizenId == null ? "-" : p.CitizenId.ToThaiNumber(), - EducationLevelExamName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelExamName, + EducationLevelExamName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelExamName.ToThaiNumber(), EducationName = p.Educations.FirstOrDefault() == null ? null : (p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาตรี" || p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาโท" || p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาเอก" ? p.Educations.FirstOrDefault().EducationName : null), - EducationMajor = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationMajor, + EducationMajor = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationMajor.ToThaiNumber(), EducationLocation = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLocation, - EducationEndDate = p.Educations.FirstOrDefault() == null || p.Educations.FirstOrDefault().EducationEndDate == null ? "-" : p.Educations.FirstOrDefault().EducationEndDate.Value.ToThaiFullDate2(), - EducationScores = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationScores, + EducationEndDate = p.Educations.FirstOrDefault() == null || p.Educations.FirstOrDefault().EducationEndDate == null ? "-" : p.Educations.FirstOrDefault().EducationEndDate.Value.ToThaiFullDate2().ToThaiNumber(), + EducationScores = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationScores.ToThaiNumber(), EducationType = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationType, EducationLevelHighName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelHighName, OccupationPositionType = p.OccupationPositionType == "other" ? "ผู้ปฏิบัติงานอื่นในกรุงเทพมหานคร" : (p.OccupationPositionType == "temp" ? "ลูกจ้างชั่วคราว" : (p.OccupationPositionType == "prem" ? "ลูกจ้างประจำ" : "-")), OccupationPosition = p.OccupationPosition == null ? "-" : p.OccupationPosition, - OccupationSalary = p.OccupationSalary == null ? "-" : p.OccupationSalary.ToString(), + OccupationSalary = p.OccupationSalary == null ? "-" : p.OccupationSalary.Value.ToString("N0").ToThaiNumber(), OccupationGroup = p.OccupationGroup == null ? "-" : p.OccupationGroup, OccupationPile = p.OccupationPile == null ? "-" : p.OccupationPile, OccupationOrg = p.OccupationOrg == null ? "-" : p.OccupationOrg, - OccupationTelephone = p.OccupationTelephone == null ? "-" : p.OccupationTelephone, + OccupationTelephone = p.OccupationTelephone == null ? "-" : p.OccupationTelephone.ToThaiNumber(), - CareersTotal = sb.ToString(), + CareersTotal = sb.ToString().ToThaiNumber(), // Careers = p.Careers.Select(y => new // { // Position = y.Position, @@ -129,24 +129,24 @@ namespace BMA.EHR.Application.Repositories.Reports // RangeDate = y.RangeDate, // }).ToList(), - RegistAddress = p.RegistAddress == null ? "-" : p.RegistAddress, + RegistAddress = p.RegistAddress == null ? "-" : p.RegistAddress.ToThaiNumber(), RegistProvinceName = p.RegistProvinceName == null ? "-" : p.RegistProvinceName, RegistDistrictName = p.RegistDistrictName == null ? "-" : p.RegistDistrictName, RegistSubDistrictName = p.RegistSubDistrictName == null ? "-" : p.RegistSubDistrictName, - RegistZipCode = p.RegistZipCode == null ? "-" : p.RegistZipCode, - CurrentAddress = p.CurrentAddress == null ? (p.RegistAddress == null ? "-" : p.RegistAddress) : p.CurrentAddress, + RegistZipCode = p.RegistZipCode == null ? "-" : p.RegistZipCode.ToThaiNumber(), + CurrentAddress = p.CurrentAddress == null ? (p.RegistAddress == null ? "-" : p.RegistAddress.ToThaiNumber()) : p.CurrentAddress.ToThaiNumber(), CurrentProvinceName = p.CurrentProvinceName == null ? (p.RegistProvinceName == null ? "-" : p.RegistProvinceName) : p.CurrentProvinceName, CurrentDistrictName = p.CurrentDistrictName == null ? (p.RegistDistrictName == null ? "-" : p.RegistDistrictName) : p.CurrentDistrictName, CurrentSubDistrictName = p.CurrentSubDistrictName == null ? (p.RegistSubDistrictName == null ? "-" : p.RegistSubDistrictName) : p.CurrentSubDistrictName, - CurrentZipCode = p.CurrentZipCode == null ? (p.RegistZipCode == null ? "-" : p.RegistZipCode) : p.CurrentZipCode, - Telephone = p.Telephone == null ? "-" : p.Telephone, + CurrentZipCode = p.CurrentZipCode == null ? (p.RegistZipCode == null ? "-" : p.RegistZipCode.ToThaiNumber()) : p.CurrentZipCode.ToThaiNumber(), + Telephone = p.Telephone == null ? "-" : p.Telephone.ToThaiNumber(), Email = p.Email == null ? "-" : p.Email, ContactFullName = $"{p.ContactPrefixName}{p.ContactFirstname} {p.ContactLastname}", ContactRelations = p.ContactRelations == null ? "-" : p.ContactRelations, - ContactTel = p.ContactTel == null ? "-" : p.ContactTel, + ContactTel = p.ContactTel == null ? "-" : p.ContactTel.ToThaiNumber(), - RegisterDate = p.RegisterDate == null ? "-" : p.RegisterDate.Value.ToThaiFullDate(), + RegisterDate = p.RegisterDate == null ? "-" : p.RegisterDate.Value.ToThaiFullDate().ToThaiNumber(), }) .FirstOrDefaultAsync(); if (data == null) @@ -176,10 +176,10 @@ namespace BMA.EHR.Application.Repositories.Reports { Position = item.Position, Type = item.Type, - DurationStart = item.DurationStart, - DurationEnd = item.DurationEnd, - RangeDate = item.RangeDate, - Index = retVal, + DurationStart = item.DurationStart.ToThaiNumber(), + DurationEnd = item.DurationEnd.ToThaiNumber(), + RangeDate = item.RangeDate.ToThaiNumber(), + Index = retVal.ToString().ToThaiNumber(), }; data.Add(_data); retVal++; diff --git a/BMA.EHR.Report.Service/Controllers/CandidateReportController.cs b/BMA.EHR.Report.Service/Controllers/CandidateReportController.cs index b825ee69..9952d6d0 100644 --- a/BMA.EHR.Report.Service/Controllers/CandidateReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/CandidateReportController.cs @@ -52,47 +52,105 @@ namespace BMA.EHR.Report.Service.Controllers var avatar = await _service.GetExamAvatarCandidateAsync(Id); if (candidate != null) { - var mimeType = ""; - switch (exportType.Trim().ToLower()) - { - case "pdf": mimeType = "application/pdf"; break; - case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; - case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; - } + //var mimeType = ""; + //switch (exportType.Trim().ToLower()) + //{ + // case "pdf": mimeType = "application/pdf"; break; + // case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + // case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + //} - var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"ผลสอบคัดเลือกรายบุคคล.trdp"); - ReportPackager reportPacker = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream); - } - report.DataSource = candidate; + //var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"ผลสอบคัดเลือกรายบุคคล.trdp"); + //ReportPackager reportPacker = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream); + //} + //report.DataSource = candidate; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - tblData.DataSource = careers; + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = careers; - Console.WriteLine("000000"); - if (avatar != Guid.Parse("00000000-0000-0000-0000-000000000000")) - { - try - { - // Get avatar Image - var picContent = await _minIOExamService.DownloadFileAsync(avatar); - var pictureBox = (Telerik.Reporting.PictureBox)report.Items["detailSection1"].Items["picAvatar"]; - pictureBox.Value = Image.FromStream(new MemoryStream(picContent.FileContent)); - } - catch { } - } + //Console.WriteLine("000000"); + //if (avatar != Guid.Parse("00000000-0000-0000-0000-000000000000")) + //{ + // try + // { + // // Get avatar Image + //var picContent = await _minIOExamService.DownloadFileAsync(avatar); + //var pictureBox = (Telerik.Reporting.PictureBox)report.Items["detailSection1"].Items["picAvatar"]; + //pictureBox.Value = Image.FromStream(new MemoryStream(picContent.FileContent)); + // } + // catch { } + //} - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - InstanceReportSource instanceReportSource = new InstanceReportSource() + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report, + //}; + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo); + //return File(result.DocumentBytes, mimeType, $"ใบสมัครสอบคัดเลือก.{exportType.Trim().ToLower()}"); + var mapData = new { - ReportDocument = report, + Id = candidate.GetType().GetProperty("Id").GetValue(candidate), + AvatarId = candidate.GetType().GetProperty("AvatarId").GetValue(candidate), + PeriodExamName = candidate.GetType().GetProperty("PeriodExamName").GetValue(candidate), + PeriodExamRound = candidate.GetType().GetProperty("PeriodExamRound").GetValue(candidate), + PeriodExamYear = candidate.GetType().GetProperty("PeriodExamYear").GetValue(candidate), + PositionName = candidate.GetType().GetProperty("PositionName").GetValue(candidate), + PositionLevelName = candidate.GetType().GetProperty("PositionLevelName").GetValue(candidate), + FullName = candidate.GetType().GetProperty("FullName").GetValue(candidate), + Nationality = candidate.GetType().GetProperty("Nationality").GetValue(candidate), + Religion = candidate.GetType().GetProperty("Religion").GetValue(candidate), + CitizenId = candidate.GetType().GetProperty("CitizenId").GetValue(candidate), + DateOfBirth = candidate.GetType().GetProperty("DateOfBirth").GetValue(candidate), + Age = candidate.GetType().GetProperty("Age").GetValue(candidate), + EducationLevelExamName = candidate.GetType().GetProperty("EducationLevelExamName").GetValue(candidate), + EducationName = candidate.GetType().GetProperty("EducationName").GetValue(candidate), + EducationMajor = candidate.GetType().GetProperty("EducationMajor").GetValue(candidate), + EducationLocation = candidate.GetType().GetProperty("EducationLocation").GetValue(candidate), + EducationEndDate = candidate.GetType().GetProperty("EducationEndDate").GetValue(candidate), + EducationScores = candidate.GetType().GetProperty("EducationScores").GetValue(candidate), + EducationType = candidate.GetType().GetProperty("EducationType").GetValue(candidate), + EducationLevelHighName = candidate.GetType().GetProperty("EducationLevelHighName").GetValue(candidate), + ExamIdenNumber = candidate.GetType().GetProperty("ExamIdenNumber").GetValue(candidate), + OccupationPositionType = candidate.GetType().GetProperty("OccupationPositionType").GetValue(candidate), + OccupationPosition = candidate.GetType().GetProperty("OccupationPosition").GetValue(candidate), + OccupationSalary = candidate.GetType().GetProperty("OccupationSalary").GetValue(candidate), + OccupationGroup = candidate.GetType().GetProperty("OccupationGroup").GetValue(candidate), + OccupationPile = candidate.GetType().GetProperty("OccupationPile").GetValue(candidate), + OccupationOrg = candidate.GetType().GetProperty("OccupationOrg").GetValue(candidate), + OccupationTelephone = candidate.GetType().GetProperty("OccupationTelephone").GetValue(candidate), + CareersTotal = candidate.GetType().GetProperty("CareersTotal").GetValue(candidate), + RegistAddress = candidate.GetType().GetProperty("RegistAddress").GetValue(candidate), + RegistProvinceName = candidate.GetType().GetProperty("RegistProvinceName").GetValue(candidate), + RegistDistrictName = candidate.GetType().GetProperty("RegistDistrictName").GetValue(candidate), + RegistSubDistrictName = candidate.GetType().GetProperty("RegistSubDistrictName").GetValue(candidate), + RegistZipCode = candidate.GetType().GetProperty("RegistZipCode").GetValue(candidate), + CurrentAddress = candidate.GetType().GetProperty("CurrentAddress").GetValue(candidate), + CurrentProvinceName = candidate.GetType().GetProperty("CurrentProvinceName").GetValue(candidate), + CurrentDistrictName = candidate.GetType().GetProperty("CurrentDistrictName").GetValue(candidate), + CurrentSubDistrictName = candidate.GetType().GetProperty("CurrentSubDistrictName").GetValue(candidate), + CurrentZipCode = candidate.GetType().GetProperty("CurrentZipCode").GetValue(candidate), + Telephone = candidate.GetType().GetProperty("Telephone").GetValue(candidate), + Email = candidate.GetType().GetProperty("Email").GetValue(candidate), + ContactFullName = candidate.GetType().GetProperty("ContactFullName").GetValue(candidate), + ContactRelations = candidate.GetType().GetProperty("ContactRelations").GetValue(candidate), + ContactTel = candidate.GetType().GetProperty("ContactTel").GetValue(candidate), + RegisterDate = candidate.GetType().GetProperty("RegisterDate").GetValue(candidate), + Url = "https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg", + Careers = careers, }; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo); - return File(result.DocumentBytes, mimeType, $"ใบสมัครสอบคัดเลือก.{exportType.Trim().ToLower()}"); + + var data = new { + template = "ผลสอบคัดเลือกรายบุคคล", + reportName = "docx-report", + data = mapData + }; + return Success(data); } else {