parent
47635c9de0
commit
5eacee9045
|
@ -77,11 +77,12 @@
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, project_id, name,api_definition_id,priority,description, create_user_id, update_user_id, create_time, update_time
|
id
|
||||||
</sql>
|
, project_id, name,api_definition_id,priority,description, create_user_id, update_user_id, create_time, update_time
|
||||||
|
</sql>
|
||||||
<sql id="Blob_Column_List">
|
<sql id="Blob_Column_List">
|
||||||
request
|
request
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.ApiTestCaseExample"
|
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.ApiTestCaseExample"
|
||||||
resultMap="ResultMapWithBLOBs">
|
resultMap="ResultMapWithBLOBs">
|
||||||
select
|
select
|
||||||
|
@ -276,14 +277,15 @@
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectApiCaseInfoByPrimaryKey" resultType="io.metersphere.api.dto.definition.ApiTestCaseInfo">
|
<select id="selectApiCaseInfoByPrimaryKey" resultType="io.metersphere.api.dto.definition.ApiTestCaseInfo">
|
||||||
SELECT
|
SELECT t1.*,
|
||||||
t1.*,
|
a.method AS apiMethod,
|
||||||
a.method AS apiMethod, project_version.name as version_name, project.version_enable
|
project_version.name as version_name,
|
||||||
FROM
|
project.version_enable
|
||||||
api_test_case t1
|
FROM api_test_case t1
|
||||||
inner join api_definition a on t1.api_definition_id = a.id
|
inner join api_definition a on t1.api_definition_id = a.id
|
||||||
LEFT JOIN project_version on a.project_id = project_version.project_id AND project_version.id = t1.version_id
|
LEFT JOIN project_version
|
||||||
LEFT JOIN project on a.project_id = project.id
|
on a.project_id = project_version.project_id AND project_version.id = t1.version_id
|
||||||
|
LEFT JOIN project on a.project_id = project.id
|
||||||
WHERE t1.id = #{0}
|
WHERE t1.id = #{0}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@ -314,25 +316,25 @@
|
||||||
|
|
||||||
<select id="findPassRateByIds" resultType="io.metersphere.api.dto.definition.ParamsDTO">
|
<select id="findPassRateByIds" resultType="io.metersphere.api.dto.definition.ParamsDTO">
|
||||||
SELECT
|
SELECT
|
||||||
t2.resource_id as id,
|
t2.resource_id as id,
|
||||||
CONCAT(
|
CONCAT(
|
||||||
FORMAT(
|
FORMAT(
|
||||||
SUM(
|
SUM(
|
||||||
IF
|
IF
|
||||||
( t2.`status` = 'success', 1, 0 ))/ COUNT( t2.id )* 100,
|
( t2.`status` = 'success', 1, 0 ))/ COUNT( t2.id )* 100,
|
||||||
2
|
2
|
||||||
),
|
),
|
||||||
'%'
|
'%'
|
||||||
) value
|
) value
|
||||||
FROM
|
FROM
|
||||||
api_definition_exec_result t2
|
api_definition_exec_result t2
|
||||||
WHERE
|
WHERE
|
||||||
t2.resource_id IN
|
t2.resource_id IN
|
||||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
GROUP BY
|
GROUP BY
|
||||||
t2.resource_id
|
t2.resource_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="listSimple" resultType="io.metersphere.api.dto.definition.ApiTestCaseDTO">
|
<select id="listSimple" resultType="io.metersphere.api.dto.definition.ApiTestCaseDTO">
|
||||||
|
@ -551,14 +553,15 @@
|
||||||
where c.project_id = #{projectId}
|
where c.project_id = #{projectId}
|
||||||
and c.id not in (
|
and c.id not in (
|
||||||
select pc.api_case_id
|
select pc.api_case_id
|
||||||
from test_plan_api_case pc
|
from test_plan_api_case pc
|
||||||
where pc.test_plan_id = #{planId}
|
where pc.test_plan_id = #{planId}
|
||||||
)
|
)
|
||||||
</select>
|
</select>
|
||||||
<select id="selectIdsNotExistsInReview" resultType="java.lang.String">
|
<select id="selectIdsNotExistsInReview" resultType="java.lang.String">
|
||||||
select c.id
|
select c.id
|
||||||
from api_test_case c
|
from api_test_case c
|
||||||
where c.project_id = #{projectId} and c.id not in (
|
where c.project_id = #{projectId}
|
||||||
|
and c.id not in (
|
||||||
select pc.api_case_id
|
select pc.api_case_id
|
||||||
from test_case_review_api_case pc
|
from test_case_review_api_case pc
|
||||||
where pc.test_case_review_id = #{reviewId}
|
where pc.test_case_review_id = #{reviewId}
|
||||||
|
@ -566,29 +569,40 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="countProtocolByProjectID" resultType="io.metersphere.api.dto.datacount.ApiDataCountResult">
|
<select id="countProtocolByProjectID" resultType="io.metersphere.api.dto.datacount.ApiDataCountResult">
|
||||||
SELECT apiDef.protocol AS groupField,COUNT(testCase.id) AS countNumber FROM api_test_case testCase
|
SELECT apiDef.protocol AS groupField, COUNT(testCase.id) AS countNumber
|
||||||
INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id
|
FROM api_test_case testCase
|
||||||
WHERE testCase.project_id = #{0} AND (testCase.status IS NULL or testCase.status != "Trash") and latest = 1
|
INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id
|
||||||
|
WHERE testCase.project_id = #{0}
|
||||||
|
AND (testCase.status IS NULL or testCase.status != "Trash")
|
||||||
|
and latest = 1
|
||||||
GROUP BY apiDef.protocol
|
GROUP BY apiDef.protocol
|
||||||
</select>
|
</select>
|
||||||
<select id="findApiUrlAndMethodById" resultType="io.metersphere.base.domain.ApiDefinition">
|
<select id="findApiUrlAndMethodById" resultType="io.metersphere.base.domain.ApiDefinition">
|
||||||
SELECT method,path FROM api_definition WHERE id IN (
|
SELECT method, path
|
||||||
SELECT api_definition_id FROM api_test_case WHERE id = #{0}
|
FROM api_definition
|
||||||
|
WHERE id IN (
|
||||||
|
SELECT api_definition_id
|
||||||
|
FROM api_test_case
|
||||||
|
WHERE id = #{0}
|
||||||
)
|
)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="countByProjectIDAndCreateInThisWeek" resultType="java.lang.Long">
|
<select id="countByProjectIDAndCreateInThisWeek" resultType="java.lang.Long">
|
||||||
SELECT count(testCase.id) AS countNumber FROM api_test_case testCase
|
SELECT count(testCase.id) AS countNumber
|
||||||
INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id
|
FROM api_test_case testCase
|
||||||
|
INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id
|
||||||
WHERE testCase.project_id = #{projectId}AND apiDef.status != "Trash"
|
WHERE testCase.project_id = #{projectId}AND apiDef.status != "Trash"
|
||||||
AND testCase.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
|
AND testCase.create_time BETWEEN #{firstDayTimestamp}
|
||||||
|
AND #{lastDayTimestamp}
|
||||||
and latest = 1
|
and latest = 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="moduleCount" resultType="java.lang.Integer">
|
<select id="moduleCount" resultType="java.lang.Integer">
|
||||||
SELECT count(api_test_case.id) FROM api_test_case
|
SELECT count(api_test_case.id) FROM api_test_case
|
||||||
left join project on api_test_case.project_id = project.id
|
inner join project on api_test_case.project_id = project.id
|
||||||
|
inner JOIN api_definition a ON api_test_case.api_definition_id = a.id
|
||||||
<include refid="criCondition"/>
|
<include refid="criCondition"/>
|
||||||
|
and a.latest is not null
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getRequest" resultType="io.metersphere.api.dto.definition.ApiTestCaseInfo">
|
<select id="getRequest" resultType="io.metersphere.api.dto.definition.ApiTestCaseInfo">
|
||||||
|
@ -627,11 +641,12 @@
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM api_test_case
|
FROM api_test_case
|
||||||
WHERE api_test_case.api_definition_id = #{definitionId}
|
WHERE api_test_case.api_definition_id = #{definitionId}
|
||||||
ORDER BY num DESC
|
ORDER BY num DESC LIMIT 1;
|
||||||
LIMIT 1;
|
|
||||||
</select>
|
</select>
|
||||||
<select id="selectEffectiveTestCaseByProjectId" resultType="io.metersphere.base.domain.ApiTestCase">
|
<select id="selectEffectiveTestCaseByProjectId" resultType="io.metersphere.base.domain.ApiTestCase">
|
||||||
select id,api_definition_id from api_test_case where project_id = #{projectId}
|
select id, api_definition_id
|
||||||
|
from api_test_case
|
||||||
|
where project_id = #{projectId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getCannotReductionApiCaseList" resultType="io.metersphere.api.dto.definition.ApiTestCaseDTO">
|
<select id="getCannotReductionApiCaseList" resultType="io.metersphere.api.dto.definition.ApiTestCaseDTO">
|
||||||
|
@ -661,7 +676,8 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectNameById" resultType="java.lang.String">
|
<select id="selectNameById" resultType="java.lang.String">
|
||||||
SELECT testCase.name FROM api_test_case testCase
|
SELECT testCase.name
|
||||||
|
FROM api_test_case testCase
|
||||||
WHERE testCase.id = #{0}
|
WHERE testCase.id = #{0}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@ -754,10 +770,14 @@
|
||||||
<include refid="queryWhereCondition"/>
|
<include refid="queryWhereCondition"/>
|
||||||
</select>
|
</select>
|
||||||
<select id="selectProjectIds" resultType="java.lang.String">
|
<select id="selectProjectIds" resultType="java.lang.String">
|
||||||
select DISTINCT project_id from api_test_case;
|
select DISTINCT project_id
|
||||||
|
from api_test_case;
|
||||||
</select>
|
</select>
|
||||||
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
|
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
|
||||||
select id from api_test_case where project_id = #{projectId} order by update_time ASC;
|
select id
|
||||||
|
from api_test_case
|
||||||
|
where project_id = #{projectId}
|
||||||
|
order by update_time ASC;
|
||||||
</select>
|
</select>
|
||||||
<select id="getPreOrder" resultType="java.lang.Long">
|
<select id="getPreOrder" resultType="java.lang.Long">
|
||||||
select `order` from api_test_case where project_id = #{projectId}
|
select `order` from api_test_case where project_id = #{projectId}
|
||||||
|
@ -832,12 +852,33 @@
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<insert id="insertNewVersionCases">
|
<insert id="insertNewVersionCases">
|
||||||
INSERT INTO api_test_case(id, project_id, name, priority, api_definition_id, description, request, create_user_id,
|
INSERT INTO api_test_case(id, project_id, name, priority, api_definition_id, description, request,
|
||||||
update_user_id, create_time, update_time, num, tags, last_result_id, status, original_status,
|
create_user_id,
|
||||||
delete_time, delete_user_id, version, `order`, case_status, version_id)
|
update_user_id, create_time, update_time, num, tags, last_result_id, status,
|
||||||
SELECT UUID(), project_id, name, priority, #{api.id}, description, request, #{api.createUser}, update_user_id,
|
original_status,
|
||||||
create_time, update_time, num, tags, last_result_id, status, original_status, delete_time, delete_user_id,
|
delete_time, delete_user_id, version, `order`, case_status, version_id)
|
||||||
version, `order`, case_status, #{api.versionId}
|
SELECT UUID(),
|
||||||
|
project_id,
|
||||||
|
name,
|
||||||
|
priority,
|
||||||
|
#{api.id},
|
||||||
|
description,
|
||||||
|
request,
|
||||||
|
#{api.createUser},
|
||||||
|
update_user_id,
|
||||||
|
create_time,
|
||||||
|
update_time,
|
||||||
|
num,
|
||||||
|
tags,
|
||||||
|
last_result_id,
|
||||||
|
status,
|
||||||
|
original_status,
|
||||||
|
delete_time,
|
||||||
|
delete_user_id,
|
||||||
|
version,
|
||||||
|
`order`,
|
||||||
|
case_status,
|
||||||
|
#{api.versionId}
|
||||||
FROM api_test_case
|
FROM api_test_case
|
||||||
WHERE api_definition_id = #{old.id};
|
WHERE api_definition_id = #{old.id};
|
||||||
</insert>
|
</insert>
|
||||||
|
|
|
@ -13,7 +13,9 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -40,10 +42,11 @@ public class WorkstationService {
|
||||||
apiTestCaseRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
apiTestCaseRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
//@see io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml:103
|
//@see io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml:103
|
||||||
Map<String, Object> combine = new HashMap<>(2);
|
Map<String, Object> combine = new HashMap<>(2);
|
||||||
Map<String,String>operatorValue = new HashMap<>(2);
|
Map<String, String> operatorValue = new HashMap<>(2);
|
||||||
operatorValue.put("operator","current user");
|
operatorValue.put("operator", "current user");
|
||||||
operatorValue.put("value","current user");
|
operatorValue.put("value", "current user");
|
||||||
combine.put("creator",operatorValue);
|
combine.put("creator", operatorValue);
|
||||||
|
Map<String, List<String>> filter = new HashMap<>(2);
|
||||||
testPlanRequest.setCombine(combine);
|
testPlanRequest.setCombine(combine);
|
||||||
apiTestCaseRequest.setCombine(combine);
|
apiTestCaseRequest.setCombine(combine);
|
||||||
ApiScenarioRequest apiScenarioRequest = new ApiScenarioRequest();
|
ApiScenarioRequest apiScenarioRequest = new ApiScenarioRequest();
|
||||||
|
@ -52,17 +55,23 @@ public class WorkstationService {
|
||||||
QueryTestCaseRequest testCaseRequest = new QueryTestCaseRequest();
|
QueryTestCaseRequest testCaseRequest = new QueryTestCaseRequest();
|
||||||
testCaseRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
testCaseRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
testCaseRequest.setCombine(combine);
|
testCaseRequest.setCombine(combine);
|
||||||
|
List<String> status = new ArrayList<>();
|
||||||
|
status.add("Prepare");
|
||||||
|
status.add("Pass");
|
||||||
|
status.add("UnPass");
|
||||||
|
filter.put("reviewStatus", status);
|
||||||
|
testCaseRequest.setFilters(filter);
|
||||||
//query db
|
//query db
|
||||||
int apiScenarioCaseCount = extApiScenarioMapper.listModule(apiScenarioRequest);
|
int apiScenarioCaseCount = extApiScenarioMapper.listModule(apiScenarioRequest);
|
||||||
int apiTestCaseCount = extApiTestCaseMapper.moduleCount(apiTestCaseRequest);
|
int apiTestCaseCount = extApiTestCaseMapper.moduleCount(apiTestCaseRequest);
|
||||||
int testCaseCount = extTestCaseMapper.moduleCount(testCaseRequest);
|
int testCaseCount = extTestCaseMapper.moduleCount(testCaseRequest);
|
||||||
int loadTestCount = extLoadTestMapper.moduleCount(testPlanRequest);
|
int loadTestCount = extLoadTestMapper.moduleCount(testPlanRequest);
|
||||||
//build result
|
//build result
|
||||||
Map<String, Integer>map = new HashMap<>(4);
|
Map<String, Integer> map = new HashMap<>(4);
|
||||||
map.put("apiScenarioCaseCount",apiScenarioCaseCount);
|
map.put("apiScenarioCaseCount", apiScenarioCaseCount);
|
||||||
map.put("apiTestCaseCount",apiTestCaseCount);
|
map.put("apiTestCaseCount", apiTestCaseCount);
|
||||||
map.put("testCaseCount",testCaseCount);
|
map.put("testCaseCount", testCaseCount);
|
||||||
map.put("loadTestCount",loadTestCount);
|
map.put("loadTestCount", loadTestCount);
|
||||||
return map;
|
return map;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue