diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml
index 5e147b6acc..cb3236a1bb 100644
--- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml
+++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml
@@ -78,9 +78,9 @@
and (test_case.tags is null or test_case.tags
-
-
-
+
+
+
)
@@ -109,36 +109,39 @@
and test_case.id in (
- select resource_id from custom_field_test_case where field_id = #{custom.id}
-
-
- and JSON_CONTAINS(`value`, #{custom.value})
-
-
- and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13)
-
-
-
-
-
- and text_value
-
-
-
-
-
- and trim(both '"' from value)
-
-
-
-
-
+ select resource_id from custom_field_test_case where field_id = #{custom.id}
+
+
+ and JSON_CONTAINS(`value`, #{custom.value})
+
+
+ and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13)
+
+
+
+
+
+ and text_value
+
+
+
+
+
+ and trim(both '"' from value)
+
+
+
+
+
)
- update test_case set custom_num = num where (custom_num is null or custom_num = '') and project_id = #{projectId}
+ update test_case
+ set custom_num = num
+ where (custom_num is null or custom_num = '')
+ and project_id = #{projectId}
@@ -580,9 +589,9 @@
and test_case.id in (
- select resource_id from custom_field_test_case where concat('custom',field_id) = #{key}
- and trim(both '"' from value) in
-
+ select resource_id from custom_field_test_case where concat('custom',field_id) = #{key}
+ and trim(both '"' from value) in
+
)
@@ -657,10 +666,28 @@
- and test_case.id not in (select distinct test_case_test.test_case_id from test_case_test)
+ and test_case.id not in (
+ SELECT test_case_id FROM test_case_test WHERE test_type = 'testCase' and test_id IN (select id FROM
+ api_test_case WHERE `STATUS` is null or status != 'Trash')
+ UNION
+ SELECT test_case_id FROM test_case_test WHERE test_type = 'performance' and test_id IN (select id from
+ load_test)
+ UNION
+ SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM
+ api_scenario WHERE `STATUS` != 'Trash')
+ )
- and test_case.id in (select distinct test_case_test.test_case_id from test_case_test)
+ and test_case.id in (
+ SELECT test_case_id FROM test_case_test WHERE test_type = 'testCase' and test_id IN (select id FROM
+ api_test_case WHERE `STATUS` is null or status != 'Trash')
+ UNION
+ SELECT test_case_id FROM test_case_test WHERE test_type = 'performance' and test_id IN (select id from
+ load_test)
+ UNION
+ SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM
+ api_scenario WHERE `STATUS` != 'Trash')
+ )
@@ -733,44 +760,94 @@
SELECT test_case.priority as groupField, count(DISTINCT ref_id) AS countNumber
FROM test_case
WHERE project_id = #{projectId}
- AND test_case.status != 'Trash'
+ AND test_case.status != 'Trash'
and latest = true
GROUP BY test_case.priority
- SELECT count(DISTINCT ref_id) AS countNumber FROM test_case WHERE test_case.project_id = #{projectId} and test_case.status != 'Trash' and latest = 1
- AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
+ SELECT count(DISTINCT ref_id) AS countNumber
+ FROM test_case
+ WHERE test_case.project_id = #{projectId}
+ and test_case.status != 'Trash' and latest = 1
+ AND create_time BETWEEN #{firstDayTimestamp}
+ AND #{lastDayTimestamp}
- SELECT review_status AS groupField,count(id) AS countNumber FROM test_case
- WHERE project_id = #{projectId} and test_case.status != 'Trash' and latest = 1
+ SELECT review_status AS groupField, count(id) AS countNumber
+ FROM test_case
+ WHERE project_id = #{projectId}
+ and test_case.status != 'Trash' and latest = 1
GROUP BY test_case.review_status
- SELECT test_case_test.test_type AS groupField, count(test_case_test.test_case_id) AS countNumber
- FROM test_case join test_case_test on test_case.id = test_case_test.test_case_id
- WHERE test_case.project_id = #{projectId} and test_case.status != 'Trash' and latest = 1 GROUP BY test_case_test.test_type
+ SELECT test_case_test.test_type AS groupField,
+ count(test_case_test.test_case_id) AS countNumber
+ FROM test_case
+ INNER JOIN (SELECT test_case_id, test_id, test_type
+ FROM test_case_test
+ WHERE test_type = 'testCase'
+ and test_id IN (select id FROM api_test_case WHERE `STATUS` is null or status != 'Trash')
+ UNION
+ SELECT test_case_id, test_id, test_type
+ FROM test_case_test
+ WHERE test_type = 'performance'
+ and test_id IN (select id from load_test)
+ UNION
+ SELECT test_case_id, test_id, test_type
+ FROM test_case_test
+ WHERE test_type = 'automation'
+ and test_id IN (select id FROM api_scenario WHERE `STATUS` != 'Trash')
+ )
+ test_case_test
+ ON test_case.id = test_case_test.test_case_id
+ WHERE
+ test_case.project_id = #{projectId}
+ AND test_case.STATUS != 'Trash'
+ AND latest = 1
+ GROUP BY
+ test_case_test.test_type
- SELECT count(distinct test_case.ref_id) AS countNumber FROM test_case join test_case_test on test_case.id = test_case_test.test_case_id
- WHERE test_case.project_id = #{projectId} and test_case.status != 'Trash' and latest = 1
- AND test_case_test.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
+ SELECT count(distinct test_case.ref_id) AS countNumber
+ FROM test_case
+ join test_case_test on test_case.id = test_case_test.test_case_id
+ WHERE test_case.project_id = #{projectId}
+ and test_case.status != 'Trash' and latest = 1
+ AND test_case_test.create_time BETWEEN #{firstDayTimestamp}
+ AND #{lastDayTimestamp}
- select count(test_case.id) from test_case where test_case.project_id = #{projectId} and test_case.status != 'Trash' and latest = 1
- and test_case.id in (select distinct test_case_test.test_case_id from test_case_test)
+ select count(test_case.id)
+ from test_case
+ where test_case.project_id = #{projectId}
+ and test_case.status != 'Trash' and latest = 1
+ and test_case.id in (
+ SELECT test_case_id FROM test_case_test WHERE test_type = 'testCase' and test_id IN (select id FROM
+ api_test_case WHERE `STATUS` is null or status != 'Trash')
+ UNION
+ SELECT test_case_id FROM test_case_test WHERE test_type = 'performance' and test_id IN (select id from load_test)
+ UNION
+ SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM
+ api_scenario WHERE `STATUS` != 'Trash')
+ )
- select count(tc.id) as countNumber, user.name as groupField from test_case tc right join user on tc.maintainer = user.id
- where tc.project_id = #{projectId} and tc.status != 'Trash' and tc.latest = 1
+ select count(tc.id) as countNumber, user.name as groupField
+ from test_case tc
+ right join user on tc.maintainer = user.id
+ where tc.project_id = #{projectId}
+ and tc.status != 'Trash' and tc.latest = 1
group by tc.maintainer
- select count(tc.id) as countNumber, user.name as groupField from test_case tc right join user on tc.maintainer = user.id
- where tc.project_id = #{projectId} and tc.status != 'Trash' and tc.latest = 1 and tc.id in (select distinct test_case_test.test_case_id from test_case_test)
+ select count(tc.id) as countNumber, user.name as groupField
+ from test_case tc
+ right join user on tc.maintainer = user.id
+ where tc.project_id = #{projectId}
+ and tc.status != 'Trash' and tc.latest = 1 and tc.id in (select distinct test_case_test.test_case_id from test_case_test)
group by tc.maintainer
@@ -788,50 +865,57 @@
select count(s)
- from (
- select tptc.id as s
- from test_plan_test_case tptc join test_case on tptc.case_id = test_case.id
- where tptc.plan_id = #{planId} and (test_case.status != 'Trash' or test_case.status is null)
+ from (select tptc.id as s
+ from test_plan_test_case tptc
+ join test_case on tptc.case_id = test_case.id
+ where tptc.plan_id = #{planId}
+ and (test_case.status != 'Trash' or test_case.status is null)
- union all
+ union all
- select tpas.id as s
- from test_plan_api_scenario tpas join api_scenario on tpas.api_scenario_id = api_scenario.id
- where tpas.test_plan_id = #{planId} and (api_scenario.status != 'Trash' or api_scenario.status is null)
+ select tpas.id as s
+ from test_plan_api_scenario tpas
+ join api_scenario on tpas.api_scenario_id = api_scenario.id
+ where tpas.test_plan_id = #{planId}
+ and (api_scenario.status != 'Trash' or api_scenario.status is null)
- union all
+ union all
- select tpac.id as s
- from test_plan_api_case tpac join api_test_case on tpac.api_case_id = api_test_case.id
- join api_definition on api_test_case.api_definition_id = api_definition.id
- where tpac.test_plan_id = #{planId} and (api_definition.status != 'Trash' or api_definition.status is null)
+ select tpac.id as s
+ from test_plan_api_case tpac
+ join api_test_case on tpac.api_case_id = api_test_case.id
+ join api_definition on api_test_case.api_definition_id = api_definition.id
+ where tpac.test_plan_id = #{planId}
+ and (api_definition.status != 'Trash' or api_definition.status is null)
- union all
+ union all
- select tplc.id as s
- from test_plan_load_case tplc join load_test on tplc.load_case_id = load_test.id
- where tplc.test_plan_id = #{planId}
- ) as temp
+ select tplc.id as s
+ from test_plan_load_case tplc
+ join load_test on tplc.load_case_id = load_test.id
+ where tplc.test_plan_id = #{planId}) as temp
select count(s)
- from (
- select id as s
- from test_plan_test_case tptc
- where tptc.plan_id = #{planId} and tptc.status = 'Pass'
- union all
- select id as s
- from test_plan_api_scenario tpas
- where tpas.test_plan_id = #{planId} and tpas.last_result = 'Success'
- union all
- select id as s
- from test_plan_api_case tpac
- where tpac.test_plan_id = #{planId} and tpac.status = 'success'
- union all
- select id as s
- from test_plan_load_case tplc
- where tplc.test_plan_id = #{planId} and tplc.status = 'success'
- ) as temp
+ from (select id as s
+ from test_plan_test_case tptc
+ where tptc.plan_id = #{planId}
+ and tptc.status = 'Pass'
+ union all
+ select id as s
+ from test_plan_api_scenario tpas
+ where tpas.test_plan_id = #{planId}
+ and tpas.last_result = 'Success'
+ union all
+ select id as s
+ from test_plan_api_case tpac
+ where tpac.test_plan_id = #{planId}
+ and tpac.status = 'success'
+ union all
+ select id as s
+ from test_plan_load_case tplc
+ where tplc.test_plan_id = #{planId}
+ and tplc.status = 'success') as temp
@@ -894,13 +978,19 @@
- select id, prerequisite, steps, step_description, expected_result, step_model from test_case where id = #{id}
+ select id, prerequisite, steps, step_description, expected_result, step_model
+ from test_case
+ where id = #{id}
- select DISTINCT project_id from test_case;
+ select DISTINCT project_id
+ from test_case;
- select id from test_case where project_id = #{projectId} order by update_time ASC;
+ select id
+ from test_case
+ where project_id = #{projectId}
+ order by update_time ASC;
@@ -934,7 +1024,8 @@
project_version.id versionId
FROM
test_case AS test_case
- inner join project_version on project_version.project_id = test_case.project_id and project_version.id = test_case.version_id
+ inner join project_version on project_version.project_id = test_case.project_id and project_version.id =
+ test_case.version_id
@@ -961,27 +1052,27 @@
update test_case
set original_status=status,
- status = 'Trash',
- delete_time = #{request.deleteTime},
- delete_user_id = #{request.deleteUserId}
+ status = 'Trash',
+ delete_time = #{request.deleteTime},
+ delete_user_id = #{request.deleteUserId}
where ref_id in (
- select a.ref_id from (
- select ref_id from test_case
+ select a.ref_id from (
+ select ref_id from test_case
-
-
- id = #{request.id}
-
-
- and id in
-
- #{id}
-
-
-
+
+
+ id = #{request.id}
+
+
+ and id in
+
+ #{id}
+
+
+
- ) a
- )
+ ) a
+ )
@@ -992,7 +1083,7 @@
ref_id =#{request.refId}
- and version_id =#{request.versionId}
+ and version_id =#{request.versionId}
@@ -1027,21 +1118,17 @@
select count(distinct ref_id)
from test_case
- where project_id in (
- select id
- from project
- where workspace_id = #{workSpaceId})
+ where project_id in (select id
+ from project
+ where workspace_id = #{workSpaceId})
and case_public = true
and test_case.status != 'Trash'
- SELECT
- count(DISTINCT ref_id)
- FROM
- test_case
- WHERE
- project_id = #{projectId}
+ SELECT count(DISTINCT ref_id)
+ FROM test_case
+ WHERE project_id = #{projectId}
AND STATUS = 'Trash'
@@ -1060,12 +1147,10 @@
SELECT DISTINCT ref_id
FROM test_case
- WHERE ref_id NOT IN (
- SELECT DISTINCT ref_id
- FROM test_case
- WHERE version_id = #{versionId}
- AND project_id = #{projectId}
- )
+ WHERE ref_id NOT IN (SELECT DISTINCT ref_id
+ FROM test_case
+ WHERE version_id = #{versionId}
+ AND project_id = #{projectId})
AND project_id = #{projectId}
@@ -1087,8 +1172,8 @@
select id, custom_fields
from test_case
- where project_id = #{projectId}
- limit #{offset},#{pageSize}
+ where project_id = #{projectId} limit #{offset}
+ , #{pageSize}