fix(接口测试首页 接口测试): 修复新建接口无执行记录时统计报错的问题,新项目下创建接口测试时Mock相关功能报错的问题 (#5531)

修复新建接口无执行记录时统计报错的问题,新项目下创建接口测试时Mock相关功能报错的问题

Co-authored-by: song-tianyang <tianyang.song@fit2cloud.com>
This commit is contained in:
metersphere-bot 2021-08-20 14:28:29 +08:00 committed by GitHub
parent fe96b6694f
commit da7b8d0e76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 12 deletions

View File

@ -2497,6 +2497,11 @@ public class ApiAutomationService {
}
public long countExecuteTimesByProjectID(String projectId) {
return extApiScenarioMapper.countExeciteTimesByProjectID(projectId);
Long result = extApiScenarioMapper.countExecuteTimesByProjectID(projectId);
if(result == null){
return 0;
}else {
return result.longValue();
}
}
}

View File

@ -227,7 +227,7 @@ public class ApiDefinitionExecResultService {
apiCase.setStatus(status);
apiCase.setUpdateTime(System.currentTimeMillis());
testPlanApiCaseService.updateByPrimaryKeySelective(apiCase);
} else if (StringUtils.equals(type, ApiRunMode.JENKINS_SCENARIO_PLAN.name())) {
} else if (StringUtils.equals(type, ApiRunMode.JENKINS_API_PLAN.name())) {
TestPlanApiCase apiCase = testPlanApiCaseService.getById(item.getName());
userID = Objects.requireNonNull(SessionUtils.getUser()).getId();
apiCase.setStatus(status);

View File

@ -109,12 +109,14 @@ public class MockConfigService {
MockConfig config = new MockConfig();
config.setProjectId(request.getProjectId());
config.setApiId(request.getApiId());
config.setId(UUID.randomUUID().toString());
config.setCreateUserId(SessionUtils.getUserId());
config.setCreateTime(createTimeStmp);
config.setUpdateTime(createTimeStmp);
mockConfigMapper.insert(config);
if(request.getApiId() != null){
config.setApiId(request.getApiId());
mockConfigMapper.insert(config);
}
returnRsp = new MockConfigResponse(config, new ArrayList<>());
} else {
MockConfig config = configList.get(0);

View File

@ -71,5 +71,5 @@ public interface ExtApiScenarioMapper {
List<String> selectIdsByExecuteTimeIsNull();
long countExeciteTimesByProjectID(String projectId);
Long countExecuteTimesByProjectID(String projectId);
}

View File

@ -457,7 +457,7 @@
</foreach>
</select>
<select id="countExeciteTimesByProjectID" resultType="java.lang.Long">
<select id="countExecuteTimesByProjectID" resultType="java.lang.Long">
SELECT SUM(execute_times) FROM api_scenario
WHERE project_id = #{0}
</select>

View File

@ -176,12 +176,14 @@ export default {
mockSetting() {
let mockParam = {};
mockParam.projectId = this.projectId;
mockParam.apiId = this.currentApi.id;
this.$post('/mockConfig/genMockConfig', mockParam, response => {
let mockConfig = response.data;
mockConfig.apiName = this.currentApi.name;
this.baseMockConfigData = mockConfig;
});
if(this.currentApi.id){
mockParam.apiId = this.currentApi.id;
this.$post('/mockConfig/genMockConfig', mockParam, response => {
let mockConfig = response.data;
mockConfig.apiName = this.currentApi.name;
this.baseMockConfigData = mockConfig;
});
}
},
runTest(data) {
this.$emit("runTest", data);