Merge branch 'master' of https://github.com/metersphere/metersphere into master

This commit is contained in:
BugKing 2021-03-23 15:08:07 +08:00
commit 1e81835dcf
4 changed files with 67 additions and 31 deletions

View File

@ -63,6 +63,7 @@ public class ApiDefinitionController {
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
return PageUtils.setPageInfo(page, apiDefinitionService.listRelevance(request));
}
@PostMapping("/list/relevance/review/{goPage}/{pageSize}")
public Pager<List<ApiDefinitionResult>> listRelevanceReview(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
@ -103,7 +104,7 @@ public class ApiDefinitionController {
@PostMapping(value = "/updateEsbRequest")
public SaveApiDefinitionRequest updateEsbRequest(@RequestBody SaveApiDefinitionRequest request) {
if(StringUtils.equals(request.getMethod(),"ESB")){
if (StringUtils.equals(request.getMethod(), "ESB")) {
//ESB的接口类型数据采用TCP方式去发送并将方法类型改为TCP 并修改发送数据
request = esbApiParamService.updateEsbRequest(request);
}
@ -180,15 +181,18 @@ public class ApiDefinitionController {
public void createSchedule(@RequestBody ScheduleRequest request) throws MalformedURLException {
apiDefinitionService.createSchedule(request);
}
@PostMapping(value = "/schedule/update")
public void updateSchedule(@RequestBody Schedule request){
public void updateSchedule(@RequestBody Schedule request) {
apiDefinitionService.updateSchedule(request);
}
//查找定时任务资源Id
@PostMapping(value = "/getResourceId")
public String getResourceId(@RequestBody SwaggerUrlRequest swaggerUrlRequest){
public String getResourceId(@RequestBody SwaggerUrlRequest swaggerUrlRequest) {
return apiDefinitionService.getResourceId(swaggerUrlRequest);
}
//查找定时任务列表
@GetMapping("/scheduleTask/{projectId}")
public List<SwaggerTaskResult> getSwaggerScheduleList(@PathVariable String projectId) {
@ -198,12 +202,13 @@ public class ApiDefinitionController {
resultList) {
swaggerTaskResult.setIndex(dataIndex++);
Date nextExecutionTime = CronUtils.getNextTriggerTime(swaggerTaskResult.getRule());
if(nextExecutionTime!=null){
if (nextExecutionTime != null) {
swaggerTaskResult.setNextExecutionTime(nextExecutionTime.getTime());
}
}
return resultList;
return resultList;
}
//更新定时任务
@PostMapping(value = "/schedule/updateByPrimyKey")
public void updateScheduleEnableByPrimyKey(@RequestBody ScheduleInfoSwaggerUrlRequest request) {
@ -211,11 +216,13 @@ public class ApiDefinitionController {
schedule.setEnable(request.getTaskStatus());
apiDefinitionService.updateSchedule(schedule);
}
//删除定时任务和swaggereUrl
@PostMapping("/schedule/deleteByPrimyKey")
public void deleteSchedule(@RequestBody ScheduleInfoSwaggerUrlRequest request) {
apiDefinitionService.deleteSchedule(request);
}
@PostMapping("/getReference")
public ReferenceDTO getReference(@RequestBody ApiScenarioRequest request) {
return apiDefinitionService.getReference(request);
@ -237,8 +244,9 @@ public class ApiDefinitionController {
public void testPlanRelevance(@RequestBody ApiCaseRelevanceRequest request) {
apiDefinitionService.testPlanRelevance(request);
}
@PostMapping("/relevance/review")
public void testCaseReviewRelevance(@RequestBody ApiCaseRelevanceRequest request){
public void testCaseReviewRelevance(@RequestBody ApiCaseRelevanceRequest request) {
apiDefinitionService.testCaseReviewRelevance(request);
}

View File

@ -40,4 +40,7 @@ public class ApiTestBatchRequest extends ApiTestCaseWithBLOBs {
private String protocol;
private String status;
private String envId;
}

View File

@ -50,7 +50,7 @@ public class ApiTestCaseService {
@Resource
TestPlanMapper testPlanMapper;
@Resource
TestCaseReviewMapper testCaseReviewMapper;
TestCaseReviewMapper testCaseReviewMapper;
@Resource
private ApiTestCaseMapper apiTestCaseMapper;
@Resource
@ -82,12 +82,12 @@ public class ApiTestCaseService {
public List<ApiTestCaseResult> list(ApiTestCaseRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
List<ApiTestCaseResult> returnList = extApiTestCaseMapper.list(request);
List<ApiTestCaseResult> returnList = extApiTestCaseMapper.list(request);
for (ApiTestCaseResult res : returnList) {
esbApiParamService.handleApiEsbParams(res);
}
return returnList;
return returnList;
}
public List<ApiTestCaseDTO> listSimple(ApiTestCaseRequest request) {
@ -230,7 +230,7 @@ public class ApiTestCaseService {
private ApiTestCase updateTest(SaveApiTestCaseRequest request) {
checkNameExist(request);
if(StringUtils.isNotEmpty(request.getEsbDataStruct())){
if (StringUtils.isNotEmpty(request.getEsbDataStruct())) {
request = esbApiParamService.handleEsbRequest(request);
}
@ -253,7 +253,7 @@ public class ApiTestCaseService {
request.setId(UUID.randomUUID().toString());
checkNameExist(request);
if(StringUtils.isNotEmpty(request.getEsbDataStruct())||StringUtils.isNotEmpty(request.getBackEsbDataStruct())){
if (StringUtils.isNotEmpty(request.getEsbDataStruct()) || StringUtils.isNotEmpty(request.getBackEsbDataStruct())) {
request = esbApiParamService.handleEsbRequest(request);
}
@ -332,7 +332,8 @@ public class ApiTestCaseService {
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
relevance(apiTestCases, request);
}
public void relevanceByApiByReview(ApiCaseRelevanceRequest request){
public void relevanceByApiByReview(ApiCaseRelevanceRequest request) {
List<String> ids = request.getSelectIds();
if (CollectionUtils.isEmpty(ids)) {
return;
@ -342,6 +343,7 @@ public class ApiTestCaseService {
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
relevanceByReview(apiTestCases, request);
}
public void relevanceByCase(ApiCaseRelevanceRequest request) {
List<String> ids = request.getSelectIds();
if (CollectionUtils.isEmpty(ids)) {
@ -391,7 +393,7 @@ public class ApiTestCaseService {
TestCaseReviewApiCase.setUpdateTime(System.currentTimeMillis());
batchMapper.insertIfNotExists(TestCaseReviewApiCase);
});
TestCaseReview testCaseReview=testCaseReviewMapper.selectByPrimaryKey(request.getReviewId());
TestCaseReview testCaseReview = testCaseReviewMapper.selectByPrimaryKey(request.getReviewId());
if (StringUtils.equals(testCaseReview.getStatus(), TestPlanStatus.Prepare.name())
|| StringUtils.equals(testCaseReview.getStatus(), TestPlanStatus.Completed.name())) {
testCaseReview.setStatus(TestPlanStatus.Underway.name());
@ -399,11 +401,13 @@ public class ApiTestCaseService {
}
sqlSession.flushStatements();
}
public List<String> selectIdsNotExistsInPlan(String projectId, String 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) {
@ -497,7 +501,22 @@ public class ApiTestCaseService {
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) {

View File

@ -181,7 +181,7 @@
this.visible = false;
},
runRefresh(data) {
runRefresh() {
this.batchLoadingIds = [];
this.singleLoading = false;
this.singleRunId = "";
@ -192,12 +192,9 @@
this.$set(item, 'selected', false);
})
}
//
let cases = this.apiCaseList[0];
cases.request.useEnvironment = this.environment;
cases.message = true;
this.$refs.apiCaseItem[0].saveCase(cases);
this.refresh();
//
let obj = {envId: this.environment, show: true};
this.batchEdit(obj);
this.$success(this.$t('organization.integration.successful_operation'));
},
@ -286,6 +283,8 @@
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
this.selectdCases = [];
this.selectdCases.push(row.id);
this.runData = [];
this.singleLoading = true;
this.singleRunId = row.id;
@ -304,6 +303,7 @@
}
this.runData = [];
this.batchLoadingIds = [];
this.selectdCases = [];
if (this.apiCaseList.length > 0) {
this.apiCaseList.forEach(item => {
if (item.selected && item.id) {
@ -311,6 +311,7 @@
item.request.useEnvironment = this.environment;
this.runData.push(item.request);
this.batchLoadingIds.push(item.id);
this.selectdCases.push(item.id);
}
})
if (this.runData.length > 0) {
@ -350,17 +351,22 @@
},
batchEdit(form) {
let param = {};
param[form.type] = form.value;
param.ids = this.selectdCases;
param.projectId = getCurrentProjectID();
if (this.api) {
param.protocol = this.api.protocol;
if (form) {
param[form.type] = form.value;
param.ids = this.selectdCases;
param.projectId = getCurrentProjectID();
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.$success(this.$t('commons.save_success'));
if (!form.show) {
this.$success(this.$t('commons.save_success'));
}
this.selectdCases = [];
this.getApiTest();
});