From 89c2b0da8fec50bac7a43cdfe5d5c54c16b98f59 Mon Sep 17 00:00:00 2001 From: dev02 Date: Fri, 11 Nov 2022 10:12:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=90=9C=E5=B0=8B=E5=95=8F?= =?UTF-8?q?=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/GraphManageController.cs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/FrontendWebApi/ApiControllers/GraphManageController.cs b/FrontendWebApi/ApiControllers/GraphManageController.cs index 7d93b4b..693c263 100644 --- a/FrontendWebApi/ApiControllers/GraphManageController.cs +++ b/FrontendWebApi/ApiControllers/GraphManageController.cs @@ -10,6 +10,7 @@ using System.Linq; using Repository.BackendRepository.Interface; using Repository.FrontendRepository.Interface; using System.IO; +using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource; namespace FrontendWebApi.ApiControllers { @@ -98,28 +99,27 @@ namespace FrontendWebApi.ApiControllers List graManList = new List(); try { - var sqlString = @$"SELECT gm.* + var param = new { @graph_manage_layer1 = graph_manage_layer1, @graph_manage_layer2 = graph_manage_layer2, @sub_system_tag = gi.sub_system_tag, @main_system_tag = gi.main_system_tag }; + if (gi.keyWord != null && !string.IsNullOrEmpty(gi.keyWord)) + { + graManList = await backendRepository.GetAllAsync(@$"SELECT gm.* + FROM graph_manage gm + JOIN variable v1 ON v1.system_value = @main_system_tag and v1.system_type = @graph_manage_layer1 and v1.deleted = 0 AND convert(v1.system_value, nchar) = gm.main_system_tag + JOIN variable v2 ON v1.id = v2.system_parent_id AND v2.system_type = @graph_manage_layer2 AND v2.deleted = 0 and convert(v2.system_value, nchar) = gm.sub_system_tag + WHERE v2.system_value in @sub_system_tag AND gm.deleted = 0 + AND (gm.code like '%{gi.keyWord}%' OR gm.name like '%{gi.keyWord}%' OR gm.oriOrgName like '%{gi.keyWord}%' OR gm.donOrgName like '%{gi.keyWord}%') + ORDER BY gm.priority, gm.created_at desc", param); + } + else + { + var sqlString = @$"SELECT gm.* FROM graph_manage gm JOIN variable v1 ON v1.system_value = @main_system_tag and v1.system_type = @graph_manage_layer1 and v1.deleted = 0 AND convert(v1.system_value, nchar) = gm.main_system_tag JOIN variable v2 ON v1.id = v2.system_parent_id AND v2.system_type = @graph_manage_layer2 AND v2.deleted = 0 AND convert(v2.system_value, nchar) = gm.sub_system_tag WHERE v2.system_value in @sub_system_tag AND gm.deleted = 0 ORDER BY gm.priority, gm.created_at desc"; - - var param = new { @graph_manage_layer1 = graph_manage_layer1, graph_manage_layer2 = graph_manage_layer2, @sub_system_tag = gi.sub_system_tag, @main_system_tag = gi.main_system_tag }; - - graManList = await backendRepository.GetAllAsync(sqlString, param); - - if (gi.keyWord != null) - { - var wParam = new { @graph_manage_layer1 = graph_manage_layer1, graph_manage_layer2 = graph_manage_layer2, @sub_system_tag = gi.sub_system_tag, @main_system_tag = gi.main_system_tag, @keyWord = gi.keyWord }; - graManList = await backendRepository.GetAllAsync(@$"SELECT gm.* - FROM graph_manage gm - JOIN variable v1 ON v1.system_value = @main_system_tag and v1.system_type = @graph_manage_layer1 and v1.deleted = 0 AND convert(v1.system_value, nchar) = gm.main_system_tag - JOIN variable v2 ON v1.id = v2.system_parent_id AND v2.system_type = @graph_manage_layer2 AND v2.deleted = 0 and convert(v2.system_value, nchar) = gm.sub_system_tag - WHERE v2.system_value in @sub_system_tag AND gm.deleted = 0 - AND (code like '%@keyWord%' OR name like '%@keyWord%' OR oriOrgName like '%@keyWord%' OR donOrgName like '%@keyWord%') - ORDER BY gm.priority, gm.created_at desc", wParam); + graManList = await backendRepository.GetAllAsync(sqlString, param); } apiResult.Code = "0000";