Merge branch 'master' of https://github.com/metersphere/metersphere into master
This commit is contained in:
commit
1e81835dcf
|
@ -63,6 +63,7 @@ public class ApiDefinitionController {
|
||||||
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
return PageUtils.setPageInfo(page, apiDefinitionService.listRelevance(request));
|
return PageUtils.setPageInfo(page, apiDefinitionService.listRelevance(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/list/relevance/review/{goPage}/{pageSize}")
|
@PostMapping("/list/relevance/review/{goPage}/{pageSize}")
|
||||||
public Pager<List<ApiDefinitionResult>> listRelevanceReview(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) {
|
public Pager<List<ApiDefinitionResult>> listRelevanceReview(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) {
|
||||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||||
|
@ -103,7 +104,7 @@ public class ApiDefinitionController {
|
||||||
|
|
||||||
@PostMapping(value = "/updateEsbRequest")
|
@PostMapping(value = "/updateEsbRequest")
|
||||||
public SaveApiDefinitionRequest updateEsbRequest(@RequestBody SaveApiDefinitionRequest request) {
|
public SaveApiDefinitionRequest updateEsbRequest(@RequestBody SaveApiDefinitionRequest request) {
|
||||||
if(StringUtils.equals(request.getMethod(),"ESB")){
|
if (StringUtils.equals(request.getMethod(), "ESB")) {
|
||||||
//ESB的接口类型数据,采用TCP方式去发送。并将方法类型改为TCP。 并修改发送数据
|
//ESB的接口类型数据,采用TCP方式去发送。并将方法类型改为TCP。 并修改发送数据
|
||||||
request = esbApiParamService.updateEsbRequest(request);
|
request = esbApiParamService.updateEsbRequest(request);
|
||||||
}
|
}
|
||||||
|
@ -180,15 +181,18 @@ public class ApiDefinitionController {
|
||||||
public void createSchedule(@RequestBody ScheduleRequest request) throws MalformedURLException {
|
public void createSchedule(@RequestBody ScheduleRequest request) throws MalformedURLException {
|
||||||
apiDefinitionService.createSchedule(request);
|
apiDefinitionService.createSchedule(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/schedule/update")
|
@PostMapping(value = "/schedule/update")
|
||||||
public void updateSchedule(@RequestBody Schedule request){
|
public void updateSchedule(@RequestBody Schedule request) {
|
||||||
apiDefinitionService.updateSchedule(request);
|
apiDefinitionService.updateSchedule(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
//查找定时任务资源Id
|
//查找定时任务资源Id
|
||||||
@PostMapping(value = "/getResourceId")
|
@PostMapping(value = "/getResourceId")
|
||||||
public String getResourceId(@RequestBody SwaggerUrlRequest swaggerUrlRequest){
|
public String getResourceId(@RequestBody SwaggerUrlRequest swaggerUrlRequest) {
|
||||||
return apiDefinitionService.getResourceId(swaggerUrlRequest);
|
return apiDefinitionService.getResourceId(swaggerUrlRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
//查找定时任务列表
|
//查找定时任务列表
|
||||||
@GetMapping("/scheduleTask/{projectId}")
|
@GetMapping("/scheduleTask/{projectId}")
|
||||||
public List<SwaggerTaskResult> getSwaggerScheduleList(@PathVariable String projectId) {
|
public List<SwaggerTaskResult> getSwaggerScheduleList(@PathVariable String projectId) {
|
||||||
|
@ -198,12 +202,13 @@ public class ApiDefinitionController {
|
||||||
resultList) {
|
resultList) {
|
||||||
swaggerTaskResult.setIndex(dataIndex++);
|
swaggerTaskResult.setIndex(dataIndex++);
|
||||||
Date nextExecutionTime = CronUtils.getNextTriggerTime(swaggerTaskResult.getRule());
|
Date nextExecutionTime = CronUtils.getNextTriggerTime(swaggerTaskResult.getRule());
|
||||||
if(nextExecutionTime!=null){
|
if (nextExecutionTime != null) {
|
||||||
swaggerTaskResult.setNextExecutionTime(nextExecutionTime.getTime());
|
swaggerTaskResult.setNextExecutionTime(nextExecutionTime.getTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
//更新定时任务
|
//更新定时任务
|
||||||
@PostMapping(value = "/schedule/updateByPrimyKey")
|
@PostMapping(value = "/schedule/updateByPrimyKey")
|
||||||
public void updateScheduleEnableByPrimyKey(@RequestBody ScheduleInfoSwaggerUrlRequest request) {
|
public void updateScheduleEnableByPrimyKey(@RequestBody ScheduleInfoSwaggerUrlRequest request) {
|
||||||
|
@ -211,11 +216,13 @@ public class ApiDefinitionController {
|
||||||
schedule.setEnable(request.getTaskStatus());
|
schedule.setEnable(request.getTaskStatus());
|
||||||
apiDefinitionService.updateSchedule(schedule);
|
apiDefinitionService.updateSchedule(schedule);
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除定时任务和swaggereUrl
|
//删除定时任务和swaggereUrl
|
||||||
@PostMapping("/schedule/deleteByPrimyKey")
|
@PostMapping("/schedule/deleteByPrimyKey")
|
||||||
public void deleteSchedule(@RequestBody ScheduleInfoSwaggerUrlRequest request) {
|
public void deleteSchedule(@RequestBody ScheduleInfoSwaggerUrlRequest request) {
|
||||||
apiDefinitionService.deleteSchedule(request);
|
apiDefinitionService.deleteSchedule(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/getReference")
|
@PostMapping("/getReference")
|
||||||
public ReferenceDTO getReference(@RequestBody ApiScenarioRequest request) {
|
public ReferenceDTO getReference(@RequestBody ApiScenarioRequest request) {
|
||||||
return apiDefinitionService.getReference(request);
|
return apiDefinitionService.getReference(request);
|
||||||
|
@ -237,8 +244,9 @@ public class ApiDefinitionController {
|
||||||
public void testPlanRelevance(@RequestBody ApiCaseRelevanceRequest request) {
|
public void testPlanRelevance(@RequestBody ApiCaseRelevanceRequest request) {
|
||||||
apiDefinitionService.testPlanRelevance(request);
|
apiDefinitionService.testPlanRelevance(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/relevance/review")
|
@PostMapping("/relevance/review")
|
||||||
public void testCaseReviewRelevance(@RequestBody ApiCaseRelevanceRequest request){
|
public void testCaseReviewRelevance(@RequestBody ApiCaseRelevanceRequest request) {
|
||||||
apiDefinitionService.testCaseReviewRelevance(request);
|
apiDefinitionService.testCaseReviewRelevance(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,4 +40,7 @@ public class ApiTestBatchRequest extends ApiTestCaseWithBLOBs {
|
||||||
private String protocol;
|
private String protocol;
|
||||||
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
private String envId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ApiTestCaseService {
|
||||||
@Resource
|
@Resource
|
||||||
TestPlanMapper testPlanMapper;
|
TestPlanMapper testPlanMapper;
|
||||||
@Resource
|
@Resource
|
||||||
TestCaseReviewMapper testCaseReviewMapper;
|
TestCaseReviewMapper testCaseReviewMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiTestCaseMapper apiTestCaseMapper;
|
private ApiTestCaseMapper apiTestCaseMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -82,12 +82,12 @@ public class ApiTestCaseService {
|
||||||
|
|
||||||
public List<ApiTestCaseResult> list(ApiTestCaseRequest request) {
|
public List<ApiTestCaseResult> list(ApiTestCaseRequest request) {
|
||||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||||
List<ApiTestCaseResult> returnList = extApiTestCaseMapper.list(request);
|
List<ApiTestCaseResult> returnList = extApiTestCaseMapper.list(request);
|
||||||
|
|
||||||
for (ApiTestCaseResult res : returnList) {
|
for (ApiTestCaseResult res : returnList) {
|
||||||
esbApiParamService.handleApiEsbParams(res);
|
esbApiParamService.handleApiEsbParams(res);
|
||||||
}
|
}
|
||||||
return returnList;
|
return returnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ApiTestCaseDTO> listSimple(ApiTestCaseRequest request) {
|
public List<ApiTestCaseDTO> listSimple(ApiTestCaseRequest request) {
|
||||||
|
@ -230,7 +230,7 @@ public class ApiTestCaseService {
|
||||||
private ApiTestCase updateTest(SaveApiTestCaseRequest request) {
|
private ApiTestCase updateTest(SaveApiTestCaseRequest request) {
|
||||||
checkNameExist(request);
|
checkNameExist(request);
|
||||||
|
|
||||||
if(StringUtils.isNotEmpty(request.getEsbDataStruct())){
|
if (StringUtils.isNotEmpty(request.getEsbDataStruct())) {
|
||||||
request = esbApiParamService.handleEsbRequest(request);
|
request = esbApiParamService.handleEsbRequest(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ public class ApiTestCaseService {
|
||||||
request.setId(UUID.randomUUID().toString());
|
request.setId(UUID.randomUUID().toString());
|
||||||
checkNameExist(request);
|
checkNameExist(request);
|
||||||
|
|
||||||
if(StringUtils.isNotEmpty(request.getEsbDataStruct())||StringUtils.isNotEmpty(request.getBackEsbDataStruct())){
|
if (StringUtils.isNotEmpty(request.getEsbDataStruct()) || StringUtils.isNotEmpty(request.getBackEsbDataStruct())) {
|
||||||
request = esbApiParamService.handleEsbRequest(request);
|
request = esbApiParamService.handleEsbRequest(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +332,8 @@ public class ApiTestCaseService {
|
||||||
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
|
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
|
||||||
relevance(apiTestCases, request);
|
relevance(apiTestCases, request);
|
||||||
}
|
}
|
||||||
public void relevanceByApiByReview(ApiCaseRelevanceRequest request){
|
|
||||||
|
public void relevanceByApiByReview(ApiCaseRelevanceRequest request) {
|
||||||
List<String> ids = request.getSelectIds();
|
List<String> ids = request.getSelectIds();
|
||||||
if (CollectionUtils.isEmpty(ids)) {
|
if (CollectionUtils.isEmpty(ids)) {
|
||||||
return;
|
return;
|
||||||
|
@ -342,6 +343,7 @@ public class ApiTestCaseService {
|
||||||
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
|
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
|
||||||
relevanceByReview(apiTestCases, request);
|
relevanceByReview(apiTestCases, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void relevanceByCase(ApiCaseRelevanceRequest request) {
|
public void relevanceByCase(ApiCaseRelevanceRequest request) {
|
||||||
List<String> ids = request.getSelectIds();
|
List<String> ids = request.getSelectIds();
|
||||||
if (CollectionUtils.isEmpty(ids)) {
|
if (CollectionUtils.isEmpty(ids)) {
|
||||||
|
@ -391,7 +393,7 @@ public class ApiTestCaseService {
|
||||||
TestCaseReviewApiCase.setUpdateTime(System.currentTimeMillis());
|
TestCaseReviewApiCase.setUpdateTime(System.currentTimeMillis());
|
||||||
batchMapper.insertIfNotExists(TestCaseReviewApiCase);
|
batchMapper.insertIfNotExists(TestCaseReviewApiCase);
|
||||||
});
|
});
|
||||||
TestCaseReview testCaseReview=testCaseReviewMapper.selectByPrimaryKey(request.getReviewId());
|
TestCaseReview testCaseReview = testCaseReviewMapper.selectByPrimaryKey(request.getReviewId());
|
||||||
if (StringUtils.equals(testCaseReview.getStatus(), TestPlanStatus.Prepare.name())
|
if (StringUtils.equals(testCaseReview.getStatus(), TestPlanStatus.Prepare.name())
|
||||||
|| StringUtils.equals(testCaseReview.getStatus(), TestPlanStatus.Completed.name())) {
|
|| StringUtils.equals(testCaseReview.getStatus(), TestPlanStatus.Completed.name())) {
|
||||||
testCaseReview.setStatus(TestPlanStatus.Underway.name());
|
testCaseReview.setStatus(TestPlanStatus.Underway.name());
|
||||||
|
@ -399,11 +401,13 @@ public class ApiTestCaseService {
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> selectIdsNotExistsInPlan(String projectId, String planId) {
|
public List<String> selectIdsNotExistsInPlan(String projectId, String planId) {
|
||||||
return extApiTestCaseMapper.selectIdsNotExistsInPlan(projectId, planId);
|
return extApiTestCaseMapper.selectIdsNotExistsInPlan(projectId, planId);
|
||||||
}
|
}
|
||||||
public List<String> selectIdsNotExistsInReview(String projectId,String reviewId){
|
|
||||||
return extApiTestCaseMapper.selectIdsNotExistsInReview(projectId,reviewId);
|
public List<String> selectIdsNotExistsInReview(String projectId, String reviewId) {
|
||||||
|
return extApiTestCaseMapper.selectIdsNotExistsInReview(projectId, reviewId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ApiDataCountResult> countProtocolByProjectID(String projectId) {
|
public List<ApiDataCountResult> countProtocolByProjectID(String projectId) {
|
||||||
|
@ -497,7 +501,22 @@ public class ApiTestCaseService {
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (StringUtils.isNotEmpty(request.getEnvId())) {
|
||||||
|
List<ApiTestCaseWithBLOBs> bloBs = apiTestCaseMapper.selectByExampleWithBLOBs(apiDefinitionExample);
|
||||||
|
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||||
|
ApiTestCaseMapper batchMapper = sqlSession.getMapper(ApiTestCaseMapper.class);
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
bloBs.forEach(apiTestCase -> {
|
||||||
|
JSONObject req = JSON.parseObject(apiTestCase.getRequest());
|
||||||
|
req.put("useEnvironment", request.getEnvId());
|
||||||
|
String requestStr = JSON.toJSONString(req);
|
||||||
|
apiTestCase.setRequest(requestStr);
|
||||||
|
batchMapper.updateByPrimaryKeySelective(apiTestCase);
|
||||||
|
});
|
||||||
|
sqlSession.flushStatements();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getAllApiCaseIdsByFontedSelect(Map<String, List<String>> filters, List<String> moduleIds, String name, String projectId, String protocol, List<String> unSelectIds, String status) {
|
private List<String> getAllApiCaseIdsByFontedSelect(Map<String, List<String>> filters, List<String> moduleIds, String name, String projectId, String protocol, List<String> unSelectIds, String status) {
|
||||||
|
|
|
@ -181,7 +181,7 @@
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
runRefresh(data) {
|
runRefresh() {
|
||||||
this.batchLoadingIds = [];
|
this.batchLoadingIds = [];
|
||||||
this.singleLoading = false;
|
this.singleLoading = false;
|
||||||
this.singleRunId = "";
|
this.singleRunId = "";
|
||||||
|
@ -192,12 +192,9 @@
|
||||||
this.$set(item, 'selected', false);
|
this.$set(item, 'selected', false);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 更新最后一条的环境
|
// 批量更新最后执行环境
|
||||||
let cases = this.apiCaseList[0];
|
let obj = {envId: this.environment, show: true};
|
||||||
cases.request.useEnvironment = this.environment;
|
this.batchEdit(obj);
|
||||||
cases.message = true;
|
|
||||||
this.$refs.apiCaseItem[0].saveCase(cases);
|
|
||||||
this.refresh();
|
|
||||||
this.$success(this.$t('organization.integration.successful_operation'));
|
this.$success(this.$t('organization.integration.successful_operation'));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -286,6 +283,8 @@
|
||||||
this.$warning(this.$t('api_test.environment.select_environment'));
|
this.$warning(this.$t('api_test.environment.select_environment'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.selectdCases = [];
|
||||||
|
this.selectdCases.push(row.id);
|
||||||
this.runData = [];
|
this.runData = [];
|
||||||
this.singleLoading = true;
|
this.singleLoading = true;
|
||||||
this.singleRunId = row.id;
|
this.singleRunId = row.id;
|
||||||
|
@ -304,6 +303,7 @@
|
||||||
}
|
}
|
||||||
this.runData = [];
|
this.runData = [];
|
||||||
this.batchLoadingIds = [];
|
this.batchLoadingIds = [];
|
||||||
|
this.selectdCases = [];
|
||||||
if (this.apiCaseList.length > 0) {
|
if (this.apiCaseList.length > 0) {
|
||||||
this.apiCaseList.forEach(item => {
|
this.apiCaseList.forEach(item => {
|
||||||
if (item.selected && item.id) {
|
if (item.selected && item.id) {
|
||||||
|
@ -311,6 +311,7 @@
|
||||||
item.request.useEnvironment = this.environment;
|
item.request.useEnvironment = this.environment;
|
||||||
this.runData.push(item.request);
|
this.runData.push(item.request);
|
||||||
this.batchLoadingIds.push(item.id);
|
this.batchLoadingIds.push(item.id);
|
||||||
|
this.selectdCases.push(item.id);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (this.runData.length > 0) {
|
if (this.runData.length > 0) {
|
||||||
|
@ -350,17 +351,22 @@
|
||||||
},
|
},
|
||||||
batchEdit(form) {
|
batchEdit(form) {
|
||||||
let param = {};
|
let param = {};
|
||||||
param[form.type] = form.value;
|
if (form) {
|
||||||
param.ids = this.selectdCases;
|
param[form.type] = form.value;
|
||||||
param.projectId = getCurrentProjectID();
|
param.ids = this.selectdCases;
|
||||||
if (this.api) {
|
param.projectId = getCurrentProjectID();
|
||||||
param.protocol = this.api.protocol;
|
param.envId = form.envId;
|
||||||
|
if (this.api) {
|
||||||
|
param.protocol = this.api.protocol;
|
||||||
|
}
|
||||||
|
param.selectAllDate = this.isSelectAllDate;
|
||||||
|
param.unSelectIds = this.unSelection;
|
||||||
|
param = Object.assign(param, this.condition);
|
||||||
}
|
}
|
||||||
param.selectAllDate = this.isSelectAllDate;
|
|
||||||
param.unSelectIds = this.unSelection;
|
|
||||||
param = Object.assign(param, this.condition);
|
|
||||||
this.$post('/api/testcase/batch/editByParam', param, () => {
|
this.$post('/api/testcase/batch/editByParam', param, () => {
|
||||||
this.$success(this.$t('commons.save_success'));
|
if (!form.show) {
|
||||||
|
this.$success(this.$t('commons.save_success'));
|
||||||
|
}
|
||||||
this.selectdCases = [];
|
this.selectdCases = [];
|
||||||
this.getApiTest();
|
this.getApiTest();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue