fix(测试计划): 查看接口用例执行结果无执行数据

This commit is contained in:
shiziyuan9527 2021-08-17 15:11:17 +08:00 committed by 刘瑞斌
parent bfd2fe12b3
commit ed00bfe960
5 changed files with 19 additions and 1 deletions

View File

@ -195,6 +195,11 @@ public class ApiDefinitionController {
return apiDefinitionService.getDbResult(testId, type); return apiDefinitionService.getDbResult(testId, type);
} }
@GetMapping("/report/plan/getReport/{testId}/{type}")
public APIReportResult getTestPlanApiCaseReport(@PathVariable String testId, @PathVariable String type) {
return apiDefinitionService.getTestPlanApiCaseReport(testId, type);
}
@PostMapping(value = "/import", consumes = {"multipart/form-data"}) @PostMapping(value = "/import", consumes = {"multipart/form-data"})
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_IMPORT_API) @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_IMPORT_API)
@MsAuditLog(module = "api_definition", type = OperLogConstants.IMPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId") @MsAuditLog(module = "api_definition", type = OperLogConstants.IMPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")

View File

@ -1346,4 +1346,9 @@ public class ApiDefinitionService {
}); });
this.removeToGc(apiIdList); this.removeToGc(apiIdList);
} }
public APIReportResult getTestPlanApiCaseReport(String testId, String type) {
ApiDefinitionExecResult result = extApiDefinitionExecResultMapper.selectPlanApiMaxResultByTestIdAndType(testId, type);
return buildAPIReportResult(result);
}
} }

View File

@ -22,4 +22,6 @@ public interface ExtApiDefinitionExecResultMapper {
List<ExecutedCaseInfoResult> findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("startTimestamp") long startTimestamp); List<ExecutedCaseInfoResult> findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("startTimestamp") long startTimestamp);
String selectExecResult(String resourceId); String selectExecResult(String resourceId);
ApiDefinitionExecResult selectPlanApiMaxResultByTestIdAndType(String resourceId, String type);
} }

View File

@ -86,4 +86,10 @@
<select id="selectExecResult" resultType="java.lang.String"> <select id="selectExecResult" resultType="java.lang.String">
select ader.status from api_definition_exec_result ader where ader.resource_id=#{resourceId} select ader.status from api_definition_exec_result ader where ader.resource_id=#{resourceId}
</select> </select>
<select id="selectPlanApiMaxResultByTestIdAndType"
resultType="io.metersphere.base.domain.ApiDefinitionExecResult">
select * from api_definition_exec_result
where resource_id = #{resourceId,jdbcType=VARCHAR} and `type` = #{type, jdbcType=VARCHAR}
ORDER BY start_time DESC LIMIT 1
</select>
</mapper> </mapper>

View File

@ -619,7 +619,7 @@ export default {
// this.environmentId = data.id; // this.environmentId = data.id;
}, },
getReportResult(apiCase) { getReportResult(apiCase) {
let url = "/api/definition/report/getReport/" + apiCase.id + '/' + 'API_PLAN'; let url = "/api/definition/report/plan/getReport/" + apiCase.id + '/' + 'API_PLAN';
this.$get(url, response => { this.$get(url, response => {
if (response.data) { if (response.data) {
this.response = JSON.parse(response.data.content); this.response = JSON.parse(response.data.content);