refactor(接口测试): 接口测试查询项目下所有的用例(带版本)

This commit is contained in:
CaptainB 2022-10-13 15:07:02 +08:00 committed by 刘瑞斌
parent 32a82ac55d
commit 4935ae78f8
8 changed files with 54 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.base.domain.ApiScenario;
import io.metersphere.base.domain.ApiScenarioExampleWithOperation;
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
import io.metersphere.dto.BaseCase;
import io.metersphere.dto.RelationshipGraphData;
import io.metersphere.request.BaseQueryRequest;
import org.apache.ibatis.annotations.Param;
@ -104,4 +105,6 @@ public interface ExtApiScenarioMapper {
List<ApiCountChartResult> countByRequest(ApiCountRequest request);
List<ApiScenarioDTO> relevanceScenarioList(@Param("request") ApiScenarioRequest request);
List<BaseCase> selectBaseCaseByProjectId(@Param("projectId") String projectId);
}

View File

@ -1015,4 +1015,17 @@
</include>
</if>
</sql>
<select id="selectBaseCaseByProjectId" resultType="io.metersphere.dto.BaseCase">
select api_scenario.id, api_scenario.name, api_scenario.project_id,'接口场景' as type, project_version.name as
version_name
from api_scenario inner join project_version on project_version.project_id = api_scenario.project_id and
project_version.id = api_scenario.version_id
<where>
<if test="projectId!=null">
and api_scenario.project_id= #{projectId}
</if>
</where>
and api_scenario.status!='Trash'
</select>
</mapper>

View File

@ -8,6 +8,7 @@ import io.metersphere.api.dto.definition.*;
import io.metersphere.base.domain.ApiDefinition;
import io.metersphere.base.domain.ApiTestCase;
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
import io.metersphere.dto.BaseCase;
import io.metersphere.dto.ParamsDTO;
import org.apache.ibatis.annotations.Param;
@ -97,4 +98,6 @@ public interface ExtApiTestCaseMapper {
List<ApiCountChartResult> countByRequest(ApiCountRequest request);
List<ApiTestCaseDTO> relevanceApiList(@Param("request") ApiTestCaseRequest request);
List<BaseCase> selectBaseCaseByProjectId(@Param("projectId") String projectId);
}

View File

@ -1147,4 +1147,15 @@
</include>
</if>
</sql>
<select id="selectBaseCaseByProjectId" resultType="io.metersphere.dto.BaseCase">
select b.id,b.name,b.project_id,'接口用例' as type, project_version.name as version_name
from api_test_case b inner join api_definition a on b.api_definition_id = a.id and a.status != 'Trash'
inner join project_version on project_version.project_id = a.project_id and project_version.id = a.version_id
<where>
<if test="projectId!=null">
and b.project_id= #{projectId}
</if>
</where>
</select>
</mapper>

View File

@ -16,6 +16,7 @@ import io.metersphere.api.exec.api.ApiExecuteService;
import io.metersphere.api.exec.generator.JSONSchemaGenerator;
import io.metersphere.api.exec.queue.ExecThreadPoolExecutor;
import io.metersphere.api.parse.api.ApiDefinitionImport;
import io.metersphere.dto.BaseCase;
import io.metersphere.service.definition.ApiDefinitionService;
import io.metersphere.service.definition.ApiTestCaseService;
import io.metersphere.service.definition.EsbApiParamService;
@ -405,4 +406,10 @@ public class ApiDefinitionController {
public void updateFileMetadataId(@RequestBody List<ReplaceFileIdRequest> requestList) {
apiDefinitionService.updateFileMetadataId(requestList);
}
@GetMapping("/get-base-case/{projectId}")
@RequiresPermissions("PROJECT_API_DEFINITION:READ")
public List<BaseCase> getBaseCaseByProjectId(@PathVariable String projectId) {
return apiDefinitionService.getBaseCaseByProjectId(projectId);
}
}

View File

@ -7,6 +7,7 @@ import io.metersphere.api.dto.automation.*;
import io.metersphere.api.dto.definition.RunDefinitionRequest;
import io.metersphere.api.dto.export.ScenarioToPerformanceInfoDTO;
import io.metersphere.api.parse.scenario.ScenarioImport;
import io.metersphere.dto.BaseCase;
import io.metersphere.service.scenario.ApiScenarioService;
import io.metersphere.service.ext.ExtApiTaskService;
import io.metersphere.base.domain.ApiScenario;
@ -426,5 +427,11 @@ public class ApiScenarioController {
public List<ApiCountChartResult> countScenarioCaseByRequest(@RequestBody ApiCountRequest request) {
return apiAutomationService.countByRequest(request);
}
@GetMapping("/get-base-case/{projectId}")
@RequiresPermissions("PROJECT_API_SCENARIO:READ")
public List<BaseCase> getBaseCaseByProjectId(@PathVariable String projectId) {
return apiAutomationService.getBaseCaseByProjectId(projectId);
}
}

View File

@ -2889,4 +2889,8 @@ public class ApiDefinitionService {
});
}
}
public List<BaseCase> getBaseCaseByProjectId(String projectId) {
return extApiTestCaseMapper.selectBaseCaseByProjectId(projectId);
}
}

View File

@ -32,6 +32,7 @@ import io.metersphere.commons.enums.ApiTestDataStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.*;
import io.metersphere.commons.utils.mock.MockApiUtils;
import io.metersphere.dto.BaseCase;
import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.dto.ProjectConfig;
import io.metersphere.environment.service.BaseEnvGroupProjectService;
@ -2174,4 +2175,9 @@ public class ApiScenarioService {
}
return new ArrayList<>();
}
public List<BaseCase> getBaseCaseByProjectId(String projectId) {
return extApiScenarioMapper.selectBaseCaseByProjectId(projectId);
}
}