feat(接口测试): 接口测试首页增加按照版本统计筛选的功能
--story=1010740 --user=宋天阳 【接口测试】首页增加版本筛选 https://www.tapd.cn/55049933/s/1315395
This commit is contained in:
parent
f03dbd20a1
commit
35ab1c1f47
|
@ -24,7 +24,7 @@ public class QueryAPIReportRequest {
|
|||
private Map<String, Object> combine;
|
||||
private String selectDataType;
|
||||
private String selectDataRange;
|
||||
|
||||
private String versionId;
|
||||
/**
|
||||
* 查询哪种用例的报告 SCENARIO/API
|
||||
*/
|
||||
|
|
|
@ -28,8 +28,7 @@ public interface ExtApiDefinitionExecResultMapper {
|
|||
|
||||
long countByTestCaseIDInProject(String projectId);
|
||||
|
||||
List<ExecutedCaseInfoResult> findFailureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("selectFunctionCase") boolean selectFunctionCase,
|
||||
@Param("startTimestamp") long startTimestamp, @Param("limitNumber") int limitNumber);
|
||||
List<ExecutedCaseInfoResult> findFailureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("version") String version, @Param("selectFunctionCase") boolean selectFunctionCase, @Param("startTimestamp") long startTimestamp, @Param("limitNumber") int limitNumber);
|
||||
|
||||
String selectExecResult(String resourceId);
|
||||
|
||||
|
|
|
@ -77,7 +77,8 @@
|
|||
INNER JOIN test_plan testPlan ON testPlan.id = testPlanCase.test_plan_id
|
||||
WHERE (
|
||||
(apiCase.`status` IS NULL OR apiCase.`status` != 'Trash')
|
||||
AND apiCase.project_id = #{projectId})) testCase
|
||||
AND apiCase.project_id = #{projectId}
|
||||
)) testCase
|
||||
INNER JOIN (SELECT executionInfo.source_id AS sourceId,
|
||||
COUNT(executionInfo.id) AS dataCountNumber
|
||||
FROM api_case_execution_info executionInfo
|
||||
|
@ -85,6 +86,9 @@
|
|||
ON executionInfo.source_id = testPlanCase.id
|
||||
WHERE executionInfo.`result` = 'ERROR'
|
||||
AND executionInfo.create_time > #{startTimestamp}
|
||||
<if test="versionId != null">
|
||||
AND executionInfo.version = #{versionId}
|
||||
</if>
|
||||
GROUP BY source_id) caseErrorCountData
|
||||
ON caseErrorCountData.sourceId = testCase.testPlanCaseID
|
||||
UNION
|
||||
|
@ -110,6 +114,9 @@
|
|||
AND scene.`status` != 'Trash'
|
||||
AND ( executionInfo.result = 'ERROR' )
|
||||
AND executionInfo.create_time >= #{startTimestamp}
|
||||
<if test="versionId != null">
|
||||
AND executionInfo.version = #{versionId}
|
||||
</if>
|
||||
GROUP BY
|
||||
scene.id,apiScene.testPlanId
|
||||
<if test="selectFunctionCase == true">
|
||||
|
|
|
@ -39,13 +39,13 @@ public interface ExtApiDefinitionMapper {
|
|||
|
||||
int reduction(@Param("ids") List<String> ids);
|
||||
|
||||
List<ApiDataCountResult> countProtocolByProjectID(String projectId);
|
||||
List<ApiDataCountResult> countProtocolByProjectID(@Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
|
||||
Long countByProjectIDAndCreateInThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
|
||||
Long countByProjectIDAndCreateInThisWeek(@Param("projectId") String projectId, @Param("versionId") String versionId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
|
||||
|
||||
List<ApiDataCountResult> countStateByProjectID(String projectId);
|
||||
List<ApiDataCountResult> countStateByProjectID(@Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
|
||||
List<ApiDataCountResult> countApiCoverageByProjectID(String projectId);
|
||||
List<ApiDataCountResult> countApiCoverageByProjectID(@Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
|
||||
ApiDefinition getNextNum(@Param("projectId") String projectId);
|
||||
|
||||
|
@ -55,7 +55,7 @@ public interface ExtApiDefinitionMapper {
|
|||
|
||||
List<String> selectIds(@Param("request") BaseQueryRequest query);
|
||||
|
||||
List<ApiDefinition> selectEffectiveIdByProjectId(String projectId);
|
||||
List<ApiDefinition> selectEffectiveIdByProjectId(@Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
|
||||
List<ApiDefinitionResult> listByIds(@Param("ids") List<String> ids);
|
||||
|
||||
|
@ -73,7 +73,7 @@ public interface ExtApiDefinitionMapper {
|
|||
|
||||
Long getLastOrder(@Param("projectId") String projectId, @Param("baseOrder") Long baseOrder);
|
||||
|
||||
long countApiByProjectIdAndHasCase(String projectId);
|
||||
long countApiByProjectIdAndHasCase(@Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
|
||||
List<RelationshipGraphData.Node> getForGraph(@Param("ids") Set<String> ids);
|
||||
|
||||
|
@ -99,7 +99,7 @@ public interface ExtApiDefinitionMapper {
|
|||
|
||||
int countById(String id);
|
||||
|
||||
List<ApiDefinition> selectEffectiveIdByProjectIdAndHaveNotCase(String projectId);
|
||||
List<ApiDefinition> selectEffectiveIdByProjectIdAndHaveNotCase(@Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
|
||||
int deleteApiToGc(ApiDefinitionRequest request);
|
||||
|
||||
|
|
|
@ -398,16 +398,27 @@
|
|||
<select id="countProtocolByProjectID" resultType="io.metersphere.api.dto.datacount.ApiDataCountResult">
|
||||
SELECT protocol AS groupField, count(DISTINCT ref_id) AS countNumber
|
||||
FROM api_definition
|
||||
WHERE project_id = #{0}
|
||||
WHERE project_id = #{projectId}
|
||||
AND `status` != 'Trash'
|
||||
<if test="versionId != null">
|
||||
AND version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND latest = 1
|
||||
</if>
|
||||
GROUP BY protocol
|
||||
</select>
|
||||
<select id="countStateByProjectID" resultType="io.metersphere.api.dto.datacount.ApiDataCountResult">
|
||||
SELECT status AS groupField, count(id) AS countNumber
|
||||
FROM api_definition
|
||||
WHERE project_id = #{0}
|
||||
AND `status` != 'Trash' AND latest = 1
|
||||
WHERE project_id = #{projectId}
|
||||
AND `status` != 'Trash'
|
||||
<if test="versionId != null">
|
||||
AND version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND latest = 1
|
||||
</if>
|
||||
GROUP BY status
|
||||
</select>
|
||||
<select id="countByProjectIDAndCreateInThisWeek" resultType="java.lang.Long">
|
||||
|
@ -415,7 +426,13 @@
|
|||
FROM api_definition
|
||||
WHERE project_id = #{projectId}
|
||||
AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
|
||||
AND `status` != 'Trash' AND latest = 1
|
||||
AND `status` != 'Trash'
|
||||
<if test="versionId != null">
|
||||
AND version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND latest = 1
|
||||
</if>
|
||||
</select>
|
||||
<select id="countApiCoverageByProjectID" resultType="io.metersphere.api.dto.datacount.ApiDataCountResult">
|
||||
SELECT count(api.id) AS countNumber,
|
||||
|
@ -426,8 +443,14 @@
|
|||
WHERE status is null
|
||||
or status != 'Trash') test_case_api
|
||||
ON api.id = test_case_api.api_definition_id
|
||||
WHERE api.project_id = #{0}
|
||||
and api.`status` != 'Trash' and api.latest = 1
|
||||
WHERE api.project_id = #{projectId}
|
||||
and api.`status` != 'Trash'
|
||||
<if test="versionId != null">
|
||||
and api.version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
and api.latest = 1
|
||||
</if>
|
||||
GROUP BY groupField
|
||||
</select>
|
||||
<select id="getNextNum" resultType="io.metersphere.base.domain.ApiDefinition">
|
||||
|
@ -666,18 +689,29 @@
|
|||
<select id="selectEffectiveIdByProjectId" resultType="io.metersphere.base.domain.ApiDefinition">
|
||||
select id, path, method, protocol
|
||||
from api_definition
|
||||
WHERE project_id = #{0}
|
||||
AND status != 'Trash' AND latest = 1
|
||||
WHERE project_id = #{projectId}
|
||||
AND status != 'Trash'
|
||||
<if test="versionId != null">
|
||||
AND version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND latest = 1
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectEffectiveIdByProjectIdAndHaveNotCase" resultType="io.metersphere.base.domain.ApiDefinition">
|
||||
select id, path, method, protocol
|
||||
from api_definition
|
||||
WHERE project_id = #{0}
|
||||
AND status != 'Trash' AND latest = 1
|
||||
AND id NOT IN (select api_definition_id FROM api_test_case WHERE project_id = #{0}
|
||||
AND (status IS NULL
|
||||
or status != 'Trash'))
|
||||
WHERE project_id = #{projectId}
|
||||
AND status != 'Trash'
|
||||
<if test="versionId != null">
|
||||
AND version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND latest = 1
|
||||
</if>
|
||||
AND id NOT IN (select api_definition_id FROM api_test_case WHERE project_id = #{projectId}
|
||||
AND (status IS NULL or status != 'Trash'))
|
||||
</select>
|
||||
<select id="moduleCount" resultType="java.lang.Integer">
|
||||
select count(id) from api_definition
|
||||
|
@ -1003,13 +1037,18 @@
|
|||
<select id="countApiByProjectIdAndHasCase" resultType="java.lang.Long">
|
||||
SELECT COUNT(id)
|
||||
FROM api_definition
|
||||
WHERE project_id = #{0}
|
||||
WHERE project_id = #{projectId}
|
||||
AND `status` != 'Trash'
|
||||
AND
|
||||
id IN (
|
||||
SELECT api_definition_id FROM api_test_case WHERE `status` is null or `status` != 'Trash'
|
||||
)
|
||||
AND latest = 1
|
||||
<if test="versionId != null">
|
||||
AND version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND latest = 1
|
||||
</if>
|
||||
</select>
|
||||
<select id="getForGraph" resultType="io.metersphere.dto.RelationshipGraphData$Node">
|
||||
select id,num,`name`
|
||||
|
|
|
@ -38,11 +38,11 @@ public interface ExtApiScenarioMapper {
|
|||
|
||||
int reduction(@Param("ids") List<String> ids);
|
||||
|
||||
long countByProjectID(String projectId);
|
||||
long countByProjectID(@Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
|
||||
long countByProjectIDAndCreatInThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
|
||||
long countByProjectIDAndCreatInThisWeek(@Param("projectId") String projectId, @Param("versionId") String versionId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
|
||||
|
||||
List<ApiDataCountResult> countRunResultByProjectID(String projectId);
|
||||
List<ApiDataCountResult> countRunResultByProjectID(@Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
|
||||
List<String> selectIdsNotExistsInPlan(String projectId, String planId);
|
||||
|
||||
|
|
|
@ -537,14 +537,26 @@
|
|||
<select id="countByProjectID" resultType="java.lang.Long">
|
||||
SELECT COUNT(DISTINCT ref_id) AS countNumber
|
||||
FROM api_scenario
|
||||
WHERE project_id = #{0}
|
||||
AND status != 'Trash' AND latest = 1
|
||||
WHERE project_id = #{projectId}
|
||||
AND status != 'Trash'
|
||||
<if test="versionId != null">
|
||||
AND version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND latest = 1
|
||||
</if>
|
||||
</select>
|
||||
<select id="countByProjectIDAndCreatInThisWeek" resultType="java.lang.Long">
|
||||
SELECT count(id) AS countNumber
|
||||
FROM api_scenario
|
||||
WHERE project_id = #{projectId}
|
||||
AND status != 'Trash' and latest = 1
|
||||
AND status != 'Trash'
|
||||
<if test="versionId != null">
|
||||
AND version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND latest = 1
|
||||
</if>
|
||||
AND create_time BETWEEN #{firstDayTimestamp}
|
||||
AND #{lastDayTimestamp}
|
||||
</select>
|
||||
|
@ -552,8 +564,14 @@
|
|||
<select id="countRunResultByProjectID" resultType="io.metersphere.api.dto.datacount.ApiDataCountResult">
|
||||
SELECT count(id) AS countNumber, if(last_result is null, "notRun", last_result) AS groupField
|
||||
FROM api_scenario
|
||||
WHERE project_id = #{0}
|
||||
AND status != 'Trash' and latest = 1
|
||||
WHERE project_id = #{projectId}
|
||||
AND status != 'Trash'
|
||||
<if test="versionId != null">
|
||||
AND version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND latest = 1
|
||||
</if>
|
||||
GROUP BY groupField
|
||||
</select>
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import io.metersphere.base.domain.ApiScenarioReferenceId;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtApiScenarioReferenceIdMapper {
|
||||
List<ApiScenarioReferenceId> selectUrlByProjectId(String projectId);
|
||||
List<ApiScenarioReferenceId> selectUrlByProjectId(@Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
|
||||
List<ApiScenarioReferenceId> selectReferenceIdByIds(List<String> ids);
|
||||
}
|
||||
|
|
|
@ -4,12 +4,17 @@
|
|||
<select id="selectUrlByProjectId" resultType="io.metersphere.base.domain.ApiScenarioReferenceId">
|
||||
SELECT method, url, reference_id
|
||||
from api_scenario_reference_id
|
||||
WHERE api_scenario_id in (SELECT id
|
||||
from api_scenario
|
||||
WHERE status
|
||||
!= 'Trash'
|
||||
AND project_id = #{0}
|
||||
AND latest = 1)
|
||||
WHERE api_scenario_id in (
|
||||
SELECT id from api_scenario
|
||||
WHERE status != 'Trash'
|
||||
AND project_id = #{projectId}
|
||||
<if test="versionId != null">
|
||||
AND version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND latest = 1
|
||||
</if>
|
||||
)
|
||||
AND reference_id IS NOT NULL
|
||||
</select>
|
||||
<select id="selectReferenceIdByIds" resultType="io.metersphere.base.domain.ApiScenarioReferenceId">
|
||||
|
|
|
@ -188,7 +188,9 @@
|
|||
<if test="request.projectId != null">
|
||||
AND s_r.project_id = #{request.projectId}
|
||||
</if>
|
||||
|
||||
<if test="request.versionId != null">
|
||||
AND s_r.version_id = #{request.versionId}
|
||||
</if>
|
||||
<if test="request.isUi">
|
||||
AND s_r.report_type like 'UI%'
|
||||
</if>
|
||||
|
|
|
@ -25,9 +25,9 @@ public interface ExtApiTestCaseMapper {
|
|||
|
||||
List<String> selectIdsNotExistsInReview(@Param("projectId") String projectId, @Param("reviewId") String reviewId);
|
||||
|
||||
List<ApiDataCountResult> countProtocolByProjectID(String projectId);
|
||||
List<ApiDataCountResult> countProtocolByProjectID(@Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
|
||||
long countByProjectIDAndCreateInThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
|
||||
long countByProjectIDAndCreateInThisWeek(@Param("projectId") String projectId, @Param("versionId") String versionId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
|
||||
|
||||
List<ApiTestCaseInfo> getRequest(@Param("request") ApiTestCaseRequest request);
|
||||
|
||||
|
@ -87,7 +87,7 @@ public interface ExtApiTestCaseMapper {
|
|||
|
||||
int countById(String resourceID);
|
||||
|
||||
List<ExecuteResultCountDTO> selectExecuteResultByProjectId(String projectId);
|
||||
List<ExecuteResultCountDTO> selectExecuteResultByProjectId(@Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
|
||||
int deleteCaseToGc(ApiTestCaseRequest request);
|
||||
|
||||
|
|
|
@ -665,9 +665,14 @@
|
|||
SELECT apiDef.protocol AS groupField, COUNT(testCase.id) AS countNumber
|
||||
FROM api_test_case testCase
|
||||
INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id
|
||||
WHERE testCase.project_id = #{0}
|
||||
WHERE testCase.project_id = #{projectId}
|
||||
AND (testCase.status IS NULL or testCase.status != "Trash")
|
||||
and latest = 1
|
||||
<if test="versionId != null">
|
||||
AND apiDef.version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND apiDef.latest = 1
|
||||
</if>
|
||||
GROUP BY apiDef.protocol
|
||||
</select>
|
||||
<select id="findApiUrlAndMethodById" resultType="io.metersphere.base.domain.ApiDefinition">
|
||||
|
@ -682,12 +687,17 @@
|
|||
SELECT count(testCase.id) AS countNumber
|
||||
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.status is null
|
||||
or testCase.status != 'Trash')
|
||||
and latest = 1
|
||||
<if test="versionId != null">
|
||||
AND apiDef.version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND apiDef.latest = 1
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="moduleCount" resultType="java.lang.Integer">
|
||||
|
@ -1017,7 +1027,14 @@
|
|||
FROM api_test_case
|
||||
WHERE `status` != 'Trash' AND api_definition_id IN
|
||||
(SELECT id FROM api_definition
|
||||
WHERE project_id = #{0} AND latest IS TRUE)
|
||||
WHERE project_id = #{projectId}
|
||||
<if test="versionId != null">
|
||||
AND version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND latest IS TRUE
|
||||
</if>
|
||||
)
|
||||
GROUP BY `status`
|
||||
</select>
|
||||
<select id="caseList" resultType="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
|
||||
|
|
|
@ -8,4 +8,5 @@ public class ApiHomeFilterEnum {
|
|||
public static final String SCHEDULE_EXECUTION_PASS = "scheduleExecutionPass";
|
||||
public static final String SCHEDULE_EXECUTION_FAKE_ERROR = "scheduleExecutionFakeError";
|
||||
public static final String SCHEDULE_EXECUTION_FAILED = "scheduleExecutionFailed";
|
||||
public static final String DEFAULT_VERSION = "default";
|
||||
}
|
||||
|
|
|
@ -72,10 +72,13 @@ public class ApiDefinitionController {
|
|||
return PageUtils.setPageInfo(page, apiDefinitionService.list(request));
|
||||
}
|
||||
|
||||
@PostMapping("/list/week/{projectId}/{goPage}/{pageSize}")
|
||||
public Pager<List<ApiDefinitionResult>> weekList(@PathVariable String projectId, @PathVariable int goPage, @PathVariable int pageSize) {
|
||||
@PostMapping("/list/week/{projectId}/{versionId}/{goPage}/{pageSize}")
|
||||
public Pager<List<ApiDefinitionResult>> weekList(@PathVariable String projectId, @PathVariable String versionId, @PathVariable int goPage, @PathVariable int pageSize) {
|
||||
if (StringUtils.equalsIgnoreCase(versionId, "default")) {
|
||||
versionId = null;
|
||||
}
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
return PageUtils.setPageInfo(page, apiDefinitionService.weekList(projectId));
|
||||
return PageUtils.setPageInfo(page, apiDefinitionService.weekList(projectId, versionId));
|
||||
}
|
||||
|
||||
@PostMapping("/list/relevance/{goPage}/{pageSize}")
|
||||
|
|
|
@ -17,22 +17,23 @@ import io.metersphere.base.domain.ApiDefinition;
|
|||
import io.metersphere.base.domain.Schedule;
|
||||
import io.metersphere.commons.constants.ReportTriggerMode;
|
||||
import io.metersphere.commons.enums.ExecutionExecuteTypeEnum;
|
||||
import io.metersphere.commons.utils.DataFormattingUtil;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.commons.utils.PageUtils;
|
||||
import io.metersphere.commons.utils.Pager;
|
||||
import io.metersphere.commons.utils.*;
|
||||
import io.metersphere.dto.TaskInfoResult;
|
||||
import io.metersphere.service.BaseScheduleService;
|
||||
import io.metersphere.service.definition.ApiDefinitionExecResultService;
|
||||
import io.metersphere.service.definition.ApiDefinitionService;
|
||||
import io.metersphere.service.definition.ApiTestCaseService;
|
||||
import io.metersphere.service.scenario.ApiScenarioReportService;
|
||||
import io.metersphere.service.scenario.ApiScenarioService;
|
||||
import io.metersphere.task.service.TaskService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -51,18 +52,22 @@ public class ApiHomeController {
|
|||
private ApiScenarioReportService apiScenarioReportService;
|
||||
@Resource
|
||||
private BaseScheduleService baseScheduleService;
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
|
||||
|
||||
@GetMapping("/api/count/{projectId}")
|
||||
public ApiDataCountDTO apiCount(@PathVariable String projectId) {
|
||||
|
||||
@GetMapping("/api/count/{projectId}/{versionId}")
|
||||
public ApiDataCountDTO apiCount(@PathVariable String projectId, @PathVariable String versionId) {
|
||||
if (StringUtils.equalsIgnoreCase(versionId, "default")) {
|
||||
versionId = null;
|
||||
}
|
||||
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
|
||||
List<ApiDataCountResult> countResultByProtocolList = apiDefinitionService.countProtocolByProjectID(projectId);
|
||||
List<ApiDataCountResult> countResultByProtocolList = apiDefinitionService.countProtocolByProjectID(projectId, versionId);
|
||||
apiCountResult.countProtocol(countResultByProtocolList);
|
||||
long dateCountByCreateInThisWeek = apiDefinitionService.countByProjectIDAndCreateInThisWeek(projectId);
|
||||
long dateCountByCreateInThisWeek = apiDefinitionService.countByProjectIDAndCreateInThisWeek(projectId, versionId);
|
||||
apiCountResult.setCreatedInWeek(dateCountByCreateInThisWeek);
|
||||
//查询完成率、进行中、已完成
|
||||
List<ApiDataCountResult> countResultByStateList = apiDefinitionService.countStateByProjectID(projectId);
|
||||
List<ApiDataCountResult> countResultByStateList = apiDefinitionService.countStateByProjectID(projectId, versionId);
|
||||
apiCountResult.countStatus(countResultByStateList);
|
||||
long allCount = apiCountResult.getFinishedCount() + apiCountResult.getRunningCount() + apiCountResult.getNotStartedCount();
|
||||
if (allCount != 0) {
|
||||
|
@ -71,45 +76,48 @@ public class ApiHomeController {
|
|||
apiCountResult.setCompletedRate(df.format(completeRateNumber) + "%");
|
||||
}
|
||||
//统计覆盖率
|
||||
long effectiveApiCount = apiDefinitionService.countEffectiveByProjectId(projectId);
|
||||
long apiHasCase = apiDefinitionService.countApiByProjectIdAndHasCase(projectId);
|
||||
List<ApiDefinition> apiNoCaseList = apiDefinitionService.selectEffectiveIdByProjectIdAndHaveNotCase(projectId);
|
||||
Map<String, Map<String, String>> scenarioUrlList = apiAutomationService.selectScenarioUseUrlByProjectId(projectId);
|
||||
long effectiveApiCount = apiDefinitionService.countEffectiveByProjectId(projectId, versionId);
|
||||
long apiHasCase = apiDefinitionService.countApiByProjectIdAndHasCase(projectId, versionId);
|
||||
List<ApiDefinition> apiNoCaseList = apiDefinitionService.selectEffectiveIdByProjectIdAndHaveNotCase(projectId, versionId);
|
||||
Map<String, Map<String, String>> scenarioUrlList = apiAutomationService.selectScenarioUseUrlByProjectId(projectId, versionId);
|
||||
int apiInScenario = apiAutomationService.getApiIdInScenario(projectId, scenarioUrlList, apiNoCaseList).size();
|
||||
|
||||
try {
|
||||
if (effectiveApiCount == 0) {
|
||||
apiCountResult.setCoveredCount(0);
|
||||
apiCountResult.setNotCoveredCount(0);
|
||||
} else {
|
||||
long quotedApiCount = apiHasCase + apiInScenario;
|
||||
apiCountResult.setCoveredCount(quotedApiCount);
|
||||
apiCountResult.setNotCoveredCount(effectiveApiCount - quotedApiCount);
|
||||
if (effectiveApiCount == 0) {
|
||||
apiCountResult.setCoveredCount(0);
|
||||
apiCountResult.setNotCoveredCount(0);
|
||||
} else {
|
||||
long quotedApiCount = apiHasCase + apiInScenario;
|
||||
apiCountResult.setCoveredCount(quotedApiCount);
|
||||
apiCountResult.setNotCoveredCount(effectiveApiCount - quotedApiCount);
|
||||
try {
|
||||
float coveredRateNumber = (float) quotedApiCount * 100 / effectiveApiCount;
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
apiCountResult.setApiCoveredRate(df.format(coveredRateNumber) + "%");
|
||||
} catch (Exception e) {
|
||||
LogUtil.error("转化通过率失败:[" + quotedApiCount + "," + effectiveApiCount + "]", e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
|
||||
return apiCountResult;
|
||||
}
|
||||
|
||||
@GetMapping("/api/case/count/{projectId}")
|
||||
public ApiDataCountDTO apiCaseCount(@PathVariable String projectId) {
|
||||
@GetMapping("/api/case/count/{projectId}/{versionId}")
|
||||
public ApiDataCountDTO apiCaseCount(@PathVariable String projectId, @PathVariable String versionId) {
|
||||
if (StringUtils.equalsIgnoreCase(versionId, "default")) {
|
||||
versionId = null;
|
||||
}
|
||||
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
|
||||
List<ApiDataCountResult> countResultList = apiTestCaseService.countProtocolByProjectID(projectId);
|
||||
List<ApiDataCountResult> countResultList = apiTestCaseService.countProtocolByProjectID(projectId, versionId);
|
||||
apiCountResult.countProtocol(countResultList);
|
||||
//本周创建、本周执行、总执行
|
||||
long dateCountByCreateInThisWeek = apiTestCaseService.countByProjectIDAndCreateInThisWeek(projectId);
|
||||
long dateCountByCreateInThisWeek = apiTestCaseService.countByProjectIDAndCreateInThisWeek(projectId, versionId);
|
||||
apiCountResult.setCreatedInWeek(dateCountByCreateInThisWeek);
|
||||
long executedInThisWeekCountNumber = apiDefinitionExecResultService.countByTestCaseIDInProjectAndExecutedInThisWeek(projectId, null);
|
||||
long executedInThisWeekCountNumber = apiDefinitionExecResultService.countByTestCaseIDInProjectAndExecutedInThisWeek(projectId, versionId);
|
||||
apiCountResult.setExecutedTimesInWeek(executedInThisWeekCountNumber);
|
||||
long executedCount = apiTestCaseService.countExecutedTimesByProjectId(projectId, ExecutionExecuteTypeEnum.BASIC.name(), null);
|
||||
long executedCount = apiTestCaseService.countExecutedTimesByProjectId(projectId, ExecutionExecuteTypeEnum.BASIC.name(), versionId);
|
||||
apiCountResult.setExecutedTimes(executedCount);
|
||||
//未覆盖 已覆盖: 统计当前接口下是否含有案例
|
||||
List<ApiDataCountResult> countResultByApiCoverageList = apiDefinitionService.countApiCoverageByProjectID(projectId);
|
||||
List<ApiDataCountResult> countResultByApiCoverageList = apiDefinitionService.countApiCoverageByProjectID(projectId, versionId);
|
||||
apiCountResult.countApiCoverage(countResultByApiCoverageList);
|
||||
long allCount = apiCountResult.getCoveredCount() + apiCountResult.getNotCoveredCount();
|
||||
if (allCount != 0) {
|
||||
|
@ -118,7 +126,7 @@ public class ApiHomeController {
|
|||
apiCountResult.setApiCoveredRate(df.format(coveredRateNumber) + "%");
|
||||
}
|
||||
//计算用例的通过率和执行率
|
||||
List<ExecuteResultCountDTO> apiCaseExecResultList = apiTestCaseService.selectExecuteResultByProjectId(projectId);
|
||||
List<ExecuteResultCountDTO> apiCaseExecResultList = apiTestCaseService.selectExecuteResultByProjectId(projectId, versionId);
|
||||
apiCountResult.countApiCaseRunResult(apiCaseExecResultList);
|
||||
if (apiCountResult.getExecutedCount() > 0) {
|
||||
//通过率
|
||||
|
@ -136,21 +144,24 @@ public class ApiHomeController {
|
|||
return apiCountResult;
|
||||
}
|
||||
|
||||
@GetMapping("/scenario/count/{projectId}")
|
||||
public ApiDataCountDTO scenarioCount(@PathVariable String projectId) {
|
||||
@GetMapping("/scenario/count/{projectId}/{versionId}")
|
||||
public ApiDataCountDTO scenarioCount(@PathVariable String projectId, @PathVariable String versionId) {
|
||||
if (StringUtils.equalsIgnoreCase(versionId, "default")) {
|
||||
versionId = null;
|
||||
}
|
||||
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
|
||||
long scenarioCountNumber = apiAutomationService.countScenarioByProjectID(projectId);
|
||||
long scenarioCountNumber = apiAutomationService.countScenarioByProjectID(projectId, versionId);
|
||||
apiCountResult.setTotal(scenarioCountNumber);
|
||||
//统计覆盖率
|
||||
long dateCountByCreateInThisWeek = apiAutomationService.countScenarioByProjectIDAndCreatInThisWeek(projectId);
|
||||
long dateCountByCreateInThisWeek = apiAutomationService.countScenarioByProjectIDAndCreatInThisWeek(projectId, versionId);
|
||||
apiCountResult.setCreatedInWeek(dateCountByCreateInThisWeek);
|
||||
long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateInThisWeek(projectId, ExecutionExecuteTypeEnum.BASIC.name(), null);
|
||||
long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateInThisWeek(projectId, ExecutionExecuteTypeEnum.BASIC.name(), versionId);
|
||||
apiCountResult.setExecutedTimesInWeek(executedInThisWeekCountNumber);
|
||||
//所有执行次数
|
||||
long executedTimes = apiAutomationService.countExecuteTimesByProjectID(projectId, null, ExecutionExecuteTypeEnum.BASIC.name(), null);
|
||||
long executedTimes = apiAutomationService.countExecuteTimesByProjectID(projectId, null, ExecutionExecuteTypeEnum.BASIC.name(), versionId);
|
||||
apiCountResult.setExecutedTimes(executedTimes);
|
||||
//未执行、未通过、已通过
|
||||
List<ApiDataCountResult> countResultByRunResult = apiAutomationService.countRunResultByProjectID(projectId);
|
||||
List<ApiDataCountResult> countResultByRunResult = apiAutomationService.countRunResultByProjectID(projectId, versionId);
|
||||
apiCountResult.countScenarioRunResult(countResultByRunResult);
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
if (apiCountResult.getExecutedData() != 0) {
|
||||
|
@ -164,8 +175,8 @@ public class ApiHomeController {
|
|||
|
||||
//统计覆盖率
|
||||
CoveredDTO coveredDTO = new CoveredDTO();
|
||||
Map<String, Map<String, String>> scenarioUrlList = apiAutomationService.selectScenarioUseUrlByProjectId(projectId);
|
||||
List<ApiDefinition> allEffectiveApiIdList = apiDefinitionService.selectEffectiveIdByProjectId(projectId);
|
||||
Map<String, Map<String, String>> scenarioUrlList = apiAutomationService.selectScenarioUseUrlByProjectId(projectId, versionId);
|
||||
List<ApiDefinition> allEffectiveApiIdList = apiDefinitionService.selectEffectiveIdByProjectId(projectId, versionId);
|
||||
try {
|
||||
coveredDTO = apiAutomationService.countInterfaceCoverage(projectId, scenarioUrlList, allEffectiveApiIdList);
|
||||
} catch (Exception e) {
|
||||
|
@ -178,22 +189,24 @@ public class ApiHomeController {
|
|||
return apiCountResult;
|
||||
}
|
||||
|
||||
@GetMapping("/schedule/task/count/{projectId}")
|
||||
public ApiDataCountDTO scheduleTaskCount(@PathVariable String projectId) {
|
||||
|
||||
List<Schedule> allScenarioScheduleList = baseScheduleService.selectScenarioTaskByProjectId(projectId);
|
||||
@GetMapping("/schedule/task/count/{projectId}/{versionId}")
|
||||
public ApiDataCountDTO scheduleTaskCount(@PathVariable String projectId, @PathVariable String versionId) {
|
||||
if (StringUtils.equalsIgnoreCase(versionId, "default")) {
|
||||
versionId = null;
|
||||
}
|
||||
List<Schedule> allScenarioScheduleList = baseScheduleService.selectScenarioTaskByProjectId(projectId, versionId);
|
||||
|
||||
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
|
||||
long allTaskCount = allScenarioScheduleList.size();
|
||||
apiCountResult.setTotal(allTaskCount);
|
||||
long taskCountInThisWeek = baseScheduleService.countTaskByProjectIdInThisWeek(projectId);
|
||||
long taskCountInThisWeek = baseScheduleService.countTaskByProjectIdInThisWeek(projectId, versionId);
|
||||
apiCountResult.setCreatedInWeek(taskCountInThisWeek);
|
||||
long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateAndByScheduleInThisWeek(projectId, ExecutionExecuteTypeEnum.BASIC.name(), null);
|
||||
long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateAndByScheduleInThisWeek(projectId, ExecutionExecuteTypeEnum.BASIC.name(), versionId);
|
||||
apiCountResult.setExecutedTimesInWeek(executedInThisWeekCountNumber);
|
||||
long executedTimes = apiAutomationService.countExecuteTimesByProjectID(projectId, ReportTriggerMode.SCHEDULE.name(), ExecutionExecuteTypeEnum.BASIC.name(), null);
|
||||
long executedTimes = apiAutomationService.countExecuteTimesByProjectID(projectId, ReportTriggerMode.SCHEDULE.name(), ExecutionExecuteTypeEnum.BASIC.name(), versionId);
|
||||
apiCountResult.setExecutedTimes(executedTimes);
|
||||
//统计 失败 成功 以及总数
|
||||
List<ApiDataCountResult> allExecuteResult = apiScenarioReportService.countByProjectIdGroupByExecuteResult(projectId, null);
|
||||
List<ApiDataCountResult> allExecuteResult = apiScenarioReportService.countByProjectIdGroupByExecuteResult(projectId, versionId);
|
||||
apiCountResult.countScheduleExecute(allExecuteResult);
|
||||
if (executedTimes != 0) {
|
||||
float passRateNumber = (float) apiCountResult.getPassCount() * 100 / executedTimes;
|
||||
|
@ -231,12 +244,34 @@ public class ApiHomeController {
|
|||
return returnDTO;
|
||||
}
|
||||
|
||||
@GetMapping("/failure/case/about/plan/{projectId}/{selectFunctionCase}/{limitNumber}/{goPage}/{pageSize}")
|
||||
public Pager<List<ExecutedCaseInfoDTO>> failureCaseAboutTestPlan(@PathVariable String projectId, @PathVariable boolean selectFunctionCase,
|
||||
@PathVariable int limitNumber, @PathVariable int goPage, @PathVariable int pageSize) {
|
||||
|
||||
@PostMapping("/runningTask/{projectId}/{versionId}/{goPage}/{pageSize}")
|
||||
public Pager<List<TaskInfoResult>> runningTask(@PathVariable String projectId, @PathVariable String versionId, @PathVariable int goPage, @PathVariable int pageSize) {
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
List<ExecutedCaseInfoResult> selectDataList = apiDefinitionExecResultService.findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(projectId, selectFunctionCase, limitNumber);
|
||||
if (StringUtils.equalsIgnoreCase(versionId, "default")) {
|
||||
versionId = null;
|
||||
}
|
||||
List<TaskInfoResult> resultList = taskService.findScenarioAndSwaggerRunningTaskInfoByProjectID(projectId, versionId);
|
||||
int dataIndex = 1;
|
||||
for (TaskInfoResult taskInfo :
|
||||
resultList) {
|
||||
taskInfo.setIndex(dataIndex++);
|
||||
Date nextExecutionTime = CronUtils.getNextTriggerTime(taskInfo.getRule());
|
||||
if (nextExecutionTime != null) {
|
||||
taskInfo.setNextExecutionTime(nextExecutionTime.getTime());
|
||||
}
|
||||
}
|
||||
return PageUtils.setPageInfo(page, resultList);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/failure/case/about/plan/{projectId}/{versionId}/{selectFunctionCase}/{limitNumber}/{goPage}/{pageSize}")
|
||||
public Pager<List<ExecutedCaseInfoDTO>> failureCaseAboutTestPlan(@PathVariable String projectId, @PathVariable String versionId, @PathVariable boolean selectFunctionCase,
|
||||
@PathVariable int limitNumber, @PathVariable int goPage, @PathVariable int pageSize) {
|
||||
if (StringUtils.equalsIgnoreCase(versionId, "default")) {
|
||||
versionId = null;
|
||||
}
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
List<ExecutedCaseInfoResult> selectDataList = apiDefinitionExecResultService.findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(projectId, versionId, selectFunctionCase, limitNumber);
|
||||
List<ExecutedCaseInfoDTO> returnList = new ArrayList<>(selectDataList.size());
|
||||
for (int dataIndex = 0; dataIndex < selectDataList.size(); dataIndex++) {
|
||||
ExecutedCaseInfoDTO dataDTO = new ExecutedCaseInfoDTO();
|
||||
|
|
|
@ -347,7 +347,7 @@ public class ApiDefinitionExecResultService {
|
|||
}
|
||||
}
|
||||
|
||||
public List<ExecutedCaseInfoResult> findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(String projectId, boolean selectFunctionCase, int limitNumber) {
|
||||
public List<ExecutedCaseInfoResult> findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(String projectId, String versionId, boolean selectFunctionCase, int limitNumber) {
|
||||
|
||||
//获取7天之前的日期
|
||||
Date startDay = DateUtils.dateSum(new Date(), -6);
|
||||
|
@ -362,7 +362,7 @@ public class ApiDefinitionExecResultService {
|
|||
if (startTime == null) {
|
||||
return new ArrayList<>(0);
|
||||
} else {
|
||||
List<ExecutedCaseInfoResult> list = extApiDefinitionExecResultMapper.findFailureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber(projectId, selectFunctionCase, startTime.getTime(), limitNumber);
|
||||
List<ExecutedCaseInfoResult> list = extApiDefinitionExecResultMapper.findFailureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber(projectId, versionId, selectFunctionCase, startTime.getTime(), limitNumber);
|
||||
|
||||
List<ExecutedCaseInfoResult> returnList = new ArrayList<>(limitNumber);
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ public class ApiDefinitionService {
|
|||
});
|
||||
}
|
||||
|
||||
public List<ApiDefinitionResult> weekList(String projectId) {
|
||||
public List<ApiDefinitionResult> weekList(String projectId, String versionId) {
|
||||
//获取7天之前的日期
|
||||
Date startDay = DateUtils.dateSum(new Date(), -6);
|
||||
//将日期转化为 00:00:00 的时间戳
|
||||
|
@ -284,6 +284,9 @@ public class ApiDefinitionService {
|
|||
request.setProjectId(projectId);
|
||||
request = this.initRequest(request, true, true);
|
||||
request.setNotEqStatus(ApiTestDataStatus.TRASH.getValue());
|
||||
if (StringUtils.isNotBlank(versionId)) {
|
||||
request.setVersionId(versionId);
|
||||
}
|
||||
List<ApiDefinitionResult> resList = extApiDefinitionMapper.weekList(request, startTime.getTime());
|
||||
calculateResult(resList, request.getProjectId());
|
||||
calculateRelationScenario(resList);
|
||||
|
@ -342,16 +345,17 @@ public class ApiDefinitionService {
|
|||
public void checkFilterHasCoverage(ApiDefinitionRequest request) {
|
||||
if (StringUtils.isNotEmpty(request.getProjectId())) {
|
||||
List<ApiDefinition> definitionList = null;
|
||||
String versionId = StringUtils.isEmpty(request.getVersionId()) ? null : request.getVersionId();
|
||||
if (StringUtils.equalsAnyIgnoreCase(request.getApiCoverage(), ApiHomeFilterEnum.NOT_COVERED, ApiHomeFilterEnum.COVERED)) {
|
||||
//计算没有用例接口的覆盖数量
|
||||
definitionList = this.selectEffectiveIdByProjectIdAndHaveNotCase(request.getProjectId());
|
||||
definitionList = this.selectEffectiveIdByProjectIdAndHaveNotCase(request.getProjectId(), versionId);
|
||||
} else if (StringUtils.equalsAnyIgnoreCase(request.getScenarioCoverage(), ApiHomeFilterEnum.NOT_COVERED, ApiHomeFilterEnum.COVERED)) {
|
||||
//计算全部用例
|
||||
definitionList = this.selectEffectiveIdByProjectId(request.getProjectId());
|
||||
definitionList = this.selectEffectiveIdByProjectId(request.getProjectId(), versionId);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(definitionList)) {
|
||||
//如果查询条件中有未覆盖/已覆盖, 则需要解析出没有用例的接口中,有多少是符合场景覆盖规律的。然后将这些接口的id作为查询参数
|
||||
Map<String, Map<String, String>> scenarioUrlList = apiAutomationService.selectScenarioUseUrlByProjectId(request.getProjectId());
|
||||
Map<String, Map<String, String>> scenarioUrlList = apiAutomationService.selectScenarioUseUrlByProjectId(request.getProjectId(), versionId);
|
||||
List<String> apiIdInScenario = apiAutomationService.getApiIdInScenario(request.getProjectId(), scenarioUrlList, definitionList);
|
||||
if (CollectionUtils.isNotEmpty(apiIdInScenario)) {
|
||||
request.setCoverageIds(apiIdInScenario);
|
||||
|
@ -1174,8 +1178,8 @@ public class ApiDefinitionService {
|
|||
* @param projectId 项目ID
|
||||
* @return List
|
||||
*/
|
||||
public List<ApiDataCountResult> countProtocolByProjectID(String projectId) {
|
||||
return extApiDefinitionMapper.countProtocolByProjectID(projectId);
|
||||
public List<ApiDataCountResult> countProtocolByProjectID(String projectId, String versionId) {
|
||||
return extApiDefinitionMapper.countProtocolByProjectID(projectId, versionId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1184,7 +1188,7 @@ public class ApiDefinitionService {
|
|||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
public long countByProjectIDAndCreateInThisWeek(String projectId) {
|
||||
public long countByProjectIDAndCreateInThisWeek(String projectId, String versionId) {
|
||||
Map<String, Date> startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date());
|
||||
|
||||
Date firstTime = startAndEndDateInWeek.get("firstTime");
|
||||
|
@ -1193,16 +1197,16 @@ public class ApiDefinitionService {
|
|||
if (firstTime == null || lastTime == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return extApiDefinitionMapper.countByProjectIDAndCreateInThisWeek(projectId, firstTime.getTime(), lastTime.getTime());
|
||||
return extApiDefinitionMapper.countByProjectIDAndCreateInThisWeek(projectId, versionId, firstTime.getTime(), lastTime.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public List<ApiDataCountResult> countStateByProjectID(String projectId) {
|
||||
return extApiDefinitionMapper.countStateByProjectID(projectId);
|
||||
public List<ApiDataCountResult> countStateByProjectID(String projectId, String versionId) {
|
||||
return extApiDefinitionMapper.countStateByProjectID(projectId, versionId);
|
||||
}
|
||||
|
||||
public List<ApiDataCountResult> countApiCoverageByProjectID(String projectId) {
|
||||
return extApiDefinitionMapper.countApiCoverageByProjectID(projectId);
|
||||
public List<ApiDataCountResult> countApiCoverageByProjectID(String projectId, String versionId) {
|
||||
return extApiDefinitionMapper.countApiCoverageByProjectID(projectId, versionId);
|
||||
}
|
||||
|
||||
public void deleteByParams(ApiBatchRequest request) {
|
||||
|
@ -1464,12 +1468,12 @@ public class ApiDefinitionService {
|
|||
}
|
||||
}
|
||||
|
||||
public List<ApiDefinition> selectEffectiveIdByProjectId(String projectId) {
|
||||
return extApiDefinitionMapper.selectEffectiveIdByProjectId(projectId);
|
||||
public List<ApiDefinition> selectEffectiveIdByProjectId(String projectId, String versionId) {
|
||||
return extApiDefinitionMapper.selectEffectiveIdByProjectId(projectId, versionId);
|
||||
}
|
||||
|
||||
public List<ApiDefinition> selectEffectiveIdByProjectIdAndHaveNotCase(String projectId) {
|
||||
return extApiDefinitionMapper.selectEffectiveIdByProjectIdAndHaveNotCase(projectId);
|
||||
public List<ApiDefinition> selectEffectiveIdByProjectIdAndHaveNotCase(String projectId, String versionId) {
|
||||
return extApiDefinitionMapper.selectEffectiveIdByProjectIdAndHaveNotCase(projectId, versionId);
|
||||
}
|
||||
|
||||
public List<ApiDefinitionWithBLOBs> preparedUrl(String projectId, String method, String baseUrlSuffix, String mockApiResourceId) {
|
||||
|
@ -1675,18 +1679,22 @@ public class ApiDefinitionService {
|
|||
}
|
||||
|
||||
|
||||
public long countEffectiveByProjectId(String projectId) {
|
||||
public long countEffectiveByProjectId(String projectId, String versionId) {
|
||||
if (StringUtils.isEmpty(projectId)) {
|
||||
return 0;
|
||||
} else {
|
||||
ApiDefinitionExample example = new ApiDefinitionExample();
|
||||
example.createCriteria().andProjectIdEqualTo(projectId).andStatusNotEqualTo("Trash").andLatestEqualTo(true);
|
||||
ApiDefinitionExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andProjectIdEqualTo(projectId).andStatusNotEqualTo("Trash").andLatestEqualTo(true);
|
||||
if (StringUtils.isNotBlank(versionId)) {
|
||||
criteria.andVersionIdEqualTo(versionId);
|
||||
}
|
||||
return apiDefinitionMapper.countByExample(example);
|
||||
}
|
||||
}
|
||||
|
||||
public long countApiByProjectIdAndHasCase(String projectId) {
|
||||
return extApiDefinitionMapper.countApiByProjectIdAndHasCase(projectId);
|
||||
public long countApiByProjectIdAndHasCase(String projectId, String versionId) {
|
||||
return extApiDefinitionMapper.countApiByProjectIdAndHasCase(projectId, versionId);
|
||||
}
|
||||
|
||||
public int getRelationshipCount(String id) {
|
||||
|
|
|
@ -72,6 +72,7 @@ public class ApiExecutionInfoService {
|
|||
info.setTriggerMode(triggerMode);
|
||||
info.setProjectId(projectId);
|
||||
info.setExecuteType(executeType);
|
||||
info.setVersion(versionId);
|
||||
apiCaseExecutionInfoMapper.insert(info);
|
||||
}
|
||||
|
||||
|
|
|
@ -600,11 +600,11 @@ public class ApiTestCaseService {
|
|||
return extApiTestCaseMapper.selectIdsNotExistsInReview(projectId, reviewId);
|
||||
}
|
||||
|
||||
public List<ApiDataCountResult> countProtocolByProjectID(String projectId) {
|
||||
return extApiTestCaseMapper.countProtocolByProjectID(projectId);
|
||||
public List<ApiDataCountResult> countProtocolByProjectID(String projectId, String versionId) {
|
||||
return extApiTestCaseMapper.countProtocolByProjectID(projectId, versionId);
|
||||
}
|
||||
|
||||
public long countByProjectIDAndCreateInThisWeek(String projectId) {
|
||||
public long countByProjectIDAndCreateInThisWeek(String projectId, String versionId) {
|
||||
Map<String, Date> startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date());
|
||||
|
||||
Date firstTime = startAndEndDateInWeek.get("firstTime");
|
||||
|
@ -613,7 +613,7 @@ public class ApiTestCaseService {
|
|||
if (firstTime == null || lastTime == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return extApiTestCaseMapper.countByProjectIDAndCreateInThisWeek(projectId, firstTime.getTime(), lastTime.getTime());
|
||||
return extApiTestCaseMapper.countByProjectIDAndCreateInThisWeek(projectId, versionId, firstTime.getTime(), lastTime.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1112,8 +1112,8 @@ public class ApiTestCaseService {
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<ExecuteResultCountDTO> selectExecuteResultByProjectId(String projectId) {
|
||||
return extApiTestCaseMapper.selectExecuteResultByProjectId(projectId);
|
||||
public List<ExecuteResultCountDTO> selectExecuteResultByProjectId(String projectId, String versionId) {
|
||||
return extApiTestCaseMapper.selectExecuteResultByProjectId(projectId, versionId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package io.metersphere.service.scenario;
|
||||
|
||||
import io.metersphere.service.MsHashTreeService;
|
||||
import io.metersphere.base.domain.ApiScenarioReferenceId;
|
||||
import io.metersphere.base.domain.ApiScenarioReferenceIdExample;
|
||||
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
||||
import io.metersphere.base.mapper.ApiScenarioReferenceIdMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiScenarioReferenceIdMapper;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.commons.utils.JSONUtil;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.service.MsHashTreeService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
|
@ -208,7 +208,7 @@ public class ApiScenarioReferenceIdService {
|
|||
}
|
||||
}
|
||||
|
||||
public List<ApiScenarioReferenceId> selectUrlByProjectId(String projectId) {
|
||||
return extApiScenarioReferenceIdMapper.selectUrlByProjectId(projectId);
|
||||
public List<ApiScenarioReferenceId> selectUrlByProjectId(String projectId, String versionId) {
|
||||
return extApiScenarioReferenceIdMapper.selectUrlByProjectId(projectId, versionId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import io.metersphere.api.dto.definition.request.*;
|
|||
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
|
||||
import io.metersphere.api.dto.definition.request.unknown.MsJmeterElement;
|
||||
import io.metersphere.api.dto.export.ScenarioToPerformanceInfoDTO;
|
||||
import io.metersphere.api.dto.scenario.ApiScenarioParamDTO;
|
||||
import io.metersphere.api.exec.scenario.ApiScenarioEnvService;
|
||||
import io.metersphere.api.exec.scenario.ApiScenarioExecuteService;
|
||||
import io.metersphere.api.jmeter.JMeterService;
|
||||
|
@ -56,7 +57,6 @@ import io.metersphere.service.definition.TcpApiParamService;
|
|||
import io.metersphere.service.ext.ExtApiScheduleService;
|
||||
import io.metersphere.service.ext.ExtFileAssociationService;
|
||||
import io.metersphere.service.plan.TestPlanScenarioCaseService;
|
||||
import io.metersphere.api.dto.scenario.ApiScenarioParamDTO;
|
||||
import io.metersphere.xpack.api.service.ApiAutomationRelationshipEdgeService;
|
||||
import io.metersphere.xpack.quota.service.QuotaService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -1005,23 +1005,23 @@ public class ApiScenarioService {
|
|||
return "success";
|
||||
}
|
||||
|
||||
public long countScenarioByProjectID(String projectId) {
|
||||
return extApiScenarioMapper.countByProjectID(projectId);
|
||||
public long countScenarioByProjectID(String projectId, String versionId) {
|
||||
return extApiScenarioMapper.countByProjectID(projectId, versionId);
|
||||
}
|
||||
|
||||
public long countScenarioByProjectIDAndCreatInThisWeek(String projectId) {
|
||||
public long countScenarioByProjectIDAndCreatInThisWeek(String projectId, String versionId) {
|
||||
Map<String, Date> startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date());
|
||||
Date firstTime = startAndEndDateInWeek.get("firstTime");
|
||||
Date lastTime = startAndEndDateInWeek.get("lastTime");
|
||||
if (firstTime == null || lastTime == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return extApiScenarioMapper.countByProjectIDAndCreatInThisWeek(projectId, firstTime.getTime(), lastTime.getTime());
|
||||
return extApiScenarioMapper.countByProjectIDAndCreatInThisWeek(projectId, versionId, firstTime.getTime(), lastTime.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public List<ApiDataCountResult> countRunResultByProjectID(String projectId) {
|
||||
return extApiScenarioMapper.countRunResultByProjectID(projectId);
|
||||
public List<ApiDataCountResult> countRunResultByProjectID(String projectId, String versionId) {
|
||||
return extApiScenarioMapper.countRunResultByProjectID(projectId, versionId);
|
||||
}
|
||||
|
||||
public List<ApiScenarioWithBLOBs> selectByIdsWithBLOBs(List<String> ids) {
|
||||
|
@ -2176,8 +2176,8 @@ public class ApiScenarioService {
|
|||
* @param projectId
|
||||
* @return <get/post, <step-id,url>>
|
||||
*/
|
||||
public Map<String, Map<String, String>> selectScenarioUseUrlByProjectId(String projectId) {
|
||||
List<ApiScenarioReferenceId> list = apiScenarioReferenceIdService.selectUrlByProjectId(projectId);
|
||||
public Map<String, Map<String, String>> selectScenarioUseUrlByProjectId(String projectId, String versionId) {
|
||||
List<ApiScenarioReferenceId> list = apiScenarioReferenceIdService.selectUrlByProjectId(projectId, versionId);
|
||||
Map<String, Map<String, String>> returnMap = new HashMap<>();
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
list.forEach(item -> {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
import { get, post } from 'metersphere-frontend/src/plugins/request';
|
||||
|
||||
const BASE_URL = '/environment/';
|
||||
|
||||
export function getEnvironmentByProjectId(projectId) {
|
||||
return get(BASE_URL + `list/${projectId}`);
|
||||
}
|
|
@ -61,8 +61,8 @@ export function apiListBatch(params) {
|
|||
return post('/api/definition/list/batch', params);
|
||||
}
|
||||
|
||||
export function definitionWeekList(projectId, page, pageSize) {
|
||||
return post('/api/definition/list/week/' + projectId + '/' + page + '/' + pageSize);
|
||||
export function definitionWeekList(projectId, versionId, page, pageSize) {
|
||||
return post('/api/definition/list/week/' + projectId + '/' + versionId + '/' + page + '/' + pageSize);
|
||||
}
|
||||
|
||||
export function getRelevanceDefinitionPage(page, pageSize, params) {
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
import { fileUpload } from '@/api/base-network';
|
||||
import { get, post } from 'metersphere-frontend/src/plugins/request';
|
||||
|
||||
export function apiCountByProjectId(projectId) {
|
||||
return get('/home/api/count/' + projectId);
|
||||
export function apiCountByProjectId(projectId, versionId) {
|
||||
return get('/home/api/count/' + projectId + '/' + versionId);
|
||||
}
|
||||
|
||||
export function scenarioCountByProjectId(projectId) {
|
||||
return get('/home/scenario/count/' + projectId);
|
||||
export function scenarioCountByProjectId(projectId, versionId) {
|
||||
return get('/home/scenario/count/' + projectId + '/' + versionId);
|
||||
}
|
||||
|
||||
export function apiCaseCountByProjectId(projectId) {
|
||||
return get('/home/api/case/count/' + projectId);
|
||||
export function apiCaseCountByProjectId(projectId, versionId) {
|
||||
return get('/home/api/case/count/' + projectId + '/' + versionId);
|
||||
}
|
||||
|
||||
export function scheduleTaskCountByProjectId(projectId) {
|
||||
return get('/home/schedule/task/count/' + projectId);
|
||||
export function scheduleTaskCountByProjectId(projectId, versionId) {
|
||||
return get('/home/schedule/task/count/' + projectId + '/' + versionId);
|
||||
}
|
||||
|
||||
export function dubboProviders(params) {
|
||||
|
@ -30,8 +30,8 @@ export function genPerformanceTestXml(file, files, params) {
|
|||
return fileUpload(url, file, files, params);
|
||||
}
|
||||
|
||||
export function getRunningTask(selectProjectId, currentPage, pageSize, param) {
|
||||
return post('/task/center/runningTask/' + selectProjectId + '/' + currentPage + '/' + pageSize, param);
|
||||
export function getRunningTask(selectProjectId, versionId, currentPage, pageSize) {
|
||||
return post('/home/runningTask/' + selectProjectId + '/' + versionId + '/' + currentPage + '/' + pageSize);
|
||||
}
|
||||
|
||||
export function formatNumber(param) {
|
||||
|
|
|
@ -325,11 +325,14 @@ export default {
|
|||
let selectDataRange = 'all';
|
||||
let selectDataType = 'all';
|
||||
let routeParamObj = this.$route.params;
|
||||
let redirectVersionId = this.$route.params.versionId;
|
||||
if (redirectVersionId !== 'default') {
|
||||
this.condition.versionId = redirectVersionId;
|
||||
}
|
||||
if (routeParamObj) {
|
||||
selectDataRange = routeParamObj.dataSelectRange;
|
||||
selectDataType = routeParamObj.dataType;
|
||||
}
|
||||
|
||||
if (
|
||||
(this.activeDom === 'left' && selectDataType === 'scenario') ||
|
||||
(this.activeDom === 'right' && selectDataType === 'apiCase')
|
||||
|
|
|
@ -852,7 +852,6 @@ export default {
|
|||
};
|
||||
}
|
||||
|
||||
// todo
|
||||
if (projectId != null && typeof projectId === 'string') {
|
||||
this.condition.projectId = projectId;
|
||||
} else if (this.projectId != null) {
|
||||
|
@ -1325,6 +1324,10 @@ export default {
|
|||
this.selectDataRange = 'all';
|
||||
this.selectDataType = 'all';
|
||||
let routeParamObj = this.$route.params;
|
||||
let redirectVersionId = this.$route.params.versionId;
|
||||
if (redirectVersionId !== 'default') {
|
||||
this.condition.versionId = redirectVersionId;
|
||||
}
|
||||
if (routeParamObj) {
|
||||
let dataRange = routeParamObj.dataSelectRange;
|
||||
let dataType = routeParamObj.dataType;
|
||||
|
|
|
@ -1279,6 +1279,10 @@ export default {
|
|||
this.selectDataRange = 'all';
|
||||
let routeParam = this.$route.params.dataSelectRange;
|
||||
let dataType = this.$route.params.dataType;
|
||||
let redirectVersionId = this.$route.params.versionId;
|
||||
if (redirectVersionId !== 'default') {
|
||||
this.condition.versionId = redirectVersionId;
|
||||
}
|
||||
if (dataType === 'apiTestCase') {
|
||||
this.selectDataRange = routeParam;
|
||||
}
|
||||
|
|
|
@ -1060,6 +1060,10 @@ export default {
|
|||
getSelectDataRange() {
|
||||
let dataRange = this.$route.params.dataSelectRange;
|
||||
let dataType = this.$route.params.dataType;
|
||||
let redirectVersionId = this.$route.params.versionId;
|
||||
if (redirectVersionId !== 'default') {
|
||||
this.condition.versionId = redirectVersionId;
|
||||
}
|
||||
this.selectDataRange = dataType === 'api' ? dataRange : 'all';
|
||||
if (
|
||||
this.selectDataRange &&
|
||||
|
|
|
@ -3,30 +3,40 @@
|
|||
<ms-container>
|
||||
<ms-main-container style="padding: 0px">
|
||||
<div class="api-home-layout">
|
||||
<el-row class="api-home-toolbar">
|
||||
<el-select
|
||||
clearable
|
||||
v-model="versionId"
|
||||
:placeholder="$t('home.dashboard.public.default_version')"
|
||||
size="small"
|
||||
style="height: 100%">
|
||||
<el-option v-for="item in versions" :key="item.id" :label="item.name" :value="item.id"> </el-option>
|
||||
</el-select>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<api-dashboard @redirectPage="redirectPage" />
|
||||
<api-dashboard :version-id="versionId" @redirectPage="redirectPage" ref="apiDashboard" />
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<api-case-dashboard @redirectPage="redirectPage" />
|
||||
<api-case-dashboard @redirectPage="redirectPage" ref="apiCaseDashboard" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16" style="margin-top: 16px">
|
||||
<el-col :span="12">
|
||||
<scenario-dashboard @redirectPage="redirectPage" />
|
||||
<scenario-dashboard @redirectPage="redirectPage" ref="scenarioDashboard" />
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<scenario-schedule-dashboard @redirectPage="redirectPage" />
|
||||
<scenario-schedule-dashboard @redirectPage="redirectPage" ref="scenarioScheduleDashboard" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-top: 16px">
|
||||
<el-col style="background-color: #ffffff">
|
||||
<updated-api-list @redirectPage="redirectPage" />
|
||||
<updated-api-list @redirectPage="redirectPage" ref="updatedApiList" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-top: 16px">
|
||||
<el-col style="background-color: #ffffff">
|
||||
<schedule-task-list @redirectPage="redirectPage" />
|
||||
<schedule-task-list @redirectPage="redirectPage" ref="scheduleTaskList" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
@ -45,6 +55,9 @@ import ScenarioDashboard from '@/business/home/components/dashboard/ScenarioDash
|
|||
import ScenarioScheduleDashboard from '@/business/home/components/dashboard/ScenarioScheduleDashboard';
|
||||
import UpdatedApiList from '@/business/home/components/table/UpdatedApiList';
|
||||
import ScheduleTaskList from '@/business/home/components/table/ScheduleTaskList';
|
||||
import { getProjectVersions } from '@/api/xpack';
|
||||
import { getCurrentProjectID } from 'metersphere-frontend/src/utils/token';
|
||||
import { hasLicense } from 'metersphere-frontend/src/utils/permission';
|
||||
|
||||
export default {
|
||||
name: 'ApiHome',
|
||||
|
@ -61,11 +74,60 @@ export default {
|
|||
},
|
||||
|
||||
data() {
|
||||
return {};
|
||||
return {
|
||||
versionId: '',
|
||||
projectId: getCurrentProjectID(),
|
||||
versions: [],
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.initVersions();
|
||||
this.$nextTick(() => {
|
||||
this.refreshAllCard();
|
||||
});
|
||||
},
|
||||
watch: {
|
||||
versionId() {
|
||||
this.refreshAllCard();
|
||||
},
|
||||
},
|
||||
activated() {},
|
||||
created() {},
|
||||
methods: {
|
||||
refreshAllCard() {
|
||||
let selectVersionId = this.versionId;
|
||||
if (!selectVersionId || selectVersionId === '') {
|
||||
selectVersionId = 'default';
|
||||
}
|
||||
|
||||
if (this.$refs.apiDashboard) {
|
||||
this.$refs.apiDashboard.search(selectVersionId);
|
||||
}
|
||||
if (this.$refs.apiCaseDashboard) {
|
||||
this.$refs.apiCaseDashboard.search(selectVersionId);
|
||||
}
|
||||
if (this.$refs.scenarioDashboard) {
|
||||
this.$refs.scenarioDashboard.search(selectVersionId);
|
||||
}
|
||||
if (this.$refs.scenarioScheduleDashboard) {
|
||||
this.$refs.scenarioScheduleDashboard.search(selectVersionId);
|
||||
}
|
||||
if (this.$refs.updatedApiList) {
|
||||
this.$refs.updatedApiList.search(selectVersionId);
|
||||
}
|
||||
if (this.$refs.scheduleTaskList) {
|
||||
this.$refs.scheduleTaskList.search(selectVersionId);
|
||||
}
|
||||
},
|
||||
initVersions() {
|
||||
if (hasLicense()) {
|
||||
getProjectVersions(getCurrentProjectID()).then((response) => {
|
||||
if (response.data) {
|
||||
this.versions = response.data;
|
||||
} else {
|
||||
this.versions = [];
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param redirectPage 要跳转的页面
|
||||
|
@ -77,11 +139,18 @@ export default {
|
|||
//传入UUID是为了进行页面重新加载判断
|
||||
let uuid = getUUID();
|
||||
let home;
|
||||
|
||||
let selectVersionId = this.versionId;
|
||||
if (!selectVersionId || selectVersionId === '') {
|
||||
selectVersionId = 'default';
|
||||
}
|
||||
|
||||
switch (redirectPage) {
|
||||
case 'api':
|
||||
home = this.$router.resolve({
|
||||
name: 'ApiDefinitionWithQuery',
|
||||
params: {
|
||||
versionId: selectVersionId,
|
||||
redirectID: uuid,
|
||||
dataType: dataType,
|
||||
dataSelectRange: selectRange,
|
||||
|
@ -92,6 +161,7 @@ export default {
|
|||
home = this.$router.resolve({
|
||||
name: 'ApiAutomationWithQuery',
|
||||
params: {
|
||||
versionId: selectVersionId,
|
||||
redirectID: uuid,
|
||||
dataType: dataType,
|
||||
dataSelectRange: selectRange,
|
||||
|
@ -102,6 +172,7 @@ export default {
|
|||
home = this.$router.resolve({
|
||||
name: 'ApiReportListWithQuery',
|
||||
params: {
|
||||
versionId: selectVersionId,
|
||||
redirectID: uuid,
|
||||
dataType: dataType,
|
||||
dataSelectRange: selectRange,
|
||||
|
@ -121,6 +192,28 @@ export default {
|
|||
</script>
|
||||
|
||||
<style scoped>
|
||||
.api-home-toolbar {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.api-home-toolbar :deep(.el-input__inner) {
|
||||
border: 1px solid #bbbfc4;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.api-home-toolbar :deep(.el-select__caret el-input__icon el-icon-arrow-up) {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.api-home-toolbar :deep(::-webkit-input-placeholder) {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
color: #8f959e;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
:deep(.el-card__header) {
|
||||
border: 0px;
|
||||
padding: 24px;
|
||||
|
@ -133,7 +226,7 @@ export default {
|
|||
}
|
||||
|
||||
.api-home-layout {
|
||||
margin: 12px 24px;
|
||||
margin: 16px 24px;
|
||||
min-width: 1100px;
|
||||
}
|
||||
|
||||
|
|
|
@ -210,11 +210,11 @@ export default {
|
|||
this.search();
|
||||
},
|
||||
methods: {
|
||||
search() {
|
||||
search(versionId) {
|
||||
this.loading = true;
|
||||
this.loadError = false;
|
||||
let selectProjectId = getCurrentProjectID();
|
||||
apiCaseCountByProjectId(selectProjectId)
|
||||
apiCaseCountByProjectId(selectProjectId, versionId)
|
||||
.then((response) => {
|
||||
this.loading = false;
|
||||
this.loadError = false;
|
||||
|
|
|
@ -157,15 +157,12 @@ export default {
|
|||
},
|
||||
};
|
||||
},
|
||||
activated() {
|
||||
this.search();
|
||||
},
|
||||
methods: {
|
||||
search() {
|
||||
search(versionId) {
|
||||
this.loading = true;
|
||||
this.loadError = false;
|
||||
let selectProjectId = getCurrentProjectID();
|
||||
apiCountByProjectId(selectProjectId)
|
||||
apiCountByProjectId(selectProjectId, versionId)
|
||||
.then((response) => {
|
||||
this.loading = false;
|
||||
this.loadError = false;
|
||||
|
|
|
@ -211,11 +211,11 @@ export default {
|
|||
this.search();
|
||||
},
|
||||
methods: {
|
||||
search() {
|
||||
search(versionId) {
|
||||
this.loading = true;
|
||||
this.loadError = false;
|
||||
let selectProjectId = getCurrentProjectID();
|
||||
scenarioCountByProjectId(selectProjectId)
|
||||
scenarioCountByProjectId(selectProjectId, versionId)
|
||||
.then((response) => {
|
||||
this.loading = false;
|
||||
this.loadError = false;
|
||||
|
|
|
@ -164,11 +164,11 @@ export default {
|
|||
this.search();
|
||||
},
|
||||
methods: {
|
||||
search() {
|
||||
search(versionId) {
|
||||
this.loading = true;
|
||||
this.loadError = false;
|
||||
let selectProjectId = getCurrentProjectID();
|
||||
scheduleTaskCountByProjectId(selectProjectId)
|
||||
scheduleTaskCountByProjectId(selectProjectId, versionId)
|
||||
.then((response) => {
|
||||
this.loading = false;
|
||||
this.loadError = false;
|
||||
|
|
|
@ -142,12 +142,11 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
search() {
|
||||
search(versionId) {
|
||||
let projectId = getCurrentProjectID();
|
||||
this.loading = true;
|
||||
this.loadError = false;
|
||||
this.condition.filters.task_type = ['SWAGGER_IMPORT', 'API_SCENARIO_TEST'];
|
||||
this.result = getRunningTask(projectId, this.currentPage, this.pageSize, this.condition)
|
||||
this.result = getRunningTask(projectId, versionId, this.currentPage, this.pageSize)
|
||||
.then((response) => {
|
||||
this.total = response.data.itemCount;
|
||||
this.tableData = response.data.listObject;
|
||||
|
|
|
@ -142,12 +142,10 @@ export default {
|
|||
currentPage: 1,
|
||||
pageSize: 5,
|
||||
total: 0,
|
||||
versionId: '',
|
||||
status: API_STATUS,
|
||||
};
|
||||
},
|
||||
activated() {
|
||||
this.search();
|
||||
},
|
||||
methods: {
|
||||
clickRow(row, column, event) {
|
||||
if (column.property !== 'caseTotal' && column.property !== 'scenarioTotal') {
|
||||
|
@ -157,12 +155,13 @@ export default {
|
|||
this.redirectPage('api', 'api', 'edit:' + row.id);
|
||||
}
|
||||
},
|
||||
search() {
|
||||
search(versionId) {
|
||||
this.versionId = versionId;
|
||||
let projectId = getCurrentProjectID();
|
||||
this.loading = true;
|
||||
this.loadError = false;
|
||||
|
||||
this.result = definitionWeekList(projectId, this.currentPage, this.pageSize)
|
||||
this.result = definitionWeekList(projectId, versionId, this.currentPage, this.pageSize)
|
||||
.then((response) => {
|
||||
this.total = response.data.itemCount;
|
||||
this.tableData = response.data.listObject;
|
||||
|
|
|
@ -38,6 +38,7 @@ const message = {
|
|||
home: {
|
||||
dashboard: {
|
||||
public: {
|
||||
default_version: 'Default version data',
|
||||
no_data: 'No data',
|
||||
load_error: 'Load error',
|
||||
this_week: 'Week',
|
||||
|
|
|
@ -37,6 +37,7 @@ const message = {
|
|||
home: {
|
||||
dashboard: {
|
||||
public: {
|
||||
default_version: '默认最新版本',
|
||||
no_data: '暂无数据',
|
||||
load_error: '加载失败',
|
||||
this_week: '本周',
|
||||
|
|
|
@ -37,6 +37,7 @@ const message = {
|
|||
home: {
|
||||
dashboard: {
|
||||
public: {
|
||||
default_version: '默認最新版本',
|
||||
no_data: '暫無數據',
|
||||
load_error: '加載失敗',
|
||||
this_week: '本週',
|
||||
|
|
|
@ -22,7 +22,7 @@ export default {
|
|||
component: () => import('@/business/automation/report/ApiReportView'),
|
||||
},
|
||||
{
|
||||
path: 'automation/report/:redirectID?/:dataType?/:dataSelectRange',
|
||||
path: 'automation/:versionId?/report/:redirectID?/:dataType?/:dataSelectRange',
|
||||
name: 'ApiReportListWithQuery',
|
||||
component: () => import('@/business/automation/report/ApiReportList'),
|
||||
},
|
||||
|
@ -37,12 +37,12 @@ export default {
|
|||
component: () => import('@/business/definition/ApiDefinition'),
|
||||
},
|
||||
{
|
||||
path: 'definition/:redirectID?/:dataType?/:dataSelectRange?/:projectId?/:type?/:workspaceId?',
|
||||
path: 'definition/:versionId?/:redirectID?/:dataType?/:dataSelectRange?/:projectId?/:type?/:workspaceId?',
|
||||
name: 'ApiDefinitionWithQuery',
|
||||
component: () => import('@/business/definition/ApiDefinition'),
|
||||
},
|
||||
{
|
||||
path: 'automation/:redirectID?/:dataType?/:dataSelectRange?/:projectId?/:workspaceId?',
|
||||
path: 'automation/:versionId?/:redirectID?/:dataType?/:dataSelectRange?/:projectId?/:workspaceId?',
|
||||
name: 'ApiAutomationWithQuery',
|
||||
component: () => import('@/business/automation/ApiAutomation'),
|
||||
},
|
||||
|
|
|
@ -12,12 +12,13 @@ import java.util.List;
|
|||
public interface BaseScheduleMapper {
|
||||
List<ScheduleDao> list(@Param("request") QueryScheduleRequest request);
|
||||
|
||||
List<Schedule> selectScenarioTaskByProjectId(String workspaceId);
|
||||
List<Schedule> selectScenarioTaskByProjectId(@Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
|
||||
long countTaskByProjectIdAndCreateTimeRange(@Param("projectId") String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime);
|
||||
long countTaskByProjectIdAndCreateTimeRange(@Param("projectId") String projectId, @Param("versionId") String versionId, @Param("startTime") long startTime, @Param("endTime") long endTime);
|
||||
|
||||
List<TaskInfoResult> findRunningTaskInfoByProjectID(@Param("projectId") String workspaceID, @Param("request") BaseQueryRequest request);
|
||||
|
||||
int updateNameByResourceID(@Param("resourceId") String resourceId, @Param("name") String name);
|
||||
|
||||
List<TaskInfoResult> findScenarioAndSwaggerRunningTaskInfoByProjectID(@Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,13 @@
|
|||
<select id="selectScenarioTaskByProjectId" resultType="io.metersphere.base.domain.Schedule">
|
||||
SELECT * FROM `schedule`
|
||||
WHERE resource_id IN (
|
||||
SELECT id FROM api_scenario WHERE project_id = #{0,jdbcType=VARCHAR} AND status != 'Trash' AND latest = 1
|
||||
SELECT id FROM api_scenario WHERE project_id = #{projectId,jdbcType=VARCHAR} AND status != 'Trash'
|
||||
<if test="versionId != null">
|
||||
AND version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND latest = 1
|
||||
</if>
|
||||
)
|
||||
</select>
|
||||
<select id="countTaskByProjectIdAndCreateTimeRange" resultType="java.lang.Long">
|
||||
|
@ -52,10 +58,17 @@
|
|||
SELECT scene.id
|
||||
FROM api_scenario scene
|
||||
WHERE scene.project_id = #{projectId,jdbcType=VARCHAR}
|
||||
AND scene.status != 'Trash' AND latest = 1
|
||||
AND scene.status != 'Trash'
|
||||
<if test="versionId != null">
|
||||
AND version_id = #{versionId}
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND latest = 1
|
||||
</if>
|
||||
)
|
||||
AND create_time BETWEEN #{startTime} AND #{endTime}
|
||||
</select>
|
||||
|
||||
<select id="findRunningTaskInfoByProjectID" resultType="io.metersphere.dto.TaskInfoResult">
|
||||
SELECT sch.id AS taskID,
|
||||
sch.`name` AS `name`,
|
||||
|
@ -92,6 +105,39 @@
|
|||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="findScenarioAndSwaggerRunningTaskInfoByProjectID" resultType="io.metersphere.dto.TaskInfoResult">
|
||||
SELECT sch.id AS taskID,
|
||||
sch.`name` AS `name`,
|
||||
sch.`value` AS rule,
|
||||
sch.`enable` AS `taskStatus`,
|
||||
sch.update_time AS updateTime,
|
||||
sch.id AS taskID,
|
||||
sch.`value` AS rule,
|
||||
sch.`enable` AS `taskStatus`,
|
||||
u.`name` AS creator,
|
||||
sch.update_time AS updateTime,
|
||||
sch.type AS taskType,
|
||||
sch.`group` AS taskGroup,
|
||||
sch.resource_id AS scenarioId
|
||||
FROM (
|
||||
schedule sch left join user u
|
||||
ON sch.user_id = u.id
|
||||
)
|
||||
WHERE sch.`enable` = true
|
||||
AND sch.project_id = #{projectId,jdbcType=VARCHAR}
|
||||
|
||||
<if test="versionId != null">
|
||||
AND (
|
||||
sch.group IN ('SWAGGER_IMPORT')
|
||||
OR
|
||||
resource_id IN (SELECT id FROM api_scenario WHERE status != 'Trash' AND version_id = #{versionId})
|
||||
)
|
||||
</if>
|
||||
<if test="versionId == null">
|
||||
AND sch.group IN ('API_SCENARIO_TEST','SWAGGER_IMPORT')
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateNameByResourceID">
|
||||
update schedule set name = #{name} where resource_id = #{resourceId}
|
||||
</update>
|
||||
|
|
|
@ -221,11 +221,12 @@ public class BaseScheduleService {
|
|||
});
|
||||
}
|
||||
|
||||
public List<Schedule> selectScenarioTaskByProjectId(String projectId) {
|
||||
return baseScheduleMapper.selectScenarioTaskByProjectId(projectId);
|
||||
public List<Schedule> selectScenarioTaskByProjectId(String projectId, String versionId) {
|
||||
return baseScheduleMapper.selectScenarioTaskByProjectId(projectId, versionId);
|
||||
}
|
||||
|
||||
public long countTaskByProjectIdInThisWeek(String projectId) {
|
||||
|
||||
public long countTaskByProjectIdInThisWeek(String projectId, String versionId) {
|
||||
Map<String, Date> startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date());
|
||||
|
||||
Date firstTime = startAndEndDateInWeek.get("firstTime");
|
||||
|
@ -234,7 +235,7 @@ public class BaseScheduleService {
|
|||
if (firstTime == null || lastTime == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return baseScheduleMapper.countTaskByProjectIdAndCreateTimeRange(projectId, firstTime.getTime(), lastTime.getTime());
|
||||
return baseScheduleMapper.countTaskByProjectIdAndCreateTimeRange(projectId, versionId, firstTime.getTime(), lastTime.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,4 +167,8 @@ public class TaskService {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<TaskInfoResult> findScenarioAndSwaggerRunningTaskInfoByProjectID(String projectId, String versionId) {
|
||||
return baseScheduleMapper.findScenarioAndSwaggerRunningTaskInfoByProjectID(projectId, versionId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
import {post, get} from "@/business/utils/sdk-utils";
|
||||
import { get } from "@/business/utils/sdk-utils";
|
||||
|
||||
const BASE_URL = '/home/';
|
||||
const BASE_URL = "/home/";
|
||||
|
||||
export function homeTestPlanFailureCaseGet(projectId, selectFunctionCase, limitNumber, currentPage, pageSize) {
|
||||
return get(BASE_URL + `failure/case/about/plan/${projectId}/${selectFunctionCase}/${limitNumber}/${currentPage}/${pageSize}`);
|
||||
export function homeTestPlanFailureCaseGet(
|
||||
projectId,
|
||||
selectFunctionCase,
|
||||
limitNumber,
|
||||
currentPage,
|
||||
pageSize
|
||||
) {
|
||||
return get(
|
||||
BASE_URL +
|
||||
`failure/case/about/plan/${projectId}/default/${selectFunctionCase}/${limitNumber}/${currentPage}/${pageSize}`
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue