diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java index a089656f96..0b20990141 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java @@ -5,8 +5,10 @@ import io.metersphere.api.dto.datacount.ExecutedCaseInfoResult; import io.metersphere.api.jmeter.TestResult; import io.metersphere.base.domain.ApiDefinitionExecResult; import io.metersphere.base.domain.ApiDefinitionExecResultExample; +import io.metersphere.base.domain.ApiTestCaseWithBLOBs; import io.metersphere.base.domain.TestPlanApiCase; import io.metersphere.base.mapper.ApiDefinitionExecResultMapper; +import io.metersphere.base.mapper.ApiTestCaseMapper; import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper; import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.utils.DateUtils; @@ -37,6 +39,9 @@ public class ApiDefinitionExecResultService { private TestPlanApiCaseService testPlanApiCaseService; @Resource private TestPlanService testPlanService; + @Resource + private ApiTestCaseMapper apiTestCaseMapper; + @Resource SqlSessionFactory sqlSessionFactory; @@ -60,6 +65,12 @@ public class ApiDefinitionExecResultService { if (StringUtils.equals(type, ApiRunMode.API_PLAN.name())) { testPlanApiCaseService.setExecResult(item.getName(), status); } + // 更新用例最后执行结果 + ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = new ApiTestCaseWithBLOBs(); + apiTestCaseWithBLOBs.setId(saveResult.getResourceId()); + apiTestCaseWithBLOBs.setLastResultId(saveResult.getId()); + + apiTestCaseMapper.updateByPrimaryKeySelective(apiTestCaseWithBLOBs); definitionExecResultMapper.insert(saveResult); }); sqlSession.flushStatements(); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml index 42f70b5647..1ee90b76b7 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml @@ -189,38 +189,18 @@