接口测试结果刷新

This commit is contained in:
chenjianxing 2020-06-03 11:58:26 +08:00
commit 6f4d91102f
2 changed files with 12 additions and 20 deletions

View File

@ -20,6 +20,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
@ -122,7 +123,16 @@ public class APITestService {
apiTestMapper.updateByPrimaryKeySelective(apiTest); apiTestMapper.updateByPrimaryKeySelective(apiTest);
} }
private void checkNameExist(SaveAPITestRequest request) {
ApiTestExample example = new ApiTestExample();
example.createCriteria().andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId()).andIdNotEqualTo(request.getId());
if (apiTestMapper.countByExample(example) > 0) {
MSException.throwException(Translator.get("load_test_already_exists"));
}
}
private ApiTestWithBLOBs updateTest(SaveAPITestRequest request) { private ApiTestWithBLOBs updateTest(SaveAPITestRequest request) {
checkNameExist(request);
final ApiTestWithBLOBs test = new ApiTestWithBLOBs(); final ApiTestWithBLOBs test = new ApiTestWithBLOBs();
test.setId(request.getId()); test.setId(request.getId());
test.setName(request.getName()); test.setName(request.getName());
@ -130,31 +140,12 @@ public class APITestService {
test.setScenarioDefinition(request.getScenarioDefinition()); test.setScenarioDefinition(request.getScenarioDefinition());
test.setUpdateTime(System.currentTimeMillis()); test.setUpdateTime(System.currentTimeMillis());
test.setStatus(APITestStatus.Saved.name()); test.setStatus(APITestStatus.Saved.name());
checkApiTestExist(test);
apiTestMapper.updateByPrimaryKeySelective(test); apiTestMapper.updateByPrimaryKeySelective(test);
return test; return test;
} }
private void checkApiTestExist(ApiTest apiTest) {
if (apiTest.getName() != null) {
ApiTestExample example = new ApiTestExample();
example.createCriteria()
.andNameEqualTo(apiTest.getName())
.andProjectIdEqualTo(apiTest.getProjectId())
.andIdNotEqualTo(apiTest.getId());
if (apiTestMapper.selectByExample(example).size() > 0) {
MSException.throwException(Translator.get("api_test_name_already_exists"));
}
}
}
private ApiTestWithBLOBs createTest(SaveAPITestRequest request) { private ApiTestWithBLOBs createTest(SaveAPITestRequest request) {
ApiTestExample example = new ApiTestExample(); checkNameExist(request);
example.createCriteria().andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId());
if (apiTestMapper.countByExample(example) > 0) {
MSException.throwException(Translator.get("load_test_already_exists"));
}
final ApiTestWithBLOBs test = new ApiTestWithBLOBs(); final ApiTestWithBLOBs test = new ApiTestWithBLOBs();
test.setId(request.getId()); test.setId(request.getId());
test.setName(request.getName()); test.setName(request.getName());

View File

@ -347,6 +347,7 @@
testTabChange(data) { testTabChange(data) {
if (this.testCase.type == 'performance' && data.paneName == 'result') { if (this.testCase.type == 'performance' && data.paneName == 'result') {
this.$refs.performanceTestResult.checkReportStatus(); this.$refs.performanceTestResult.checkReportStatus();
this.$refs.performanceTestResult.init();
} }
}, },
saveReport(reportId) { saveReport(reportId) {