From 9637fcee9f27e6fdcb9e242d7c938afb0b9d213b Mon Sep 17 00:00:00 2001 From: dev02 Date: Mon, 12 Dec 2022 16:09:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9C=96=E8=B3=87=E9=A1=9E?= =?UTF-8?q?=E5=88=A5crud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/GraphManageController.cs | 27 ++++++++++ .../ApiControllers/UserController.cs | 49 ++++++++++++------- FrontendWebApi/Models/MyBase.cs | 1 + 3 files changed, 59 insertions(+), 18 deletions(-) diff --git a/FrontendWebApi/ApiControllers/GraphManageController.cs b/FrontendWebApi/ApiControllers/GraphManageController.cs index 9c08634..ac7f6de 100644 --- a/FrontendWebApi/ApiControllers/GraphManageController.cs +++ b/FrontendWebApi/ApiControllers/GraphManageController.cs @@ -93,6 +93,33 @@ namespace FrontendWebApi.ApiControllers } + [HttpPost] + public async Task>> VarList() + { + ApiResult> apiResult = new ApiResult>(); + List variables = new List(); + + try + { + var sqlString = @$"select * from variable + where system_type like 'graph_manage_layer%' and deleted = 0 + order by id asc"; + + variables = await backendRepository.GetAllAsync(sqlString); + + apiResult.Code = "0000"; + apiResult.Data = variables; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + [HttpPost] public async Task>> GraManList([FromBody] GraphInfo gi) { diff --git a/FrontendWebApi/ApiControllers/UserController.cs b/FrontendWebApi/ApiControllers/UserController.cs index 6b67b11..d194630 100644 --- a/FrontendWebApi/ApiControllers/UserController.cs +++ b/FrontendWebApi/ApiControllers/UserController.cs @@ -46,7 +46,7 @@ namespace FrontendWebApi.ApiControllers /// /// [HttpPost] - public async Task>> UserManagerList() + public async Task>> UserManagerList([FromBody] UserManagerList post) { ApiResult> apiResult = new ApiResult>(); List userManagerList = new List(); @@ -56,8 +56,21 @@ namespace FrontendWebApi.ApiControllers var sqlString = @$"SELECT A.userinfo_guid, A.full_name, B.full_name AS 'Role_full_name', A.email, A.phone, A.created_at,A.Account ,B.layer FROM userinfo A LEFT JOIN role B ON A.role_guid=B.role_guid AND B.deleted='0' - WHERE A.deleted = 0 - ORDER BY A.created_at DESC"; + WHERE A.deleted = 0 "; + + if (post != null) + { + if (post.Full_name != null) + sqlString += $@" and A.full_name like '%{post.Full_name}%'"; + + if (post.Role_full_name != null) + sqlString += $@" and B.full_name like '%{post.Role_full_name}%'"; + + if (post.Status != null) + sqlString += $@" and A.status = '{post.Status}'"; + } + + sqlString += " ORDER BY A.created_at DESC"; userManagerList = await backendRepository.GetAllAsync(sqlString); apiResult.Code = "0000"; @@ -246,7 +259,7 @@ namespace FrontendWebApi.ApiControllers /// /// [HttpPost] - public async Task> GetOneUser([FromBody] string guid) + public async Task> GetOneUser([FromBody] SaveUserManager post) { ApiResult apiResult = new ApiResult(); @@ -254,7 +267,7 @@ namespace FrontendWebApi.ApiControllers try { - simpleUser = await backendRepository.GetOneAsync("userinfo", $"userinfo_guid='{guid}'"); + simpleUser = await backendRepository.GetOneAsync("userinfo", $"userinfo_guid='{post.Id}'"); if (simpleUser == null) { @@ -271,7 +284,7 @@ namespace FrontendWebApi.ApiControllers { apiResult.Code = "9999"; apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; - Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + guid); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + post.Id); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } return apiResult; @@ -283,7 +296,7 @@ namespace FrontendWebApi.ApiControllers /// /// [HttpPost] - public async Task> DeleteOneUser([FromBody] string guid) + public async Task> DeleteOneUser([FromBody] SaveUserManager post) { ApiResult apiResult = new ApiResult(); @@ -291,7 +304,7 @@ namespace FrontendWebApi.ApiControllers try { - simpleUser = await backendRepository.GetOneAsync("userinfo", $"userinfo_guid='{guid}'"); + simpleUser = await backendRepository.GetOneAsync("userinfo", $"userinfo_guid='{post.Id}'"); if (simpleUser == null) { @@ -300,7 +313,7 @@ namespace FrontendWebApi.ApiControllers return apiResult; } - await backendRepository.DeleteOne(guid, "userinfo", "userinfo_guid"); + await backendRepository.DeleteOne(post.Id, "userinfo", "userinfo_guid"); apiResult.Code = "0000"; apiResult.Msg = "刪除成功"; @@ -309,7 +322,7 @@ namespace FrontendWebApi.ApiControllers { apiResult.Code = "9999"; apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; - Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + guid); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + post.Id); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } @@ -395,7 +408,7 @@ namespace FrontendWebApi.ApiControllers /// /// [HttpPost] - public async Task> GetOneRole([FromBody] string guid) + public async Task> GetOneRole([FromBody] PostRole post) { ApiResult apiResult = new ApiResult(); @@ -403,7 +416,7 @@ namespace FrontendWebApi.ApiControllers try { - simpleRole = await backendRepository.GetOneAsync("role", $"role_guid='{guid}'"); + simpleRole = await backendRepository.GetOneAsync("role", $"role_guid='{post.Id}'"); if (simpleRole == null) { @@ -419,7 +432,7 @@ namespace FrontendWebApi.ApiControllers { apiResult.Code = "9999"; apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; - Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + guid); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + post.Id); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } return apiResult; @@ -431,7 +444,7 @@ namespace FrontendWebApi.ApiControllers /// /// [HttpPost] - public async Task> DeleteOneRole([FromBody] string guid) + public async Task> DeleteOneRole([FromBody] PostRole post) { ApiResult apiResult = new ApiResult(); @@ -439,7 +452,7 @@ namespace FrontendWebApi.ApiControllers try { - simpleRole = await backendRepository.GetOneAsync("role", $"role_guid='{guid}'"); + simpleRole = await backendRepository.GetOneAsync("role", $"role_guid='{post.Id}'"); if (simpleRole == null) { @@ -450,7 +463,7 @@ namespace FrontendWebApi.ApiControllers //檢查是否有使用者為該角色 var sWhere = $@"deleted = 0 AND role_guid = @Guid"; - var userInfos = await backendRepository.GetAllAsync("userinfo", sWhere, new { Guid = guid }); + var userInfos = await backendRepository.GetAllAsync("userinfo", sWhere, new { Guid = post.Id }); if (userInfos.Count > 0) { apiResult.Code = "9997"; @@ -459,7 +472,7 @@ namespace FrontendWebApi.ApiControllers } - await backendRepository.DeleteOne(guid, "role", "role_guid"); + await backendRepository.DeleteOne(post.Id, "role", "role_guid"); apiResult.Code = "0000"; apiResult.Msg = "刪除成功"; @@ -468,7 +481,7 @@ namespace FrontendWebApi.ApiControllers { apiResult.Code = "9999"; apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; - Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + guid); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + post.Id); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } diff --git a/FrontendWebApi/Models/MyBase.cs b/FrontendWebApi/Models/MyBase.cs index 4a7916f..0f64d8f 100644 --- a/FrontendWebApi/Models/MyBase.cs +++ b/FrontendWebApi/Models/MyBase.cs @@ -52,5 +52,6 @@ namespace FrontendWebApi.Models public string System_type { get; set; } public string System_key { get; set; } public string system_value { get; set; } + public int system_parent_id { get; set; } } }