From fec6cfce98207f3f18a964bf26a4bac5f6597948 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Fri, 19 Apr 2024 12:02:29 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/mapper/ExtApiReportMapper.xml | 88 +++++++++---------- .../api/mapper/ExtApiScenarioReportMapper.xml | 86 ++++++++---------- 2 files changed, 80 insertions(+), 94 deletions(-) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.xml index 2debbcd7d1..8b75cc4a6a 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.xml @@ -25,16 +25,16 @@ - SELECT api_report.* from ( + select distinct ar.id, ar.project_id, @@ -173,20 +173,9 @@ ar.start_time, project.organization_id, - CASE - WHEN ar.integrated = 0 THEN - c.num ELSE ar.id - END AS resourceNum, - - CASE - WHEN ar.integrated = 0 THEN - c.id ELSE ar.id - END AS resourceId, - - CASE - WHEN ar.integrated = 0 THEN - c.NAME ELSE ar.NAME - END AS resourceName, + if(ar.integrated, ar.id, c.num) AS resourceNum, + if(ar.integrated, ar.name,c.name) AS resourceName, + if (ar.integrated,ar.id,c.id ) AS resourceId, t.NAME AS poolName FROM @@ -198,16 +187,16 @@ where ar.test_plan_id = 'NONE' and ar.start_time BETWEEN #{startTime} AND #{endTime} - ) as api_report - where - api_report.project_id IN + + and + ar.project_id IN #{projectId} - and ( api_report.resourceName like concat('%', #{request.keyword},'%') + and ( if(ar.integrated, ar.id, c.num) like concat('%', #{request.keyword},'%') - or api_report.resourceNum like concat('%', #{request.keyword},'%') + or if(ar.integrated, ar.name,c.name) like concat('%', #{request.keyword},'%') ) @@ -215,29 +204,34 @@ select - api_scenario_report.* - from api_scenario_report where api_scenario_report.deleted = false - and api_scenario_report.test_plan_id = 'NONE' + asr.* + from api_scenario_report asr where asr.deleted = false + and asr.test_plan_id = 'NONE' and ( - api_scenario_report.name like concat('%', #{request.keyword},'%') + asr.name like concat('%', #{request.keyword},'%') ) - and api_scenario_report.project_id = #{request.projectId} + and asr.project_id = #{request.projectId} @@ -41,16 +41,16 @@