# Conflicts:
#	backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java
This commit is contained in:
fit2-zhao 2020-12-22 14:08:52 +08:00
commit 6b83a68db2
80 changed files with 3674 additions and 940 deletions

View File

@ -3,12 +3,12 @@ package io.metersphere.api.controller;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.*; import io.metersphere.api.dto.*;
import io.metersphere.api.dto.dataCount.ApiDataCountResult; import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.api.dto.dataCount.ExecutedCaseInfoResult; import io.metersphere.api.dto.datacount.ExecutedCaseInfoResult;
import io.metersphere.api.dto.dataCount.request.ScheduleInfoRequest; import io.metersphere.api.dto.datacount.request.ScheduleInfoRequest;
import io.metersphere.api.dto.dataCount.response.ApiDataCountDTO; import io.metersphere.api.dto.datacount.response.ApiDataCountDTO;
import io.metersphere.api.dto.dataCount.response.ExecutedCaseInfoDTO; import io.metersphere.api.dto.datacount.response.ExecutedCaseInfoDTO;
import io.metersphere.api.dto.dataCount.response.TaskInfoResult; import io.metersphere.api.dto.datacount.response.TaskInfoResult;
import io.metersphere.api.dto.scenario.request.dubbo.RegistryCenter; import io.metersphere.api.dto.scenario.request.dubbo.RegistryCenter;
import io.metersphere.api.service.*; import io.metersphere.api.service.*;
import io.metersphere.base.domain.ApiTest; import io.metersphere.base.domain.ApiTest;

View File

@ -14,6 +14,7 @@ import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles; import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -92,6 +93,11 @@ public class ApiDefinitionController {
return apiDefinitionService.getDbResult(testId); return apiDefinitionService.getDbResult(testId);
} }
@GetMapping("/report/getReport/{testId}/{type}")
public APIReportResult getReport(@PathVariable String testId, @PathVariable String type) {
return apiDefinitionService.getDbResult(testId, type);
}
@PostMapping(value = "/import", consumes = {"multipart/form-data"}) @PostMapping(value = "/import", consumes = {"multipart/form-data"})
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public ApiDefinitionImport testCaseImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) { public ApiDefinitionImport testCaseImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) {
@ -109,4 +115,8 @@ public class ApiDefinitionController {
apiDefinitionService.editApiBath(request); apiDefinitionService.editApiBath(request);
} }
@PostMapping("/relevance")
public void testPlanRelevance(@RequestBody ApiCaseRelevanceRequest request) {
apiDefinitionService.testPlanRelevance(request);
}
} }

View File

@ -3,14 +3,17 @@ package io.metersphere.api.controller;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.ApiCaseBatchRequest; import io.metersphere.api.dto.ApiCaseBatchRequest;
import io.metersphere.api.dto.definition.*; import io.metersphere.api.dto.definition.ApiTestCaseDTO;
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.ApiTestCaseResult;
import io.metersphere.api.dto.definition.SaveApiTestCaseRequest;
import io.metersphere.api.service.ApiTestCaseService; import io.metersphere.api.service.ApiTestCaseService;
import io.metersphere.base.domain.ApiTestCase;
import io.metersphere.base.domain.ApiTestCaseWithBLOBs; import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles; import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -75,4 +78,9 @@ public class ApiTestCaseController {
public void deleteBatch(@RequestBody List<String> ids) { public void deleteBatch(@RequestBody List<String> ids) {
apiTestCaseService.deleteBatch(ids); apiTestCaseService.deleteBatch(ids);
} }
@PostMapping("/relevance")
public void testPlanRelevance(@RequestBody ApiCaseRelevanceRequest request) {
apiTestCaseService.relevanceByCase(request);
}
} }

View File

@ -1,4 +1,4 @@
package io.metersphere.api.dto.dataCount; package io.metersphere.api.dto.datacount;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

View File

@ -1,4 +1,4 @@
package io.metersphere.api.dto.dataCount; package io.metersphere.api.dto.datacount;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

View File

@ -1,4 +1,4 @@
package io.metersphere.api.dto.dataCount.request; package io.metersphere.api.dto.datacount.request;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

View File

@ -1,14 +1,11 @@
package io.metersphere.api.dto.dataCount.response; package io.metersphere.api.dto.datacount.response;
import io.metersphere.api.dto.dataCount.ApiDataCountResult; import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.api.dto.scenario.request.RequestType; import io.metersphere.api.dto.scenario.request.RequestType;
import io.metersphere.base.domain.ApiDefinition;
import io.metersphere.commons.constants.APITestStatus;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List; import java.util.List;
import java.util.Locale;
/** /**
* 接口数据统计返回 * 接口数据统计返回
@ -118,7 +115,7 @@ public class ApiDataCountDTO {
/** /**
* 对Protocal视角对查询结果进行统计 * 对Protocal视角对查询结果进行统计
* @param countResultList * @param countResultList 查询参数
*/ */
public void countProtocal(List<ApiDataCountResult> countResultList){ public void countProtocal(List<ApiDataCountResult> countResultList){
for (ApiDataCountResult countResult : for (ApiDataCountResult countResult :
@ -146,16 +143,17 @@ public class ApiDataCountDTO {
/** /**
* 对Status视角对查询结果进行统计 * 对Status视角对查询结果进行统计
* @param countResultList * @param countResultList 查询参数
*/ */
public void countStatus(List<ApiDataCountResult> countResultList){ public void countStatus(List<ApiDataCountResult> countResultList){
for (ApiDataCountResult countResult : for (ApiDataCountResult countResult :
countResultList) { countResultList) {
if("Underway".equals(countResult.getGroupField())){ if("Underway".equals(countResult.getGroupField())){
//未开始
this.runningCount+= countResult.getCountNumber(); this.runningCount+= countResult.getCountNumber();
}else if("Completed".equals(countResult.getGroupField())){ }else if("Completed".equals(countResult.getGroupField())){
this.finishedCount+= countResult.getCountNumber(); this.finishedCount+= countResult.getCountNumber();
}else if("Trash".equals(countResult.getGroupField())){ }else if("Prepare".equals(countResult.getGroupField())){
this.notStartedCount+= countResult.getCountNumber(); this.notStartedCount+= countResult.getCountNumber();
} }
} }

View File

@ -1,4 +1,4 @@
package io.metersphere.api.dto.dataCount.response; package io.metersphere.api.dto.datacount.response;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

View File

@ -1,8 +1,7 @@
package io.metersphere.api.dto.dataCount.response; package io.metersphere.api.dto.datacount.response;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.python.antlr.ast.Str;
/** /**
* 任务信息 返回DTO * 任务信息 返回DTO

View File

@ -11,6 +11,8 @@ import java.util.Map;
@Setter @Setter
public class ApiTestCaseRequest { public class ApiTestCaseRequest {
private String id; private String id;
private List<String> ids;
private String planId;
private String projectId; private String projectId;
private String priority; private String priority;
private String name; private String name;
@ -18,6 +20,7 @@ public class ApiTestCaseRequest {
private String workspaceId; private String workspaceId;
private String apiDefinitionId; private String apiDefinitionId;
private String status; private String status;
private String protocol;
private List<String> moduleIds; private List<String> moduleIds;
private List<OrderRequest> orders; private List<OrderRequest> orders;
private Map<String, List<String>> filters; private Map<String, List<String>> filters;

View File

@ -15,6 +15,8 @@ public class RunDefinitionRequest {
private String reportId; private String reportId;
private String type;
private String projectId; private String projectId;
private String environmentId; private String environmentId;

View File

@ -0,0 +1,13 @@
package io.metersphere.api.dto.definition;
import io.metersphere.base.domain.ApiTestCase;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class TestPlanApiCaseDTO extends ApiTestCaseDTO {
private String environmentId;
private String caseId;
private String execResult;
}

View File

@ -165,13 +165,17 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
apiDefinitionService.addResult(testResult); apiDefinitionService.addResult(testResult);
} else { } else {
apiDefinitionService.addResult(testResult); apiDefinitionService.addResult(testResult);
apiDefinitionExecResultService.saveApiResult(testResult); apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.DELIMIT.name());
} }
} else if (StringUtils.equals(this.runMode, ApiRunMode.API_PLAN.name())) {
apiDefinitionService.addResult(testResult);
apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.API_PLAN.name());
} else if (StringUtils.equals(this.runMode, ApiRunMode.SCENARIO.name())) { } else if (StringUtils.equals(this.runMode, ApiRunMode.SCENARIO.name())) {
// 执行报告不需要存储由用户确认后在存储 // 执行报告不需要存储由用户确认后在存储
testResult.setTestId(testId); testResult.setTestId(testId);
apiScenarioReportService.complete(testResult); apiScenarioReportService.complete(testResult);
} else { }
else {
apiTestService.changeStatus(testId, APITestStatus.Completed); apiTestService.changeStatus(testId, APITestStatus.Completed);
report = apiReportService.getRunningReport(testResult.getTestId()); report = apiReportService.getRunningReport(testResult.getTestId());
apiReportService.complete(testResult, report); apiReportService.complete(testResult, report);

View File

@ -6,7 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import io.metersphere.api.dto.APIReportResult; import io.metersphere.api.dto.APIReportResult;
import io.metersphere.api.dto.DeleteAPIReportRequest; import io.metersphere.api.dto.DeleteAPIReportRequest;
import io.metersphere.api.dto.QueryAPIReportRequest; import io.metersphere.api.dto.QueryAPIReportRequest;
import io.metersphere.api.dto.dataCount.ApiDataCountResult; import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.api.jmeter.TestResult; import io.metersphere.api.jmeter.TestResult;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ApiDataViewMapper; import io.metersphere.base.mapper.ApiDataViewMapper;

View File

@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.client.utils.StringUtils; import com.alibaba.nacos.client.utils.StringUtils;
import io.github.ningyu.jmeter.plugin.dubbo.sample.ProviderService; import io.github.ningyu.jmeter.plugin.dubbo.sample.ProviderService;
import io.metersphere.api.dto.*; import io.metersphere.api.dto.*;
import io.metersphere.api.dto.dataCount.ApiDataCountResult;
import io.metersphere.api.dto.parse.ApiImport; import io.metersphere.api.dto.parse.ApiImport;
import io.metersphere.api.dto.scenario.request.dubbo.RegistryCenter; import io.metersphere.api.dto.scenario.request.dubbo.RegistryCenter;
import io.metersphere.api.jmeter.JMeterService; import io.metersphere.api.jmeter.JMeterService;

View File

@ -7,7 +7,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.metersphere.api.dto.automation.*; import io.metersphere.api.dto.automation.*;
import io.metersphere.api.dto.dataCount.ApiDataCountResult; import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.api.dto.definition.RunDefinitionRequest; import io.metersphere.api.dto.definition.RunDefinitionRequest;
import io.metersphere.api.dto.definition.request.*; import io.metersphere.api.dto.definition.request.*;
import io.metersphere.api.dto.scenario.KeyValue; import io.metersphere.api.dto.scenario.KeyValue;

View File

@ -1,9 +1,10 @@
package io.metersphere.api.service; package io.metersphere.api.service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import io.metersphere.api.dto.dataCount.ExecutedCaseInfoResult; import io.metersphere.api.dto.datacount.ExecutedCaseInfoResult;
import io.metersphere.api.jmeter.TestResult; import io.metersphere.api.jmeter.TestResult;
import io.metersphere.base.domain.ApiDefinitionExecResult; import io.metersphere.base.domain.ApiDefinitionExecResult;
import io.metersphere.base.domain.ApiDefinitionExecResultExample;
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper; import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper; import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
import io.metersphere.commons.utils.DateUtils; import io.metersphere.commons.utils.DateUtils;
@ -12,6 +13,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.*; import java.util.*;
@Service @Service
@ -23,7 +27,7 @@ public class ApiDefinitionExecResultService {
private ExtApiDefinitionExecResultMapper extApiDefinitionExecResultMapper; private ExtApiDefinitionExecResultMapper extApiDefinitionExecResultMapper;
public void saveApiResult(TestResult result) { public void saveApiResult(TestResult result, String type) {
result.getScenarios().get(0).getRequestResults().forEach(item -> { result.getScenarios().get(0).getRequestResults().forEach(item -> {
// 清理原始资源每个执行 保留一条结果 // 清理原始资源每个执行 保留一条结果
extApiDefinitionExecResultMapper.deleteByResourceId(item.getName()); extApiDefinitionExecResultMapper.deleteByResourceId(item.getName());
@ -35,12 +39,25 @@ public class ApiDefinitionExecResultService {
saveResult.setResourceId(item.getName()); saveResult.setResourceId(item.getName());
saveResult.setContent(JSON.toJSONString(item)); saveResult.setContent(JSON.toJSONString(item));
saveResult.setStartTime(item.getStartTime()); saveResult.setStartTime(item.getStartTime());
saveResult.setType(type);
saveResult.setEndTime(item.getResponseResult().getResponseTime()); saveResult.setEndTime(item.getResponseResult().getResponseTime());
saveResult.setStatus(item.getResponseResult().getResponseCode().equals("200") ? "success" : "error"); saveResult.setStatus(item.getResponseResult().getResponseCode().equals("200") ? "success" : "error");
apiDefinitionExecResultMapper.insert(saveResult); apiDefinitionExecResultMapper.insert(saveResult);
}); });
} }
public void deleteByResourceId(String resourceId) {
ApiDefinitionExecResultExample example = new ApiDefinitionExecResultExample();
example.createCriteria().andResourceIdEqualTo(resourceId);
apiDefinitionExecResultMapper.deleteByExample(example);
}
public void deleteByResourceIds(List<String> ids) {
ApiDefinitionExecResultExample example = new ApiDefinitionExecResultExample();
example.createCriteria().andResourceIdIn(ids);
apiDefinitionExecResultMapper.deleteByExample(example);
}
public long countByTestCaseIDInProjectAndExecutedInThisWeek(String projectId) { public long countByTestCaseIDInProjectAndExecutedInThisWeek(String projectId) {
Map<String, Date> startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date()); Map<String, Date> startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date());

View File

@ -6,7 +6,7 @@ import io.metersphere.api.dto.APIReportResult;
import io.metersphere.api.dto.ApiTestImportRequest; import io.metersphere.api.dto.ApiTestImportRequest;
import io.metersphere.api.dto.automation.ApiScenarioRequest; import io.metersphere.api.dto.automation.ApiScenarioRequest;
import io.metersphere.api.dto.automation.ReferenceDTO; import io.metersphere.api.dto.automation.ReferenceDTO;
import io.metersphere.api.dto.dataCount.ApiDataCountResult; import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.api.dto.definition.*; import io.metersphere.api.dto.definition.*;
import io.metersphere.api.dto.definition.parse.ApiDefinitionImport; import io.metersphere.api.dto.definition.parse.ApiDefinitionImport;
import io.metersphere.api.dto.scenario.request.RequestType; import io.metersphere.api.dto.scenario.request.RequestType;
@ -27,8 +27,10 @@ import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.*; import io.metersphere.commons.utils.*;
import io.metersphere.i18n.Translator; import io.metersphere.i18n.Translator;
import io.metersphere.service.FileService; import io.metersphere.service.FileService;
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
@ -290,8 +292,13 @@ public class ApiDefinitionService {
createBodyFiles(bodyUploadIds, bodyFiles); createBodyFiles(bodyUploadIds, bodyFiles);
HashTree hashTree = request.getTestElement().generateHashTree(); HashTree hashTree = request.getTestElement().generateHashTree();
String runMode = ApiRunMode.DELIMIT.name();
if (StringUtils.isNotBlank(request.getType()) && StringUtils.equals(request.getType(), ApiRunMode.API_PLAN.name())) {
runMode = ApiRunMode.API_PLAN.name();
}
request.getTestElement().getJmx(hashTree);
// 调用执行方法 // 调用执行方法
jMeterService.runDefinition(request.getId(), hashTree, request.getReportId(), ApiRunMode.DELIMIT.name()); jMeterService.runDefinition(request.getId(), hashTree, request.getReportId(), runMode);
return request.getId(); return request.getId();
} }
@ -329,6 +336,10 @@ public class ApiDefinitionService {
*/ */
public APIReportResult getDbResult(String testId) { public APIReportResult getDbResult(String testId) {
ApiDefinitionExecResult result = extApiDefinitionExecResultMapper.selectMaxResultByResourceId(testId); ApiDefinitionExecResult result = extApiDefinitionExecResultMapper.selectMaxResultByResourceId(testId);
return buildAPIReportResult(result);
}
private APIReportResult buildAPIReportResult(ApiDefinitionExecResult result) {
if (result == null) { if (result == null) {
return null; return null;
} }
@ -337,6 +348,11 @@ public class ApiDefinitionService {
return reportResult; return reportResult;
} }
public APIReportResult getDbResult(String testId, String type) {
ApiDefinitionExecResult result = extApiDefinitionExecResultMapper.selectMaxResultByResourceIdAndType(testId, type);
return buildAPIReportResult(result);
}
public ApiDefinitionImport apiTestImport(MultipartFile file, ApiTestImportRequest request) { public ApiDefinitionImport apiTestImport(MultipartFile file, ApiTestImportRequest request) {
ApiImportParser apiImportParser = ApiImportParserFactory.getApiImportParser(request.getPlatform()); ApiImportParser apiImportParser = ApiImportParserFactory.getApiImportParser(request.getPlatform());
@ -390,6 +406,10 @@ public class ApiDefinitionService {
apiDefinitionMapper.updateByExampleSelective(definitionWithBLOBs, definitionExample); apiDefinitionMapper.updateByExampleSelective(definitionWithBLOBs, definitionExample);
} }
public void testPlanRelevance(ApiCaseRelevanceRequest request) {
apiTestCaseService.relevanceByApi(request);
}
/** /**
* 数据统计-接口类型 * 数据统计-接口类型
* *

View File

@ -1,24 +1,28 @@
package io.metersphere.api.service; package io.metersphere.api.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import io.metersphere.api.dto.dataCount.ApiDataCountResult; import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.api.dto.definition.ApiTestCaseRequest; import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.ApiTestCaseResult; import io.metersphere.api.dto.definition.ApiTestCaseResult;
import io.metersphere.api.dto.definition.SaveApiTestCaseRequest; import io.metersphere.api.dto.definition.SaveApiTestCaseRequest;
import io.metersphere.api.dto.ApiCaseBatchRequest; import io.metersphere.api.dto.ApiCaseBatchRequest;
import io.metersphere.api.dto.definition.*; import io.metersphere.api.dto.definition.ApiTestCaseDTO;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ApiTestCaseMapper; import io.metersphere.base.mapper.ApiTestCaseMapper;
import io.metersphere.base.mapper.ApiTestFileMapper; import io.metersphere.base.mapper.ApiTestFileMapper;
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper; import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper; import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.*; import io.metersphere.commons.utils.*;
import io.metersphere.i18n.Translator; import io.metersphere.i18n.Translator;
import io.metersphere.notice.domain.UserDetail;
import io.metersphere.service.FileService; import io.metersphere.service.FileService;
import io.metersphere.service.QuotaService; import io.metersphere.service.QuotaService;
import io.metersphere.service.UserService; import io.metersphere.service.UserService;
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.aspectj.util.FileUtil; import org.aspectj.util.FileUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -36,6 +40,8 @@ public class ApiTestCaseService {
@Resource @Resource
private ApiTestCaseMapper apiTestCaseMapper; private ApiTestCaseMapper apiTestCaseMapper;
@Resource @Resource
private SqlSessionFactory sqlSessionFactory;
@Resource
private UserService userService; private UserService userService;
@Resource @Resource
private ExtApiTestCaseMapper extApiTestCaseMapper; private ExtApiTestCaseMapper extApiTestCaseMapper;
@ -59,6 +65,11 @@ public class ApiTestCaseService {
if (CollectionUtils.isEmpty(apiTestCases)) { if (CollectionUtils.isEmpty(apiTestCases)) {
return apiTestCases; return apiTestCases;
} }
buildUserInfo(apiTestCases);
return apiTestCases;
}
public void buildUserInfo(List<? extends ApiTestCaseDTO> apiTestCases) {
List<String> userIds = new ArrayList(); List<String> userIds = new ArrayList();
userIds.addAll(apiTestCases.stream().map(ApiTestCaseDTO::getCreateUserId).collect(Collectors.toList())); userIds.addAll(apiTestCases.stream().map(ApiTestCaseDTO::getCreateUserId).collect(Collectors.toList()));
userIds.addAll(apiTestCases.stream().map(ApiTestCaseDTO::getUpdateUserId).collect(Collectors.toList())); userIds.addAll(apiTestCases.stream().map(ApiTestCaseDTO::getUpdateUserId).collect(Collectors.toList()));
@ -69,7 +80,6 @@ public class ApiTestCaseService {
caseResult.setUpdateUser(userMap.get(caseResult.getUpdateUserId()).getName()); caseResult.setUpdateUser(userMap.get(caseResult.getUpdateUserId()).getName());
}); });
} }
return apiTestCases;
} }
public ApiTestCaseWithBLOBs get(String id) { public ApiTestCaseWithBLOBs get(String id) {
@ -248,6 +258,48 @@ public class ApiTestCaseService {
apiTestCaseMapper.deleteByExample(example); apiTestCaseMapper.deleteByExample(example);
} }
public void relevanceByApi(ApiCaseRelevanceRequest request) {
if (CollectionUtils.isEmpty(request.getSelectIds())) {
return;
}
ApiTestCaseExample example = new ApiTestCaseExample();
example.createCriteria().andApiDefinitionIdIn(request.getSelectIds());
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
relevance(apiTestCases, request);
}
public void relevanceByCase(ApiCaseRelevanceRequest request) {
List<String> ids = request.getSelectIds();
if (CollectionUtils.isEmpty(ids)) {
return;
}
ApiTestCaseExample example = new ApiTestCaseExample();
example.createCriteria().andIdIn(ids);
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
relevance(apiTestCases, request);
}
private void relevance(List<ApiTestCase> apiTestCases, ApiCaseRelevanceRequest request) {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
ExtTestPlanApiCaseMapper batchMapper = sqlSession.getMapper(ExtTestPlanApiCaseMapper.class);
apiTestCases.forEach(apiTestCase -> {
TestPlanApiCase testPlanApiCase = new TestPlanApiCase();
testPlanApiCase.setId(UUID.randomUUID().toString());
testPlanApiCase.setApiCaseId(apiTestCase.getId());
testPlanApiCase.setTestPlanId(request.getPlanId());
testPlanApiCase.setEnvironmentId(request.getEnvironmentId());
testPlanApiCase.setCreateTime(System.currentTimeMillis());
testPlanApiCase.setUpdateTime(System.currentTimeMillis());
batchMapper.insertIfNotExists(testPlanApiCase);
});
sqlSession.flushStatements();
}
public List<String> selectIdsNotExistsInPlan(String projectId, String planId) {
return extApiTestCaseMapper.selectIdsNotExistsInPlan(projectId, planId);
}
public List<ApiDataCountResult> countProtocolByProjectID(String projectId) { public List<ApiDataCountResult> countProtocolByProjectID(String projectId) {
return extApiTestCaseMapper.countProtocolByProjectID(projectId); return extApiTestCaseMapper.countProtocolByProjectID(projectId);
} }

View File

@ -21,6 +21,8 @@ public class ApiDefinitionExecResult implements Serializable {
private Long createTime; private Long createTime;
private String type;
private String content; private String content;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -633,6 +633,76 @@ public class ApiDefinitionExecResultExample {
addCriterion("create_time not between", value1, value2, "createTime"); addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeIsNull() {
addCriterion("`type` is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("`type` is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(String value) {
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(String value) {
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(String value) {
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(String value) {
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(String value) {
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(String value) {
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLike(String value) {
addCriterion("`type` like", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotLike(String value) {
addCriterion("`type` not like", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<String> values) {
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<String> values) {
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(String value1, String value2) {
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(String value1, String value2) {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -1,8 +1,7 @@
package io.metersphere.base.domain; package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import lombok.Data;
@Data @Data
public class TestPlan implements Serializable { public class TestPlan implements Serializable {

View File

@ -0,0 +1,23 @@
package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class TestPlanApiCase implements Serializable {
private String id;
private String testPlanId;
private String apiCaseId;
private String status;
private String environmentId;
private Long createTime;
private Long updateTime;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,670 @@
package io.metersphere.base.domain;
import java.util.ArrayList;
import java.util.List;
public class TestPlanApiCaseExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public TestPlanApiCaseExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andTestPlanIdIsNull() {
addCriterion("test_plan_id is null");
return (Criteria) this;
}
public Criteria andTestPlanIdIsNotNull() {
addCriterion("test_plan_id is not null");
return (Criteria) this;
}
public Criteria andTestPlanIdEqualTo(String value) {
addCriterion("test_plan_id =", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotEqualTo(String value) {
addCriterion("test_plan_id <>", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdGreaterThan(String value) {
addCriterion("test_plan_id >", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdGreaterThanOrEqualTo(String value) {
addCriterion("test_plan_id >=", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLessThan(String value) {
addCriterion("test_plan_id <", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLessThanOrEqualTo(String value) {
addCriterion("test_plan_id <=", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLike(String value) {
addCriterion("test_plan_id like", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotLike(String value) {
addCriterion("test_plan_id not like", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdIn(List<String> values) {
addCriterion("test_plan_id in", values, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotIn(List<String> values) {
addCriterion("test_plan_id not in", values, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdBetween(String value1, String value2) {
addCriterion("test_plan_id between", value1, value2, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotBetween(String value1, String value2) {
addCriterion("test_plan_id not between", value1, value2, "testPlanId");
return (Criteria) this;
}
public Criteria andApiCaseIdIsNull() {
addCriterion("api_case_id is null");
return (Criteria) this;
}
public Criteria andApiCaseIdIsNotNull() {
addCriterion("api_case_id is not null");
return (Criteria) this;
}
public Criteria andApiCaseIdEqualTo(String value) {
addCriterion("api_case_id =", value, "apiCaseId");
return (Criteria) this;
}
public Criteria andApiCaseIdNotEqualTo(String value) {
addCriterion("api_case_id <>", value, "apiCaseId");
return (Criteria) this;
}
public Criteria andApiCaseIdGreaterThan(String value) {
addCriterion("api_case_id >", value, "apiCaseId");
return (Criteria) this;
}
public Criteria andApiCaseIdGreaterThanOrEqualTo(String value) {
addCriterion("api_case_id >=", value, "apiCaseId");
return (Criteria) this;
}
public Criteria andApiCaseIdLessThan(String value) {
addCriterion("api_case_id <", value, "apiCaseId");
return (Criteria) this;
}
public Criteria andApiCaseIdLessThanOrEqualTo(String value) {
addCriterion("api_case_id <=", value, "apiCaseId");
return (Criteria) this;
}
public Criteria andApiCaseIdLike(String value) {
addCriterion("api_case_id like", value, "apiCaseId");
return (Criteria) this;
}
public Criteria andApiCaseIdNotLike(String value) {
addCriterion("api_case_id not like", value, "apiCaseId");
return (Criteria) this;
}
public Criteria andApiCaseIdIn(List<String> values) {
addCriterion("api_case_id in", values, "apiCaseId");
return (Criteria) this;
}
public Criteria andApiCaseIdNotIn(List<String> values) {
addCriterion("api_case_id not in", values, "apiCaseId");
return (Criteria) this;
}
public Criteria andApiCaseIdBetween(String value1, String value2) {
addCriterion("api_case_id between", value1, value2, "apiCaseId");
return (Criteria) this;
}
public Criteria andApiCaseIdNotBetween(String value1, String value2) {
addCriterion("api_case_id not between", value1, value2, "apiCaseId");
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("`status` is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(String value) {
addCriterion("`status` =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(String value) {
addCriterion("`status` <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(String value) {
addCriterion("`status` >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(String value) {
addCriterion("`status` >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(String value) {
addCriterion("`status` <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(String value) {
addCriterion("`status` <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLike(String value) {
addCriterion("`status` like", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotLike(String value) {
addCriterion("`status` not like", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<String> values) {
addCriterion("`status` in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<String> values) {
addCriterion("`status` not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(String value1, String value2) {
addCriterion("`status` between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(String value1, String value2) {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andEnvironmentIdIsNull() {
addCriterion("environment_id is null");
return (Criteria) this;
}
public Criteria andEnvironmentIdIsNotNull() {
addCriterion("environment_id is not null");
return (Criteria) this;
}
public Criteria andEnvironmentIdEqualTo(String value) {
addCriterion("environment_id =", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdNotEqualTo(String value) {
addCriterion("environment_id <>", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdGreaterThan(String value) {
addCriterion("environment_id >", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdGreaterThanOrEqualTo(String value) {
addCriterion("environment_id >=", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdLessThan(String value) {
addCriterion("environment_id <", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdLessThanOrEqualTo(String value) {
addCriterion("environment_id <=", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdLike(String value) {
addCriterion("environment_id like", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdNotLike(String value) {
addCriterion("environment_id not like", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdIn(List<String> values) {
addCriterion("environment_id in", values, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdNotIn(List<String> values) {
addCriterion("environment_id not in", values, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdBetween(String value1, String value2) {
addCriterion("environment_id between", value1, value2, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdNotBetween(String value1, String value2) {
addCriterion("environment_id not between", value1, value2, "environmentId");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Long value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Long value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Long value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Long value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Long> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Long> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Long value1, Long value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Long value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Long value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Long value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Long value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Long value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Long> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Long> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Long value1, Long value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Long value1, Long value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -0,0 +1,23 @@
package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class TestPlanApiScenario implements Serializable {
private String id;
private String testPlanId;
private String apiScenarioId;
private String status;
private String environmentId;
private Long createTime;
private Long updateTime;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,670 @@
package io.metersphere.base.domain;
import java.util.ArrayList;
import java.util.List;
public class TestPlanApiScenarioExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public TestPlanApiScenarioExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andTestPlanIdIsNull() {
addCriterion("test_plan_id is null");
return (Criteria) this;
}
public Criteria andTestPlanIdIsNotNull() {
addCriterion("test_plan_id is not null");
return (Criteria) this;
}
public Criteria andTestPlanIdEqualTo(String value) {
addCriterion("test_plan_id =", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotEqualTo(String value) {
addCriterion("test_plan_id <>", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdGreaterThan(String value) {
addCriterion("test_plan_id >", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdGreaterThanOrEqualTo(String value) {
addCriterion("test_plan_id >=", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLessThan(String value) {
addCriterion("test_plan_id <", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLessThanOrEqualTo(String value) {
addCriterion("test_plan_id <=", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLike(String value) {
addCriterion("test_plan_id like", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotLike(String value) {
addCriterion("test_plan_id not like", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdIn(List<String> values) {
addCriterion("test_plan_id in", values, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotIn(List<String> values) {
addCriterion("test_plan_id not in", values, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdBetween(String value1, String value2) {
addCriterion("test_plan_id between", value1, value2, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotBetween(String value1, String value2) {
addCriterion("test_plan_id not between", value1, value2, "testPlanId");
return (Criteria) this;
}
public Criteria andApiScenarioIdIsNull() {
addCriterion("api_scenario_id is null");
return (Criteria) this;
}
public Criteria andApiScenarioIdIsNotNull() {
addCriterion("api_scenario_id is not null");
return (Criteria) this;
}
public Criteria andApiScenarioIdEqualTo(String value) {
addCriterion("api_scenario_id =", value, "apiScenarioId");
return (Criteria) this;
}
public Criteria andApiScenarioIdNotEqualTo(String value) {
addCriterion("api_scenario_id <>", value, "apiScenarioId");
return (Criteria) this;
}
public Criteria andApiScenarioIdGreaterThan(String value) {
addCriterion("api_scenario_id >", value, "apiScenarioId");
return (Criteria) this;
}
public Criteria andApiScenarioIdGreaterThanOrEqualTo(String value) {
addCriterion("api_scenario_id >=", value, "apiScenarioId");
return (Criteria) this;
}
public Criteria andApiScenarioIdLessThan(String value) {
addCriterion("api_scenario_id <", value, "apiScenarioId");
return (Criteria) this;
}
public Criteria andApiScenarioIdLessThanOrEqualTo(String value) {
addCriterion("api_scenario_id <=", value, "apiScenarioId");
return (Criteria) this;
}
public Criteria andApiScenarioIdLike(String value) {
addCriterion("api_scenario_id like", value, "apiScenarioId");
return (Criteria) this;
}
public Criteria andApiScenarioIdNotLike(String value) {
addCriterion("api_scenario_id not like", value, "apiScenarioId");
return (Criteria) this;
}
public Criteria andApiScenarioIdIn(List<String> values) {
addCriterion("api_scenario_id in", values, "apiScenarioId");
return (Criteria) this;
}
public Criteria andApiScenarioIdNotIn(List<String> values) {
addCriterion("api_scenario_id not in", values, "apiScenarioId");
return (Criteria) this;
}
public Criteria andApiScenarioIdBetween(String value1, String value2) {
addCriterion("api_scenario_id between", value1, value2, "apiScenarioId");
return (Criteria) this;
}
public Criteria andApiScenarioIdNotBetween(String value1, String value2) {
addCriterion("api_scenario_id not between", value1, value2, "apiScenarioId");
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("`status` is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(String value) {
addCriterion("`status` =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(String value) {
addCriterion("`status` <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(String value) {
addCriterion("`status` >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(String value) {
addCriterion("`status` >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(String value) {
addCriterion("`status` <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(String value) {
addCriterion("`status` <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLike(String value) {
addCriterion("`status` like", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotLike(String value) {
addCriterion("`status` not like", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<String> values) {
addCriterion("`status` in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<String> values) {
addCriterion("`status` not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(String value1, String value2) {
addCriterion("`status` between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(String value1, String value2) {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andEnvironmentIdIsNull() {
addCriterion("environment_id is null");
return (Criteria) this;
}
public Criteria andEnvironmentIdIsNotNull() {
addCriterion("environment_id is not null");
return (Criteria) this;
}
public Criteria andEnvironmentIdEqualTo(String value) {
addCriterion("environment_id =", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdNotEqualTo(String value) {
addCriterion("environment_id <>", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdGreaterThan(String value) {
addCriterion("environment_id >", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdGreaterThanOrEqualTo(String value) {
addCriterion("environment_id >=", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdLessThan(String value) {
addCriterion("environment_id <", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdLessThanOrEqualTo(String value) {
addCriterion("environment_id <=", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdLike(String value) {
addCriterion("environment_id like", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdNotLike(String value) {
addCriterion("environment_id not like", value, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdIn(List<String> values) {
addCriterion("environment_id in", values, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdNotIn(List<String> values) {
addCriterion("environment_id not in", values, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdBetween(String value1, String value2) {
addCriterion("environment_id between", value1, value2, "environmentId");
return (Criteria) this;
}
public Criteria andEnvironmentIdNotBetween(String value1, String value2) {
addCriterion("environment_id not between", value1, value2, "environmentId");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Long value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Long value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Long value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Long value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Long> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Long> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Long value1, Long value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Long value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Long value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Long value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Long value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Long value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Long> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Long> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Long value1, Long value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Long value1, Long value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -1,12 +1,9 @@
package io.metersphere.base.mapper; package io.metersphere.base.mapper;
import io.metersphere.api.dto.dataCount.ExecutedCaseInfoResult;
import io.metersphere.base.domain.ApiDefinitionExecResult; import io.metersphere.base.domain.ApiDefinitionExecResult;
import io.metersphere.base.domain.ApiDefinitionExecResultExample; import io.metersphere.base.domain.ApiDefinitionExecResultExample;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface ApiDefinitionExecResultMapper { public interface ApiDefinitionExecResultMapper {
long countByExample(ApiDefinitionExecResultExample example); long countByExample(ApiDefinitionExecResultExample example);
@ -36,5 +33,4 @@ public interface ApiDefinitionExecResultMapper {
int updateByPrimaryKeyWithBLOBs(ApiDefinitionExecResult record); int updateByPrimaryKeyWithBLOBs(ApiDefinitionExecResult record);
int updateByPrimaryKey(ApiDefinitionExecResult record); int updateByPrimaryKey(ApiDefinitionExecResult record);
} }

View File

@ -10,6 +10,7 @@
<result column="start_time" jdbcType="BIGINT" property="startTime" /> <result column="start_time" jdbcType="BIGINT" property="startTime" />
<result column="end_time" jdbcType="BIGINT" property="endTime" /> <result column="end_time" jdbcType="BIGINT" property="endTime" />
<result column="create_time" jdbcType="BIGINT" property="createTime" /> <result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="type" jdbcType="VARCHAR" property="type" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiDefinitionExecResult"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiDefinitionExecResult">
<result column="content" jdbcType="LONGVARCHAR" property="content" /> <result column="content" jdbcType="LONGVARCHAR" property="content" />
@ -73,7 +74,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, `name`, resource_id, `status`, user_id, start_time, end_time, create_time id, `name`, resource_id, `status`, user_id, start_time, end_time, create_time, `type`
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
content content
@ -129,12 +130,12 @@
<insert id="insert" parameterType="io.metersphere.base.domain.ApiDefinitionExecResult"> <insert id="insert" parameterType="io.metersphere.base.domain.ApiDefinitionExecResult">
insert into api_definition_exec_result (id, `name`, resource_id, insert into api_definition_exec_result (id, `name`, resource_id,
`status`, user_id, start_time, `status`, user_id, start_time,
end_time, create_time, content end_time, create_time, `type`,
) content)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT},
#{endTime,jdbcType=BIGINT}, #{createTime,jdbcType=BIGINT}, #{content,jdbcType=LONGVARCHAR} #{endTime,jdbcType=BIGINT}, #{createTime,jdbcType=BIGINT}, #{type,jdbcType=VARCHAR},
) #{content,jdbcType=LONGVARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiDefinitionExecResult"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiDefinitionExecResult">
insert into api_definition_exec_result insert into api_definition_exec_result
@ -163,6 +164,9 @@
<if test="createTime != null"> <if test="createTime != null">
create_time, create_time,
</if> </if>
<if test="type != null">
`type`,
</if>
<if test="content != null"> <if test="content != null">
content, content,
</if> </if>
@ -192,6 +196,9 @@
<if test="createTime != null"> <if test="createTime != null">
#{createTime,jdbcType=BIGINT}, #{createTime,jdbcType=BIGINT},
</if> </if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="content != null"> <if test="content != null">
#{content,jdbcType=LONGVARCHAR}, #{content,jdbcType=LONGVARCHAR},
</if> </if>
@ -230,6 +237,9 @@
<if test="record.createTime != null"> <if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
</if> </if>
<if test="record.type != null">
`type` = #{record.type,jdbcType=VARCHAR},
</if>
<if test="record.content != null"> <if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR}, content = #{record.content,jdbcType=LONGVARCHAR},
</if> </if>
@ -248,6 +258,7 @@
start_time = #{record.startTime,jdbcType=BIGINT}, start_time = #{record.startTime,jdbcType=BIGINT},
end_time = #{record.endTime,jdbcType=BIGINT}, end_time = #{record.endTime,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
`type` = #{record.type,jdbcType=VARCHAR},
content = #{record.content,jdbcType=LONGVARCHAR} content = #{record.content,jdbcType=LONGVARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -262,7 +273,8 @@
user_id = #{record.userId,jdbcType=VARCHAR}, user_id = #{record.userId,jdbcType=VARCHAR},
start_time = #{record.startTime,jdbcType=BIGINT}, start_time = #{record.startTime,jdbcType=BIGINT},
end_time = #{record.endTime,jdbcType=BIGINT}, end_time = #{record.endTime,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=BIGINT} create_time = #{record.createTime,jdbcType=BIGINT},
`type` = #{record.type,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -291,6 +303,9 @@
<if test="createTime != null"> <if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
</if> </if>
<if test="type != null">
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="content != null"> <if test="content != null">
content = #{content,jdbcType=LONGVARCHAR}, content = #{content,jdbcType=LONGVARCHAR},
</if> </if>
@ -306,6 +321,7 @@
start_time = #{startTime,jdbcType=BIGINT}, start_time = #{startTime,jdbcType=BIGINT},
end_time = #{endTime,jdbcType=BIGINT}, end_time = #{endTime,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
`type` = #{type,jdbcType=VARCHAR},
content = #{content,jdbcType=LONGVARCHAR} content = #{content,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -317,7 +333,8 @@
user_id = #{userId,jdbcType=VARCHAR}, user_id = #{userId,jdbcType=VARCHAR},
start_time = #{startTime,jdbcType=BIGINT}, start_time = #{startTime,jdbcType=BIGINT},
end_time = #{endTime,jdbcType=BIGINT}, end_time = #{endTime,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=BIGINT} create_time = #{createTime,jdbcType=BIGINT},
`type` = #{type,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -1,13 +1,9 @@
package io.metersphere.base.mapper; package io.metersphere.base.mapper;
import io.metersphere.api.dto.dataCount.response.TaskInfoResult;
import io.metersphere.base.domain.Schedule; import io.metersphere.base.domain.Schedule;
import io.metersphere.base.domain.ScheduleExample; import io.metersphere.base.domain.ScheduleExample;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.python.antlr.ast.Str;
public interface ScheduleMapper { public interface ScheduleMapper {
long countByExample(ScheduleExample example); long countByExample(ScheduleExample example);

View File

@ -0,0 +1,30 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.TestPlanApiCase;
import io.metersphere.base.domain.TestPlanApiCaseExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TestPlanApiCaseMapper {
long countByExample(TestPlanApiCaseExample example);
int deleteByExample(TestPlanApiCaseExample example);
int deleteByPrimaryKey(String id);
int insert(TestPlanApiCase record);
int insertSelective(TestPlanApiCase record);
List<TestPlanApiCase> selectByExample(TestPlanApiCaseExample example);
TestPlanApiCase selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") TestPlanApiCase record, @Param("example") TestPlanApiCaseExample example);
int updateByExample(@Param("record") TestPlanApiCase record, @Param("example") TestPlanApiCaseExample example);
int updateByPrimaryKeySelective(TestPlanApiCase record);
int updateByPrimaryKey(TestPlanApiCase record);
}

View File

@ -0,0 +1,243 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.TestPlanApiCaseMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.TestPlanApiCase">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="test_plan_id" jdbcType="VARCHAR" property="testPlanId" />
<result column="api_case_id" jdbcType="VARCHAR" property="apiCaseId" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="environment_id" jdbcType="VARCHAR" property="environmentId" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, test_plan_id, api_case_id, `status`, environment_id, create_time, update_time
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestPlanApiCaseExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from test_plan_api_case
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from test_plan_api_case
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from test_plan_api_case
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.TestPlanApiCaseExample">
delete from test_plan_api_case
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestPlanApiCase">
insert into test_plan_api_case (id, test_plan_id, api_case_id,
`status`, environment_id, create_time,
update_time)
values (#{id,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{apiCaseId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{environmentId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanApiCase">
insert into test_plan_api_case
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="testPlanId != null">
test_plan_id,
</if>
<if test="apiCaseId != null">
api_case_id,
</if>
<if test="status != null">
`status`,
</if>
<if test="environmentId != null">
environment_id,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="testPlanId != null">
#{testPlanId,jdbcType=VARCHAR},
</if>
<if test="apiCaseId != null">
#{apiCaseId,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="environmentId != null">
#{environmentId,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanApiCaseExample" resultType="java.lang.Long">
select count(*) from test_plan_api_case
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update test_plan_api_case
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.testPlanId != null">
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
</if>
<if test="record.apiCaseId != null">
api_case_id = #{record.apiCaseId,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
`status` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.environmentId != null">
environment_id = #{record.environmentId,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update test_plan_api_case
set id = #{record.id,jdbcType=VARCHAR},
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
api_case_id = #{record.apiCaseId,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
environment_id = #{record.environmentId,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.TestPlanApiCase">
update test_plan_api_case
<set>
<if test="testPlanId != null">
test_plan_id = #{testPlanId,jdbcType=VARCHAR},
</if>
<if test="apiCaseId != null">
api_case_id = #{apiCaseId,jdbcType=VARCHAR},
</if>
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="environmentId != null">
environment_id = #{environmentId,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestPlanApiCase">
update test_plan_api_case
set test_plan_id = #{testPlanId,jdbcType=VARCHAR},
api_case_id = #{apiCaseId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
environment_id = #{environmentId,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -0,0 +1,30 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.TestPlanApiScenario;
import io.metersphere.base.domain.TestPlanApiScenarioExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TestPlanApiScenarioMapper {
long countByExample(TestPlanApiScenarioExample example);
int deleteByExample(TestPlanApiScenarioExample example);
int deleteByPrimaryKey(String id);
int insert(TestPlanApiScenario record);
int insertSelective(TestPlanApiScenario record);
List<TestPlanApiScenario> selectByExample(TestPlanApiScenarioExample example);
TestPlanApiScenario selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") TestPlanApiScenario record, @Param("example") TestPlanApiScenarioExample example);
int updateByExample(@Param("record") TestPlanApiScenario record, @Param("example") TestPlanApiScenarioExample example);
int updateByPrimaryKeySelective(TestPlanApiScenario record);
int updateByPrimaryKey(TestPlanApiScenario record);
}

View File

@ -0,0 +1,243 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.TestPlanApiScenarioMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.TestPlanApiScenario">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="test_plan_id" jdbcType="VARCHAR" property="testPlanId" />
<result column="api_scenario_id" jdbcType="VARCHAR" property="apiScenarioId" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="environment_id" jdbcType="VARCHAR" property="environmentId" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, test_plan_id, api_scenario_id, `status`, environment_id, create_time, update_time
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestPlanApiScenarioExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from test_plan_api_scenario
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from test_plan_api_scenario
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from test_plan_api_scenario
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.TestPlanApiScenarioExample">
delete from test_plan_api_scenario
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestPlanApiScenario">
insert into test_plan_api_scenario (id, test_plan_id, api_scenario_id,
`status`, environment_id, create_time,
update_time)
values (#{id,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{apiScenarioId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{environmentId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanApiScenario">
insert into test_plan_api_scenario
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="testPlanId != null">
test_plan_id,
</if>
<if test="apiScenarioId != null">
api_scenario_id,
</if>
<if test="status != null">
`status`,
</if>
<if test="environmentId != null">
environment_id,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="testPlanId != null">
#{testPlanId,jdbcType=VARCHAR},
</if>
<if test="apiScenarioId != null">
#{apiScenarioId,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="environmentId != null">
#{environmentId,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanApiScenarioExample" resultType="java.lang.Long">
select count(*) from test_plan_api_scenario
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update test_plan_api_scenario
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.testPlanId != null">
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
</if>
<if test="record.apiScenarioId != null">
api_scenario_id = #{record.apiScenarioId,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
`status` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.environmentId != null">
environment_id = #{record.environmentId,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update test_plan_api_scenario
set id = #{record.id,jdbcType=VARCHAR},
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
api_scenario_id = #{record.apiScenarioId,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
environment_id = #{record.environmentId,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.TestPlanApiScenario">
update test_plan_api_scenario
<set>
<if test="testPlanId != null">
test_plan_id = #{testPlanId,jdbcType=VARCHAR},
</if>
<if test="apiScenarioId != null">
api_scenario_id = #{apiScenarioId,jdbcType=VARCHAR},
</if>
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="environmentId != null">
environment_id = #{environmentId,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestPlanApiScenario">
update test_plan_api_scenario
set test_plan_id = #{testPlanId,jdbcType=VARCHAR},
api_scenario_id = #{apiScenarioId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
environment_id = #{environmentId,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -1,9 +1,8 @@
package io.metersphere.base.mapper.ext; package io.metersphere.base.mapper.ext;
import io.metersphere.api.dto.dataCount.ExecutedCaseInfoResult; import io.metersphere.api.dto.datacount.ExecutedCaseInfoResult;
import io.metersphere.base.domain.ApiDefinitionExecResult; import io.metersphere.base.domain.ApiDefinitionExecResult;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
@ -13,6 +12,9 @@ public interface ExtApiDefinitionExecResultMapper {
ApiDefinitionExecResult selectMaxResultByResourceId(String resourceId); ApiDefinitionExecResult selectMaxResultByResourceId(String resourceId);
ApiDefinitionExecResult selectMaxResultByResourceIdAndType(String resourceId, String type);
long countByProjectIDAndCreateInThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp); long countByProjectIDAndCreateInThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
long countByTestCaseIDInProject(String projectId); long countByTestCaseIDInProject(String projectId);

View File

@ -9,7 +9,13 @@
select * from api_definition_exec_result select * from api_definition_exec_result
where resource_id = #{resourceId,jdbcType=VARCHAR} ORDER BY create_time DESC LIMIT 1 where resource_id = #{resourceId,jdbcType=VARCHAR} ORDER BY create_time DESC LIMIT 1
</select> </select>
<select id="selectMaxResultByResourceIdAndType"
resultType="io.metersphere.base.domain.ApiDefinitionExecResult">
select * from api_definition_exec_result
where resource_id = #{resourceId,jdbcType=VARCHAR}
and `type` = #{type, jdbcType=VARCHAR}
ORDER BY start_time DESC LIMIT 1
</select>
<select id="countByProjectIDAndCreateInThisWeek" resultType="java.lang.Long"> <select id="countByProjectIDAndCreateInThisWeek" resultType="java.lang.Long">
SELECT count(id) AS countNumber FROM api_definition_exec_result SELECT count(id) AS countNumber FROM api_definition_exec_result
@ -26,38 +32,7 @@
WHERE testCase.project_id = #{projectId}) WHERE testCase.project_id = #{projectId})
</select> </select>
<!-- <select id="findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber" resultType="io.metersphere.api.dto.dataCount.ExecutedCaseInfoResult">--> <select id="findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber" resultType="io.metersphere.api.dto.datacount.ExecutedCaseInfoResult">
<!-- SELECT * FROM (-->
<!-- SELECT testCase.testCaseName AS caseName,testCase.testPlanName AS testPlan ,caseErrorCountData.dataCountNumber AS failureTimes,'apiCase' AS caseType-->
<!-- FROM (-->
<!-- SELECT apiCase.id AS testCaseID,apiCase.`name` AS testCaseName,group_concat(testPlan.`name`) AS testPlanName FROM api_test_case apiCase-->
<!-- LEFT JOIN test_plan testPlan ON testPlan.api_ids like concat('%"',apiCase.id,'"%')-->
<!-- GROUP BY apiCase.id-->
<!-- ORDER BY apiCase.create_time DESC-->
<!-- )testCase-->
<!-- INNER JOIN (-->
<!-- SELECT resource_id AS testCaseID,COUNT(id) AS dataCountNumber,start_time AS executeTime FROM api_definition_exec_result-->
<!-- WHERE resource_id IN (-->
<!-- SELECT id FROM api_test_case WHERE project_id = #{projectId}-->
<!-- ) and `status` = 'error' GROUP BY resource_id-->
<!-- ) caseErrorCountData ON caseErrorCountData.testCaseID =testCase.testCaseID-->
<!-- WHERE caseErrorCountData.executeTime >= #{startTimestamp}-->
<!-- UNION-->
<!-- SELECT scene.`name` AS caseName,testPlan.`name` AS testPlan,count(report.id) AS failureTimes,'scenario' AS caseType-->
<!-- FROM api_scenario_report report-->
<!-- INNER JOIN api_scenario_report_detail reportDetail ON report.id = reportDetail.report_id-->
<!-- INNER JOIN api_scenario scene ON reportDetail.content like concat('%"',scene.`name`,'"%')-->
<!-- LEFT JOIN test_plan_api_scenario apiScene ON apiScene.api_scenario_id = scene.id-->
<!-- LEFT JOIN test_plan testPlan ON testPlan.id = apiScene.test_plan_id-->
<!-- WHERE report.project_id = #{projectId}-->
<!-- AND report.status = 'Error' AND report.create_time >= #{startTimestamp}-->
<!-- GROUP BY scene.id-->
<!-- ) showTable-->
<!-- ORDER BY showTable.failureTimes DESC-->
<!-- limit #{limitNumber}-->
<!-- </select>-->
<select id="findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber" resultType="io.metersphere.api.dto.dataCount.ExecutedCaseInfoResult">
SELECT * FROM ( SELECT * FROM (
SELECT testCase.testCaseName AS caseName,testCase.testPlanName AS testPlan ,caseErrorCountData.dataCountNumber AS failureTimes,'apiCase' AS caseType SELECT testCase.testCaseName AS caseName,testCase.testPlanName AS testPlan ,caseErrorCountData.dataCountNumber AS failureTimes,'apiCase' AS caseType
FROM ( FROM (
@ -73,6 +48,16 @@
) and `status` = 'error' GROUP BY resource_id ) and `status` = 'error' GROUP BY resource_id
) caseErrorCountData ON caseErrorCountData.testCaseID =testCase.testCaseID ) caseErrorCountData ON caseErrorCountData.testCaseID =testCase.testCaseID
WHERE caseErrorCountData.executeTime >= #{startTimestamp} WHERE caseErrorCountData.executeTime >= #{startTimestamp}
UNION
SELECT scene.`name` AS caseName,testPlan.`name` AS testPlan,count(report.id) AS failureTimes,'scenario' AS caseType
FROM api_scenario_report report
INNER JOIN api_scenario_report_detail reportDetail ON report.id = reportDetail.report_id
INNER JOIN api_scenario scene ON reportDetail.content like concat('%"',scene.`name`,'"%')
LEFT JOIN test_plan_api_scenario apiScene ON apiScene.api_scenario_id = scene.id
LEFT JOIN test_plan testPlan ON testPlan.id = apiScene.test_plan_id
WHERE report.project_id = #{projectId}
AND report.status = 'Error' AND report.create_time >= #{startTimestamp}
GROUP BY scene.id
) showTable ) showTable
ORDER BY showTable.failureTimes DESC ORDER BY showTable.failureTimes DESC
limit #{limitNumber} limit #{limitNumber}

View File

@ -1,11 +1,10 @@
package io.metersphere.base.mapper.ext; package io.metersphere.base.mapper.ext;
import io.metersphere.api.dto.dataCount.ApiDataCountResult; import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.api.dto.definition.ApiComputeResult; import io.metersphere.api.dto.definition.ApiComputeResult;
import io.metersphere.api.dto.definition.ApiDefinitionRequest; import io.metersphere.api.dto.definition.ApiDefinitionRequest;
import io.metersphere.api.dto.definition.ApiDefinitionResult; import io.metersphere.api.dto.definition.ApiDefinitionResult;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;

View File

@ -274,10 +274,10 @@
</foreach> </foreach>
</update> </update>
<select id="countProtocolByProjectID" resultType="io.metersphere.api.dto.dataCount.ApiDataCountResult"> <select id="countProtocolByProjectID" resultType="io.metersphere.api.dto.datacount.ApiDataCountResult">
SELECT protocol AS groupField,count(id) AS countNumber FROM api_definition WHERE project_id = #{0} GROUP BY protocol SELECT protocol AS groupField,count(id) AS countNumber FROM api_definition WHERE project_id = #{0} GROUP BY protocol
</select> </select>
<select id="countStateByProjectID" resultType="io.metersphere.api.dto.dataCount.ApiDataCountResult"> <select id="countStateByProjectID" resultType="io.metersphere.api.dto.datacount.ApiDataCountResult">
SELECT status AS groupField,count(id) AS countNumber FROM api_definition WHERE project_id = #{0} GROUP BY status SELECT status AS groupField,count(id) AS countNumber FROM api_definition WHERE project_id = #{0} GROUP BY status
</select> </select>
<select id="countByProjectIDAndCreateInThisWeek" resultType="java.lang.Long"> <select id="countByProjectIDAndCreateInThisWeek" resultType="java.lang.Long">
@ -285,7 +285,7 @@
WHERE project_id = #{projectId} WHERE project_id = #{projectId}
AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp} AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
</select> </select>
<select id="countApiCoverageByProjectID" resultType="io.metersphere.api.dto.dataCount.ApiDataCountResult"> <select id="countApiCoverageByProjectID" resultType="io.metersphere.api.dto.datacount.ApiDataCountResult">
SELECT count(api.id) AS countNumber, if(test_case_api.api_definition_id is null,"uncoverage","coverage") AS groupField FROM api_definition api left Join ( SELECT count(api.id) AS countNumber, if(test_case_api.api_definition_id is null,"uncoverage","coverage") AS groupField FROM api_definition api left Join (
SELECT DISTINCT api_definition_id FROM api_test_case SELECT DISTINCT api_definition_id FROM api_test_case
) test_case_api ON api.id = test_case_api.api_definition_id ) test_case_api ON api.id = test_case_api.api_definition_id

View File

@ -2,11 +2,10 @@ package io.metersphere.base.mapper.ext;
import io.metersphere.api.dto.automation.ApiScenarioDTO; import io.metersphere.api.dto.automation.ApiScenarioDTO;
import io.metersphere.api.dto.automation.ApiScenarioRequest; import io.metersphere.api.dto.automation.ApiScenarioRequest;
import io.metersphere.api.dto.dataCount.ApiDataCountResult; import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.base.domain.ApiScenario; import io.metersphere.base.domain.ApiScenario;
import io.metersphere.base.domain.ApiScenarioWithBLOBs; import io.metersphere.base.domain.ApiScenarioWithBLOBs;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;

View File

@ -117,7 +117,7 @@
AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp} AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
</select> </select>
<select id="countRunResultByProjectID" resultType="io.metersphere.api.dto.dataCount.ApiDataCountResult"> <select id="countRunResultByProjectID" resultType="io.metersphere.api.dto.datacount.ApiDataCountResult">
SELECT count(id) AS countNumber, if(last_result is null,"notRun",last_result) AS groupField FROM api_scenario SELECT count(id) AS countNumber, if(last_result is null,"notRun",last_result) AS groupField FROM api_scenario
WHERE project_id = #{0} WHERE project_id = #{0}
GROUP BY groupField GROUP BY groupField

View File

@ -1,10 +1,9 @@
package io.metersphere.base.mapper.ext; package io.metersphere.base.mapper.ext;
import io.metersphere.api.dto.dataCount.ApiDataCountResult; import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.api.dto.definition.ApiTestCaseDTO; import io.metersphere.api.dto.definition.ApiTestCaseDTO;
import io.metersphere.api.dto.definition.ApiTestCaseRequest; import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.ApiTestCaseResult; import io.metersphere.api.dto.definition.ApiTestCaseResult;
import io.metersphere.base.domain.ApiTestCase;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
@ -13,9 +12,24 @@ import java.util.List;
public interface ExtApiTestCaseMapper { public interface ExtApiTestCaseMapper {
List<ApiTestCaseResult> list(@Param("request") ApiTestCaseRequest request); List<ApiTestCaseResult> list(@Param("request") ApiTestCaseRequest request);
List<ApiTestCaseDTO> listSimple(@Param("request") ApiTestCaseRequest request); List<ApiTestCaseDTO> listSimple(@Param("request") ApiTestCaseRequest request);
List<String> selectIdsNotExistsInPlan(@Param("projectId") String projectId, @Param("planId") String planId);
@Select({
"SELECT apiDef.protocol AS groupField,COUNT(testCase.id) AS countNumber FROM api_test_case testCase ",
"INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id ",
"WHERE testCase.project_id = #{0} ",
"GROUP BY apiDef.protocol "
})
List<ApiDataCountResult> countProtocolByProjectID(String projectId); List<ApiDataCountResult> countProtocolByProjectID(String projectId);
@Select({
"SELECT count(testCase.id) AS countNumber FROM api_test_case testCase ",
"INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id ",
"WHERE testCase.project_id = #{projectId} ",
"AND testCase.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp} "
})
long countByProjectIDAndCreateInThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp); long countByProjectIDAndCreateInThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
} }

View File

@ -212,6 +212,9 @@
api_definition a api_definition a
on on
c.api_definition_id = a.id c.api_definition_id = a.id
<if test="request.protocol != null and request.protocol!=''">
and a.protocol = #{request.protocol}
</if>
<choose> <choose>
<when test="request.status == 'Trash'"> <when test="request.status == 'Trash'">
and a.status = 'Trash' and a.status = 'Trash'
@ -221,7 +224,18 @@
</otherwise> </otherwise>
</choose> </choose>
where where
<if test="request.projectId != null and request.projectId!=''">
c.project_id = #{request.projectId} c.project_id = #{request.projectId}
</if>
<if test="request.ids != null and request.ids.size() > 0">
<if test="request.projectId != null and request.projectId!=''">
and
</if>
c.id in
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
#{caseId}
</foreach>
</if>
<if test="request.name != null and request.name!=''"> <if test="request.name != null and request.name!=''">
and c.name like CONCAT('%', #{request.name},'%') and c.name like CONCAT('%', #{request.name},'%')
</if> </if>
@ -252,16 +266,13 @@
</foreach> </foreach>
</if> </if>
</select> </select>
<select id="countProtocolByProjectID" resultType="io.metersphere.api.dto.dataCount.ApiDataCountResult"> <select id="selectIdsNotExistsInPlan" resultType="java.lang.String">
SELECT apiDef.protocol AS groupField,COUNT(testCase.id) AS countNumber FROM api_test_case testCase select c.id
INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id from api_test_case c
WHERE testCase.project_id = #{0} where c.project_id = #{projectId} and c.id not in (
GROUP BY apiDef.protocol select pc.api_case_id
</select> from test_plan_api_case pc
<select id="countByProjectIDAndCreateInThisWeek" resultType="java.lang.Long"> where pc.test_plan_id = #{planId}
SELECT count(testCase.id) AS countNumber FROM api_test_case testCase )
INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id
WHERE testCase.project_id = #{projectId}
AND testCase.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
</select> </select>
</mapper> </mapper>

View File

@ -2,11 +2,9 @@ package io.metersphere.base.mapper.ext;
import io.metersphere.api.dto.APIReportResult; import io.metersphere.api.dto.APIReportResult;
import io.metersphere.api.dto.QueryAPIReportRequest; import io.metersphere.api.dto.QueryAPIReportRequest;
import io.metersphere.api.dto.dataCount.ApiDataCountResult; import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.dto.ApiReportDTO;
import io.metersphere.dto.DashboardTestDTO; import io.metersphere.dto.DashboardTestDTO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;

View File

@ -152,7 +152,7 @@
GROUP BY x GROUP BY x
</select> </select>
<select id="countByWorkspaceIdAndGroupGroupByExecuteResult" resultType="io.metersphere.api.dto.dataCount.ApiDataCountResult"> <select id="countByWorkspaceIdAndGroupGroupByExecuteResult" resultType="io.metersphere.api.dto.datacount.ApiDataCountResult">
SELECT testReport.`status` AS groupField,COUNT(testReportDetail.report_id) AS countNumber SELECT testReport.`status` AS groupField,COUNT(testReportDetail.report_id) AS countNumber
FROM api_test_report_detail testReportDetail FROM api_test_report_detail testReportDetail
INNER JOIN `schedule` sch ON sch.resource_id = testReportDetail.test_id INNER JOIN `schedule` sch ON sch.resource_id = testReportDetail.test_id

View File

@ -1,10 +1,9 @@
package io.metersphere.base.mapper.ext; package io.metersphere.base.mapper.ext;
import io.metersphere.api.dto.dataCount.response.TaskInfoResult; import io.metersphere.api.dto.datacount.response.TaskInfoResult;
import io.metersphere.controller.request.QueryScheduleRequest; import io.metersphere.controller.request.QueryScheduleRequest;
import io.metersphere.dto.ScheduleDao; import io.metersphere.dto.ScheduleDao;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;

View File

@ -45,7 +45,7 @@
AND `group` = #{group} AND `group` = #{group}
AND create_time BETWEEN #{startTime} and #{endTime} AND create_time BETWEEN #{startTime} and #{endTime}
</select> </select>
<select id="findRunningTaskInfoByWorkspaceID" resultType="io.metersphere.api.dto.dataCount.response.TaskInfoResult"> <select id="findRunningTaskInfoByWorkspaceID" resultType="io.metersphere.api.dto.datacount.response.TaskInfoResult">
SELECT apiTest.`name` AS scenario,sch.id AS taskID,sch.`value` AS rule,sch.`enable` AS `taskStatus`,u.`name` AS creator,sch.update_time AS updateTime SELECT apiTest.`name` AS scenario,sch.id AS taskID,sch.`value` AS rule,sch.`enable` AS `taskStatus`,u.`name` AS creator,sch.update_time AS updateTime
FROM api_test apiTest FROM api_test apiTest
INNER JOIN `schedule` sch ON apiTest.id = sch.resource_id INNER JOIN `schedule` sch ON apiTest.id = sch.resource_id

View File

@ -0,0 +1,14 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
import io.metersphere.base.domain.TestPlanApiCase;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ExtTestPlanApiCaseMapper {
void insertIfNotExists(@Param("request") TestPlanApiCase request);
List<TestPlanApiCaseDTO> list(@Param("request") ApiTestCaseRequest request);
}

View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper">
<insert id="insertIfNotExists" parameterType="io.metersphere.base.domain.TestPlanApiCase">
-- 查询没有数据再插入
INSERT INTO test_plan_api_case(id, test_plan_id, api_case_id, environment_id, create_time, update_time)
SELECT #{request.id}, #{request.testPlanId}, #{request.apiCaseId}, #{request.environmentId}, #{request.createTime}, #{request.updateTime}
FROM DUAL
WHERE NOT EXISTS(
SELECT id FROM
test_plan_api_case
WHERE test_plan_id = #{request.testPlanId} and api_case_id = #{request.apiCaseId}
)
</insert>
<select id="list" resultType="io.metersphere.api.dto.definition.TestPlanApiCaseDTO">
select
t.id, t.environment_id, t.create_time, t.update_time,
c.id as case_id, c.project_id, c.name, c.api_definition_id, c.priority, c.description, c.create_user_id, c.update_user_id,
a.module_id, a.path, a.protocol, ader.status execResult
from
test_plan_api_case t
inner join
api_test_case c
on t.api_case_id = c.id
inner join
api_definition a
on
c.api_definition_id = a.id
left join (
select
e.status, e.id, e.resource_id
from
api_definition_exec_result e
left join (
select
max(start_time) start_time , resource_id
from
api_definition_exec_result
group by
resource_id
) as b
on e.resource_id = b.resource_id
where
e.start_time = b.start_time and e.type = 'API_PLAN'
) as ader
on t.id = ader.resource_id
<if test="request.protocol != null and request.protocol!=''">
and a.protocol = #{request.protocol}
</if>
<choose>
<when test="request.status == 'Trash'">
and a.status = 'Trash'
</when>
<otherwise>
and a.status != 'Trash'
</otherwise>
</choose>
where 1
<if test="request.ids != null and request.ids.size() > 0">
<if test="request.projectId != null and request.projectId!=''">
and
</if>
t.id in
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
#{caseId}
</foreach>
</if>
<if test="request.name != null and request.name!=''">
and c.name like CONCAT('%', #{request.name},'%')
</if>
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
and a.module_id in
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
#{nodeId}
</foreach>
</if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
<choose>
<when test="key == 'priority'">
and c.priority in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose>
</if>
</foreach>
</if>
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
<choose>
<when test="order.name == 'update_time'">
t.${order.name} ${order.type}
</when>
<otherwise>
${order.name} ${order.type}
</otherwise>
</choose>
</foreach>
</if>
</select>
</mapper>

View File

@ -1,5 +1,5 @@
package io.metersphere.commons.constants; package io.metersphere.commons.constants;
public enum ApiRunMode { public enum ApiRunMode {
RUN, DEBUG,DELIMIT,SCENARIO RUN, DEBUG,DELIMIT,SCENARIO, API_PLAN
} }

View File

@ -2,6 +2,7 @@ package io.metersphere.controller;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.Schedule;
import io.metersphere.controller.request.QueryScheduleRequest; import io.metersphere.controller.request.QueryScheduleRequest;
import io.metersphere.dto.ScheduleDao; import io.metersphere.dto.ScheduleDao;
import io.metersphere.service.ScheduleService; import io.metersphere.service.ScheduleService;
@ -22,4 +23,9 @@ public class ScheduleController {
return scheduleService.list(request); return scheduleService.list(request);
} }
@GetMapping("/findOne/{testId}/{group}")
public Schedule schedule(@PathVariable String testId,@PathVariable String group) {
Schedule schedule = scheduleService.getScheduleByResource(testId,group);
return schedule;
}
} }

View File

@ -193,11 +193,13 @@ public class ReportService {
public List<LogDetailDTO> getReportLogResource(String reportId) { public List<LogDetailDTO> getReportLogResource(String reportId) {
List<LogDetailDTO> result = new ArrayList<>(); List<LogDetailDTO> result = new ArrayList<>();
List<String> resourceIds = extLoadTestReportMapper.selectResourceId(reportId); List<String> resourceIdAndIndexes = extLoadTestReportMapper.selectResourceId(reportId);
resourceIds.forEach(resourceId -> { resourceIdAndIndexes.forEach(resourceIdAndIndex -> {
LogDetailDTO detailDTO = new LogDetailDTO(); LogDetailDTO detailDTO = new LogDetailDTO();
String[] split = StringUtils.split(resourceIdAndIndex, "_");
String resourceId = split[0];
TestResource testResource = testResourceService.getTestResource(resourceId); TestResource testResource = testResourceService.getTestResource(resourceId);
detailDTO.setResourceId(resourceId); detailDTO.setResourceId(resourceIdAndIndex);
if (testResource == null) { if (testResource == null) {
detailDTO.setResourceName(resourceId); detailDTO.setResourceName(resourceId);
result.add(detailDTO); result.add(detailDTO);

View File

@ -1,7 +1,7 @@
package io.metersphere.service; package io.metersphere.service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import io.metersphere.api.dto.dataCount.response.TaskInfoResult; import io.metersphere.api.dto.datacount.response.TaskInfoResult;
import io.metersphere.base.domain.Schedule; import io.metersphere.base.domain.Schedule;
import io.metersphere.base.domain.ScheduleExample; import io.metersphere.base.domain.ScheduleExample;
import io.metersphere.base.domain.User; import io.metersphere.base.domain.User;

View File

@ -0,0 +1,53 @@
package io.metersphere.track.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.definition.ApiTestCaseDTO;
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest;
import io.metersphere.track.service.TestPlanApiCaseService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RequestMapping("/test/plan/api/case")
@RestController
public class TestPlanApiCaseController {
@Resource
TestPlanApiCaseService testPlanApiCaseService;
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<TestPlanApiCaseDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testPlanApiCaseService.list(request));
}
@PostMapping("/relevance/list/{goPage}/{pageSize}")
public Pager<List<ApiTestCaseDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
return PageUtils.setPageInfo(page, testPlanApiCaseService.relevanceList(request));
}
@GetMapping("/delete/{planId}/{id}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public int deleteTestCase(@PathVariable String planId, @PathVariable String id) {
return testPlanApiCaseService.delete(planId, id);
}
@PostMapping("/batch/delete")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void deleteApiCaseBath(@RequestBody TestPlanApiCaseBatchRequest request) {
testPlanApiCaseService.deleteApiCaseBath(request);
}
}

View File

@ -0,0 +1,28 @@
package io.metersphere.track.request.testcase;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
public class ApiCaseRelevanceRequest {
/**
* 测试计划ID
*/
private String planId;
private String environmentId;
/**
* 当选择关联全部用例时把加载条件送到后台从后台查询
*/
// private QueryTestCaseRequest request;
/**
* 具体要关联的用例
*/
private List<String> selectIds = new ArrayList<>();
}

View File

@ -0,0 +1,13 @@
package io.metersphere.track.request.testcase;
import io.metersphere.base.domain.TestPlanTestCase;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class TestPlanApiCaseBatchRequest extends TestPlanTestCase {
private List<String> ids;
}

View File

@ -0,0 +1,72 @@
package io.metersphere.track.service;
import io.metersphere.api.dto.definition.ApiTestCaseDTO;
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
import io.metersphere.api.service.ApiDefinitionExecResultService;
import io.metersphere.api.service.ApiTestCaseService;
import io.metersphere.base.domain.TestPlanApiCaseExample;
import io.metersphere.base.mapper.TestPlanApiCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper;
import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class TestPlanApiCaseService {
@Resource
TestPlanApiCaseMapper testPlanApiCaseMapper;
@Resource
ApiTestCaseService apiTestCaseService;
@Resource
ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper;
@Resource
ApiDefinitionExecResultService apiDefinitionExecResultService;
public List<TestPlanApiCaseDTO> list(ApiTestCaseRequest request) {
request.setProjectId(null);
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
List<TestPlanApiCaseDTO> apiTestCases = extTestPlanApiCaseMapper.list(request);
if (CollectionUtils.isEmpty(apiTestCases)) {
return apiTestCases;
}
apiTestCaseService.buildUserInfo(apiTestCases);
return apiTestCases;
}
public List<ApiTestCaseDTO> relevanceList(ApiTestCaseRequest request) {
List<String> ids = apiTestCaseService.selectIdsNotExistsInPlan(request.getProjectId(), request.getPlanId());
if (CollectionUtils.isEmpty(ids)) {
return new ArrayList<>();
}
request.setIds(ids);
return apiTestCaseService.listSimple(request);
}
public int delete(String planId, String id) {
apiDefinitionExecResultService.deleteByResourceId(id);
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
example.createCriteria()
.andTestPlanIdEqualTo(planId)
.andIdEqualTo(id);
return testPlanApiCaseMapper.deleteByExample(example);
}
public void deleteApiCaseBath(TestPlanApiCaseBatchRequest request) {
apiDefinitionExecResultService.deleteByResourceIds(request.getIds());
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
example.createCriteria()
.andIdIn(request.getIds())
.andTestPlanIdEqualTo(request.getPlanId());
testPlanApiCaseMapper.deleteByExample(example);
}
}

View File

@ -0,0 +1,26 @@
CREATE TABLE IF NOT EXISTS `test_plan_api_case` (
`id` varchar(50) NOT NULL COMMENT 'ID',
`test_plan_id` varchar(50) NOT NULL COMMENT 'Test plan ID',
`api_case_id` varchar(50) NOT NULL COMMENT 'Api test case ID',
`status` varchar(50) DEFAULT NULL COMMENT 'Api case status',
`environment_id` varchar(50) NULL COMMENT 'Relevance environment_id',
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
PRIMARY KEY (`id`),
UNIQUE KEY `plan_id_case_id` (`test_plan_id`, `api_case_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `test_plan_api_scenario` (
`id` varchar(50) NOT NULL COMMENT 'ID',
`test_plan_id` varchar(50) NOT NULL COMMENT 'Test plan ID',
`api_scenario_id` varchar(50) NOT NULL COMMENT 'Api scenario case ID',
`status` varchar(50) DEFAULT NULL COMMENT 'Scenario case status',
`environment_id` varchar(50) NULL COMMENT 'Relevance environment_id',
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
PRIMARY KEY (`id`),
UNIQUE KEY `plan_id_scenario_id` (`test_plan_id`, `api_scenario_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ALTER TABLE api_definition_exec_result ADD `type` varchar(20) NULL;

View File

@ -64,7 +64,9 @@
<!--要生成的数据库表 --> <!--要生成的数据库表 -->
<table tableName="api_scenario_module"/> <table tableName="api_definition_exec_result"/>
<!--<table tableName="test_plan_api_scenario"/>-->
<!--<table tableName="test_plan"/>-->
<!--<table tableName="api_scenario_report"/>--> <!--<table tableName="api_scenario_report"/>-->
</context> </context>

View File

@ -14,6 +14,7 @@
debug: Boolean, debug: Boolean,
reportId: String, reportId: String,
runData: Array, runData: Array,
type: String
}, },
data() { data() {
return { return {
@ -106,7 +107,7 @@
this.runData.forEach(item => { this.runData.forEach(item => {
threadGroup.hashTree.push(item); threadGroup.hashTree.push(item);
}) })
let reqObj = {id: this.reportId, testElement: testPlan}; let reqObj = {id: this.reportId, testElement: testPlan, type: this.type};
let bodyFiles = this.getBodyUploadFiles(reqObj); let bodyFiles = this.getBodyUploadFiles(reqObj);
let url = ""; let url = "";
if (this.debug) { if (this.debug) {

View File

@ -27,23 +27,10 @@
</el-col> </el-col>
<el-col :span="4"> <el-col :span="4">
<div> <div>
<el-select :disabled="isReadOnly" v-model="environment" size="small" class="ms-api-header-select" <ms-environment-select
:placeholder="$t('api_test.definition.request.run_env')" :project-id="projectId"
@change="environmentChange" clearable> :is-read-only="isReadOnly || isCaseEdit"
<el-option v-for="(environment, index) in environments" :key="index" @setEnvironment="setEnvironment"/>
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
:value="environment.id"/>
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">
{{ $t('api_test.environment.environment_config') }}
</el-button>
<template v-slot:empty>
<div class="empty-environment">
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">
{{ $t('api_test.environment.environment_config') }}
</el-button>
</div>
</template>
</el-select>
</div> </div>
</el-col> </el-col>
<el-col :span="3"> <el-col :span="3">
@ -53,8 +40,8 @@
v-model="condition.name" @blur="getApiTest" @keyup.enter.native="getApiTest"/> v-model="condition.name" @blur="getApiTest" @keyup.enter.native="getApiTest"/>
</div> </div>
</el-col> </el-col>
<el-col :span="2"> <el-col :span="2" v-if="!(isReadOnly || isCaseEdit)">
<el-dropdown size="small" split-button type="primary" class="ms-api-header-select" @click="addCase" :disabled="isReadOnly || isCaseEdit" <el-dropdown size="small" split-button type="primary" class="ms-api-header-select" @click="addCase"
@command="handleCommand"> @command="handleCommand">
+{{$t('api_test.definition.request.case')}} +{{$t('api_test.definition.request.case')}}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
@ -64,22 +51,20 @@
</el-col> </el-col>
</el-row> </el-row>
</el-card> </el-card>
<!-- 环境 -->
<api-environment-config ref="environmentConfig" @close="environmentConfigClose"/>
</el-header> </el-header>
</template> </template>
<script> <script>
import ApiEnvironmentConfig from "../../../test/components/ApiEnvironmentConfig"; import ApiEnvironmentConfig from "../../../test/components/ApiEnvironmentConfig";
import {parseEnvironment} from "../../../test/model/EnvironmentModel"; import {parseEnvironment} from "../../../test/model/EnvironmentModel";
import MsTag from "../../../../common/components/MsTag"; import MsTag from "../../../../common/components/MsTag";
import MsEnvironmentSelect from "./MsEnvironmentSelect";
import {API_METHOD_COLOUR} from "../../model/JsonData"; import {API_METHOD_COLOUR} from "../../model/JsonData";
export default { export default {
name: "ApiCaseHeader", name: "ApiCaseHeader",
components: {MsTag, ApiEnvironmentConfig}, components: {MsEnvironmentSelect, MsTag, ApiEnvironmentConfig},
data() { data() {
return { return {
environments: [], environments: [],
@ -141,6 +126,9 @@
environmentConfigClose() { environmentConfigClose() {
this.getEnvironments(); this.getEnvironments();
}, },
setEnvironment(data) {
this.$emit('setEnvironment', data);
},
getApiTest() { getApiTest() {
this.$emit('getApiTest'); this.$emit('getApiTest');
}, },
@ -183,9 +171,10 @@
font-size: 10px; font-size: 10px;
} }
.environment-button {
margin-left: 20px; .el-col {
padding: 7px; height: 32px;
line-height: 32px;
} }
.ms-api-header-select { .ms-api-header-select {

View File

@ -14,7 +14,7 @@
<el-col :span="10"> <el-col :span="10">
<i class="icon el-icon-arrow-right" :class="{'is-active': apiCase.active}" <i class="icon el-icon-arrow-right" :class="{'is-active': apiCase.active}"
@click="active(apiCase)"/> @click="active(apiCase)"/>
<el-input v-if="!apiCase.id" size="small" v-model="apiCase.name" :name="index" :key="index" <el-input v-if="!apiCase.id || isShowInput" size="small" v-model="apiCase.name" :name="index" :key="index"
class="ms-api-header-select" style="width: 180px" class="ms-api-header-select" style="width: 180px"
@blur="saveTestCase(apiCase)"/> @blur="saveTestCase(apiCase)"/>
<span v-else> <span v-else>
@ -111,6 +111,7 @@
checkedCases: new Set(), checkedCases: new Set(),
visible: false, visible: false,
condition: {}, condition: {},
isShowInput: false
} }
}, },
props: { props: {
@ -175,6 +176,7 @@
} }
}, },
saveTestCase(row) { saveTestCase(row) {
this.isShowInput = false;
if (this.validate(row)) { if (this.validate(row)) {
return; return;
} }
@ -192,6 +194,7 @@
}, },
showInput(row) { showInput(row) {
// row.type = "create"; // row.type = "create";
this.isShowInput = true;
row.active = true; row.active = true;
this.active(row); this.active(row);
}, },

View File

@ -206,7 +206,7 @@
}, },
singleRun(row) { singleRun(row) {
if (!this.environment) { if (!this.environment || !this.environment) {
this.$warning(this.$t('api_test.environment.select_environment')); this.$warning(this.$t('api_test.environment.select_environment'));
return; return;
} }

View File

@ -0,0 +1,107 @@
<template>
<span>
<el-select :disabled="isReadOnly" v-model="environmentId" size="small" class="environment-select"
:placeholder="$t('api_test.definition.request.run_env')" clearable>
<el-option v-for="(environment, key) in environments" :key="key"
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
:value="environment.id"/>
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">
{{ $t('api_test.environment.environment_config') }}
</el-button>
<template v-slot:empty>
<div class="empty-environment">
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">
{{ $t('api_test.environment.environment_config') }}
</el-button>
</div>
</template>
</el-select>
<!-- 环境 -->
<api-environment-config ref="environmentConfig" @close="environmentConfigClose"/>
</span>
</template>
<script>
import ApiEnvironmentConfig from "../../../test/components/ApiEnvironmentConfig";
import {parseEnvironment} from "../../../test/model/EnvironmentModel";
export default {
name: "MsEnvironmentSelect",
components: {ApiEnvironmentConfig},
data() {
return {
environments: [],
environment: undefined,
isShow: true,
environmentId: ""
}
},
props:['projectId','isReadOnly'],
created() {
this.getEnvironments();
},
watch: {
projectId() {
this.getEnvironments();
},
environment() {
this.$emit('setEnvironment', this.environment);
},
environmentId() {
this.environmentChange(this.environmentId);
},
// planEnvironmentId() {
// this.environmentId = this.planEnvironmentId;
// }
},
methods: {
getEnvironments() {
if (this.projectId) {
this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data;
this.environments.forEach(environment => {
parseEnvironment(environment);
// if (this.planEnvironmentId && environment.id === this.planEnvironmentId) {
// this.planEnvironmentId = environment.id;
// }
});
});
} else {
this.environmentId = undefined;
}
},
openEnvironmentConfig() {
if (!this.projectId) {
this.$error(this.$t('api_test.select_project'));
return;
}
this.$refs.environmentConfig.open(this.projectId);
},
environmentChange(value) {
for (let i in this.environments) {
if (this.environments[i].id === value) {
this.environment = this.environments[i];
break;
}
}
},
environmentConfigClose() {
this.getEnvironments();
},
}
}
</script>
<style scoped>
.environment-button {
margin-left: 20px;
padding: 7px;
}
.ms-api-header-select {
margin-left: 20px;
min-width: 100px;
}
</style>

View File

@ -1,9 +1,25 @@
<template> <template>
<div> <div>
<api-list-container <api-list-container
:is-show-change-button="!isPlanModel"
:is-api-list-enable="isApiListEnable" :is-api-list-enable="isApiListEnable"
@isApiListEnableChange="isApiListEnableChange"> @isApiListEnableChange="isApiListEnableChange">
<el-input placeholder="搜索" @blur="search" class="search-input" size="small" v-model="condition.name"/>
<ms-environment-select v-if="isRelevanceModel" :project-id="relevanceProjectId" :is-read-only="isReadOnly" @setEnvironment="setEnvironment"/>
<el-input v-if="!isPlanModel" placeholder="搜索" @blur="search" class="search-input" size="small" v-model="condition.name"/>
<template v-slot:header>
<test-plan-case-list-header
:project-id="getProjectId()"
:condition="condition"
:plan-id="planId"
@refresh="initTable"
@relevanceCase="$emit('relevanceCase')"
@setEnvironment="setEnvironment"
v-if="isPlanModel"/>
</template>
<el-table v-loading="result.loading" <el-table v-loading="result.loading"
border border
:data="tableData" row-key="id" class="test-content adjust-table" :data="tableData" row-key="id" class="test-content adjust-table"
@ -14,7 +30,7 @@
<el-table-column type="selection"/> <el-table-column type="selection"/>
<el-table-column width="40" :resizable="false" align="center"> <el-table-column width="40" :resizable="false" align="center">
<template v-slot:default="scope"> <template v-slot:default="scope">
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectRows.size"/> <show-more-btn :is-show="scope.row.showMore && !isReadOnly" :buttons="buttons" :size="selectRows.size"/>
</template> </template>
</el-table-column> </el-table-column>
@ -51,8 +67,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-if="!isReadOnly && !isRelevanceModel" :label="$t('commons.operating')" min-width="130" align="center">
<el-table-column :label="$t('commons.operating')" min-width="130" align="center">
<template v-slot:default="scope"> <template v-slot:default="scope">
<!--<el-button type="text" @click="reductionApi(scope.row)" v-if="trashEnable">恢复</el-button>--> <!--<el-button type="text" @click="reductionApi(scope.row)" v-if="trashEnable">恢复</el-button>-->
<el-button type="text" @click="handleTestCase(scope.row)" v-if="!trashEnable">{{$t('commons.edit')}}</el-button> <el-button type="text" @click="handleTestCase(scope.row)" v-if="!trashEnable">{{$t('commons.edit')}}</el-button>
@ -65,19 +80,17 @@
:total="total"/> :total="total"/>
</api-list-container> </api-list-container>
<api-case-list @showExecResult="showExecResult" @refresh="initTable" :currentApi="selectCase" ref="caseList"/> <api-case-list v-if="!isRelevanceModel" @showExecResult="showExecResult" @refresh="initTable" :currentApi="selectCase" ref="caseList"/>
<!--批量编辑--> <!--批量编辑-->
<ms-batch-edit ref="batchEdit" @batchEdit="batchEdit" :typeArr="typeArr" :value-arr="valueArr"/> <ms-batch-edit v-if="!isRelevanceModel" ref="batchEdit" @batchEdit="batchEdit" :typeArr="typeArr" :value-arr="valueArr"/>
</div> </div>
</template> </template>
<script> <script>
import MsTableHeader from '../../../../common/components/MsTableHeader';
import MsTableOperator from "../../../../common/components/MsTableOperator"; import MsTableOperator from "../../../../common/components/MsTableOperator";
import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton"; import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton";
import MsTableButton from "../../../../common/components/MsTableButton";
import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent"; import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent";
import MsTablePagination from "../../../../common/pagination/TablePagination"; import MsTablePagination from "../../../../common/pagination/TablePagination";
import MsTag from "../../../../common/components/MsTag"; import MsTag from "../../../../common/components/MsTag";
@ -92,17 +105,19 @@
import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem"; import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem";
import ApiCaseList from "../case/ApiCaseList"; import ApiCaseList from "../case/ApiCaseList";
import {_filter, _sort} from "../../../../../../common/js/utils"; import {_filter, _sort} from "../../../../../../common/js/utils";
import TestPlanCaseListHeader from "../../../../track/plan/view/comonents/api/TestPlanCaseListHeader";
import MsEnvironmentSelect from "../case/MsEnvironmentSelect";
export default { export default {
name: "ApiCaseSimpleList", name: "ApiCaseSimpleList",
components: { components: {
MsEnvironmentSelect,
TestPlanCaseListHeader,
ApiCaseList, ApiCaseList,
PriorityTableItem, PriorityTableItem,
ApiListContainer, ApiListContainer,
MsTableButton,
MsTableOperatorButton, MsTableOperatorButton,
MsTableOperator, MsTableOperator,
MsTableHeader,
MsTablePagination, MsTablePagination,
MsTag, MsTag,
MsApiCaseList, MsApiCaseList,
@ -140,8 +155,8 @@
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
total: 0, total: 0,
projectId: "",
screenHeight: document.documentElement.clientHeight - 330,// screenHeight: document.documentElement.clientHeight - 330,//
environmentId: undefined
} }
}, },
props: { props: {
@ -155,10 +170,28 @@
type: Boolean, type: Boolean,
default: false, default: false,
}, },
isApiListEnable: Boolean isApiListEnable: {
type: Boolean,
default: false,
},
isReadOnly: {
type: Boolean,
default: false
},
isCaseRelevance: {
type: Boolean,
default: false,
},
relevanceProjectId: String,
model: {
type: String,
default() {
'api'
}
},
planId: String
}, },
created: function () { created: function () {
this.projectId = getCurrentProjectID();
this.initTable(); this.initTable();
}, },
watch: { watch: {
@ -173,6 +206,23 @@
this.initTable(); this.initTable();
} }
}, },
relevanceProjectId() {
this.initTable();
}
},
computed: {
//
isRelevanceModel() {
return this.model === 'relevance'
},
//
isPlanModel() {
return this.model === 'plan'
},
//
isApiModel() {
return this.model === 'api'
},
}, },
methods: { methods: {
isApiListEnableChange(data) { isApiListEnableChange(data) {
@ -187,17 +237,45 @@
this.condition.status = "Trash"; this.condition.status = "Trash";
this.condition.moduleIds = []; this.condition.moduleIds = [];
} }
if (this.projectId != null) {
this.condition.projectId = this.projectId; this.buildCondition(this.condition);
}
if (this.currentProtocol != null) { if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol; this.condition.protocol = this.currentProtocol;
} }
this.result = this.$post("/api/testcase/list/" + this.currentPage + "/" + this.pageSize, this.condition, response => { this.result = this.$post(this.getListUrl() + this.currentPage + "/" + this.pageSize, this.condition, response => {
this.total = response.data.itemCount; this.total = response.data.itemCount;
this.tableData = response.data.listObject; this.tableData = response.data.listObject;
}); });
}, },
buildCondition(condition) {
if (this.isPlanModel) {
condition.planId = this.planId;
} else if (this.isRelevanceModel) {
condition.planId = this.planId;
condition.projectId = this.getProjectId();
} else {
condition.projectId = this.getProjectId();
}
},
getListUrl() {
if (this.isPlanModel) {
return '/test/plan/api/case/list/';
} else if (this.isRelevanceModel) {
return '/test/plan/api/case/relevance/list/';
} else {
return '/api/testcase/list/';
}
},
getDeleteUrl(apiCase) {
if (this.isPlanModel) {
return '/test/plan/api/case/delete/' + this.planId + '/' + apiCase.id;
} else if (this.isRelevanceModel) {
return '/api/testcase/delete/' + apiCase.id;
} else {
return '/api/testcase/delete/' + +apiCase.id;
}
},
// getMaintainerOptions() { // getMaintainerOptions() {
// let workspaceId = localStorage.getItem(WORKSPACE_ID); // let workspaceId = localStorage.getItem(WORKSPACE_ID);
// this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => { // this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
@ -295,8 +373,7 @@
confirmButtonText: this.$t('commons.confirm'), confirmButtonText: this.$t('commons.confirm'),
callback: (action) => { callback: (action) => {
if (action === 'confirm') { if (action === 'confirm') {
let ids = Array.from(this.selectRows).map(row => row.id); this.$post(this.getBatchDeleteParam(), this.buildBatchDeleteParam(), () => {
this.$post('/api/testcase/deleteBatch/', ids, () => {
this.selectRows.clear(); this.selectRows.clear();
this.initTable(); this.initTable();
this.$success(this.$t('commons.delete_success')); this.$success(this.$t('commons.delete_success'));
@ -320,6 +397,23 @@
// }); // });
// } // }
}, },
buildBatchDeleteParam() {
if (this.isPlanModel) {
let request = {};
request.ids = Array.from(this.selectRows).map(row => row.id);
request.planId = this.planId;
return request;
} else {
return Array.from(this.selectRows).map(row => row.id);
}
},
getBatchDeleteParam() {
if (this.isPlanModel) {
return '/test/plan/api/case/batch/delete';
} else {
return '/api/testcase/deleteBatch/';
}
},
handleEditBatch() { handleEditBatch() {
this.$refs.batchEdit.open(); this.$refs.batchEdit.open();
}, },
@ -336,7 +430,7 @@
}, },
handleDelete(apiCase) { handleDelete(apiCase) {
// if (this.trashEnable) { // if (this.trashEnable) {
this.$get('/api/testcase/delete/' + apiCase.id, () => { this.$get(this.getDeleteUrl(apiCase), () => {
this.$success(this.$t('commons.delete_success')); this.$success(this.$t('commons.delete_success'));
this.initTable(); this.initTable();
}); });
@ -354,6 +448,16 @@
// } // }
// } // }
// }); // });
},
getProjectId() {
if (!this.isRelevanceModel) {
return getCurrentProjectID();
} else {
return this.relevanceProjectId;
}
},
setEnvironment(data) {
this.environmentId = data.id;
} }
}, },
} }

View File

@ -3,6 +3,9 @@
<api-list-container <api-list-container
:is-api-list-enable="isApiListEnable" :is-api-list-enable="isApiListEnable"
@isApiListEnableChange="isApiListEnableChange"> @isApiListEnableChange="isApiListEnableChange">
<ms-environment-select :project-id="relevanceProjectId" v-if="isRelevance" :is-read-only="isReadOnly" @setEnvironment="setEnvironment"/>
<el-input placeholder="搜索" @blur="search" class="search-input" size="small" @keyup.enter.native="search" v-model="condition.name"/> <el-input placeholder="搜索" @blur="search" class="search-input" size="small" @keyup.enter.native="search" v-model="condition.name"/>
<el-table v-loading="result.loading" <el-table v-loading="result.loading"
@ -13,7 +16,7 @@
<el-table-column type="selection"/> <el-table-column type="selection"/>
<el-table-column width="40" :resizable="false" align="center"> <el-table-column width="40" :resizable="false" align="center">
<template v-slot:default="scope"> <template v-slot:default="scope">
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectRows.size"/> <show-more-btn :is-show="scope.row.showMore && !isReadOnly" :buttons="buttons" :size="selectRows.size"/>
</template> </template>
</el-table-column> </el-table-column>
@ -73,7 +76,7 @@
:label="$t('api_test.definition.api_case_passing_rate')" :label="$t('api_test.definition.api_case_passing_rate')"
show-overflow-tooltip/> show-overflow-tooltip/>
<el-table-column :label="$t('commons.operating')" min-width="130" align="center"> <el-table-column v-if="!isReadOnly && !isRelevance" :label="$t('commons.operating')" min-width="130" align="center">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-button type="text" @click="reductionApi(scope.row)" v-if="trashEnable">恢复</el-button> <el-button type="text" @click="reductionApi(scope.row)" v-if="trashEnable">恢复</el-button>
<el-button type="text" @click="editApi(scope.row)" v-else>{{$t('commons.edit')}}</el-button> <el-button type="text" @click="editApi(scope.row)" v-else>{{$t('commons.edit')}}</el-button>
@ -110,10 +113,12 @@
import {getCurrentProjectID} from "@/common/js/utils"; import {getCurrentProjectID} from "@/common/js/utils";
import {WORKSPACE_ID} from '../../../../../../common/js/constants'; import {WORKSPACE_ID} from '../../../../../../common/js/constants';
import ApiListContainer from "./ApiListContainer"; import ApiListContainer from "./ApiListContainer";
import MsEnvironmentSelect from "../case/MsEnvironmentSelect";
export default { export default {
name: "ApiList", name: "ApiList",
components: { components: {
MsEnvironmentSelect,
ApiListContainer, ApiListContainer,
MsTableButton, MsTableButton,
MsTableOperatorButton, MsTableOperatorButton,
@ -154,8 +159,8 @@
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
total: 0, total: 0,
projectId: "", screenHeight: document.documentElement.clientHeight - 330,//,
screenHeight: document.documentElement.clientHeight - 330,// environmentId: undefined
} }
}, },
props: { props: {
@ -165,14 +170,23 @@
type: Boolean, type: Boolean,
default: false, default: false,
}, },
isCaseRelevance: {
type: Boolean,
default: false,
},
trashEnable: { trashEnable: {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
isApiListEnable: Boolean isApiListEnable: Boolean,
isReadOnly: {
type: Boolean,
default: false
},
relevanceProjectId: String,
isRelevance: Boolean
}, },
created: function () { created: function () {
this.projectId = getCurrentProjectID();
this.initTable(); this.initTable();
this.getMaintainerOptions(); this.getMaintainerOptions();
}, },
@ -188,6 +202,9 @@
this.initTable(); this.initTable();
} }
}, },
relevanceProjectId() {
this.initTable();
}
}, },
methods: { methods: {
isApiListEnableChange(data) { isApiListEnableChange(data) {
@ -202,9 +219,9 @@
this.condition.filters = ["Trash"]; this.condition.filters = ["Trash"];
this.condition.moduleIds = []; this.condition.moduleIds = [];
} }
if (this.projectId != null) {
this.condition.projectId = this.projectId; this.condition.projectId = this.getProjectId();
}
if (this.currentProtocol != null) { if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol; this.condition.protocol = this.currentProtocol;
} }
@ -363,6 +380,16 @@
}, },
showExecResult(row) { showExecResult(row) {
this.$emit('showExecResult', row); this.$emit('showExecResult', row);
},
getProjectId() {
if (!this.isCaseRelevance) {
return getCurrentProjectID();
} else {
return this.relevanceProjectId;
}
},
setEnvironment(data) {
this.environmentId = data.id;
} }
}, },
} }

View File

@ -1,9 +1,12 @@
<template> <template>
<el-card class="card-content" v-if="isShow"> <el-card class="card-content" v-if="isShow">
<el-button-group> <el-button-group v-if="isShowChangeButton">
<el-button plain size="small" icon="el-icon-tickets" :class="{active: isApiListEnable}" @click="apiChange('api')"></el-button> <el-button plain size="small" icon="el-icon-tickets" :class="{active: isApiListEnable}" @click="apiChange('api')"></el-button>
<el-button plain class="case-button" size="small" icon="el-icon-paperclip" :class="{active: !isApiListEnable}" @click="caseChange('case')"></el-button> <el-button plain class="case-button" size="small" icon="el-icon-paperclip" :class="{active: !isApiListEnable}" @click="caseChange('case')"></el-button>
</el-button-group> </el-button-group>
<template v-slot:header>
<slot name="header"></slot>
</template>
<slot></slot> <slot></slot>
</el-card> </el-card>
</template> </template>
@ -17,7 +20,11 @@
} }
}, },
props: { props: {
isApiListEnable: Boolean isApiListEnable: Boolean,
isShowChangeButton: {
type: Boolean,
default: true
}
}, },
methods: { methods: {
apiChange() { apiChange() {
@ -40,5 +47,4 @@
border-left: solid 1px #6d317c; border-left: solid 1px #6d317c;
} }
</style> </style>

View File

@ -24,7 +24,7 @@
</template> </template>
</el-input> </el-input>
<module-trash-button :condition="condition" :exe="enableTrash"/> <module-trash-button v-if="!isReadOnly" :condition="condition" :exe="enableTrash"/>
<ms-add-basis-api <ms-add-basis-api
:current-protocol="condition.protocol" :current-protocol="condition.protocol"

View File

@ -18,7 +18,22 @@
</el-aside> </el-aside>
<el-main style="padding-left: 0px;padding-right: 0px;"> <el-main style="padding-left: 0px;padding-right: 0px;">
<div style="width: 200px;margin:0 auto"> <div style="width: 200px;margin:0 auto">
<el-row align="center">
<el-row align="center" class="hidden-lg-and-down">
<el-col :span="6" style="padding: 5px;border-right-style: solid;border-right-width: 1px;border-right-color: #ECEEF4;">
<div class="count-info-div" v-html="apiCountData.httpCountStr"></div>
</el-col>
<el-col :span="6" style="padding: 5px;border-right-style: solid;border-right-width: 1px;border-right-color: #ECEEF4;">
<div class="count-info-div" v-html="apiCountData.rpcCountStr"></div>
</el-col>
<el-col :span="6" style="padding: 5px;border-right-style: solid;border-right-width: 1px;border-right-color: #ECEEF4;">
<div class="count-info-div" v-html="apiCountData.tcpCountStr"></div>
</el-col>
<el-col :span="6" style="padding: 5px;">
<div class="count-info-div" v-html="apiCountData.sqlCountStr"></div>
</el-col>
</el-row>
<el-row align="right" style="margin-left: 20px" class="hidden-xl-only">
<el-col :span="6" style="padding: 5px;border-right-style: solid;border-right-width: 1px;border-right-color: #ECEEF4;"> <el-col :span="6" style="padding: 5px;border-right-style: solid;border-right-width: 1px;border-right-color: #ECEEF4;">
<div class="count-info-div" v-html="apiCountData.httpCountStr"></div> <div class="count-info-div" v-html="apiCountData.httpCountStr"></div>
</el-col> </el-col>

View File

@ -11,8 +11,16 @@
<el-table-column prop="rule" :label="$t('api_test.home_page.running_task_list.table_coloum.run_rule')" width="120" show-overflow-tooltip/> <el-table-column prop="rule" :label="$t('api_test.home_page.running_task_list.table_coloum.run_rule')" width="120" show-overflow-tooltip/>
<el-table-column width="100" :label="$t('api_test.home_page.running_task_list.table_coloum.task_status')"> <el-table-column width="100" :label="$t('api_test.home_page.running_task_list.table_coloum.task_status')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-switch @click.stop.native v-model="scope.row.taskStatus" @change="updateTask(scope.row)"/> <div>
<el-switch
v-model="scope.row.taskStatus"
class="captcha-img"
@click.native="closeTaskConfirm(scope.row)"
></el-switch>
</div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="170" :label="$t('api_test.home_page.running_task_list.table_coloum.next_execution_time')"> <el-table-column width="170" :label="$t('api_test.home_page.running_task_list.table_coloum.next_execution_time')">
<template v-slot:default="scope"> <template v-slot:default="scope">
@ -41,6 +49,7 @@ export default {
value: '100', value: '100',
result: {}, result: {},
tableData: [], tableData: [],
visible: false,
loading: false loading: false
} }
}, },
@ -53,6 +62,19 @@ export default {
}); });
}, },
closeTaskConfirm(row){
let flag = row.taskStatus;
row.taskStatus = !flag; //switch
this.$confirm(this.$t('api_test.home_page.running_task_list.confirm.close_title'), this.$t('commons.prompt'), {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
}).then(() => {
this.updateTask(row);
}).catch(() => {
});
},
updateTask(taskRow){ updateTask(taskRow){
this.result = this.$post('/api/schedule/updateEnableByPrimyKey', taskRow, response => { this.result = this.$post('/api/schedule/updateEnableByPrimyKey', taskRow, response => {
@ -66,8 +88,11 @@ export default {
}, },
activated() { activated() {
this.search(); this.search();
},
handleStatus(scope) {
console.log(scope.row.userId)
}
} }
}
</script> </script>
<style scoped> <style scoped>

View File

@ -18,7 +18,21 @@
</el-aside> </el-aside>
<el-main style="padding-left: 0px;padding-right: 0px"> <el-main style="padding-left: 0px;padding-right: 0px">
<div style="width: 200px;margin:0 auto"> <div style="width: 200px;margin:0 auto">
<el-row align="center"> <el-row align="center" class="hidden-lg-and-down">
<el-col :span="6" style="padding: 5px;border-right-style: solid;border-right-width: 1px;border-right-color: #ECEEF4;">
<div class="count-info-div" v-html="testCaseCountData.httpCountStr"></div>
</el-col>
<el-col :span="6" style="padding: 5px;border-right-style: solid;border-right-width: 1px;border-right-color: #ECEEF4;">
<div class="count-info-div" v-html="testCaseCountData.rpcCountStr"></div>
</el-col>
<el-col :span="6" style="padding: 5px;border-right-style: solid;border-right-width: 1px;border-right-color: #ECEEF4;">
<div class="count-info-div" v-html="testCaseCountData.tcpCountStr"></div>
</el-col>
<el-col :span="6" style="padding: 5px;">
<div class="count-info-div" v-html="testCaseCountData.sqlCountStr"></div>
</el-col>
</el-row>
<el-row align="right" style="margin-left: 20px" class="hidden-xl-only">
<el-col :span="6" style="padding: 5px;border-right-style: solid;border-right-width: 1px;border-right-color: #ECEEF4;"> <el-col :span="6" style="padding: 5px;border-right-style: solid;border-right-width: 1px;border-right-color: #ECEEF4;">
<div class="count-info-div" v-html="testCaseCountData.httpCountStr"></div> <div class="count-info-div" v-html="testCaseCountData.httpCountStr"></div>
</el-col> </el-col>

View File

@ -17,6 +17,7 @@
<slot name="button"></slot> <slot name="button"></slot>
</span> </span>
<span> <span>
<slot name="searchBarBefore"></slot>
<ms-table-search-bar :condition.sync="condition" @change="search" class="search-bar" :tip="tip"/> <ms-table-search-bar :condition.sync="condition" @change="search" class="search-bar" :tip="tip"/>
<ms-table-adv-search-bar :condition.sync="condition" @search="search" v-if="isCombine"/> <ms-table-adv-search-bar :condition.sync="condition" @search="search" v-if="isCombine"/>
</span> </span>

View File

@ -114,6 +114,7 @@
} }
], ],
phone: [ phone: [
{required: true, message: this.$t('user.input_phone'), trigger: 'blur'},
{ {
required: false, required: false,
pattern: PHONE_REGEX, pattern: PHONE_REGEX,

View File

@ -1,5 +1,5 @@
<template> <template>
<div> <div class="select-menu">
<span class="menu-title">{{'[' + title + ']'}}</span> <span class="menu-title">{{'[' + title + ']'}}</span>
<el-select filterable slot="prepend" v-model="value" @change="changeData" :style="{width: width}" <el-select filterable slot="prepend" v-model="value" @change="changeData" :style="{width: width}"
size="small"> size="small">

View File

@ -7,27 +7,17 @@
ref="baseRelevance"> ref="baseRelevance">
<template v-slot:aside> <template v-slot:aside>
<!--<node-tree class="node-tree"-->
<!--@nodeSelectEvent="nodeChange"-->
<!--@refresh="refresh"-->
<!--:tree-nodes="treeNodes"-->
<!--ref="nodeTree"/>-->
<ms-api-module <ms-api-module
@nodeSelectEvent="nodeChange" @nodeSelectEvent="nodeChange"
@protocolChange="handleProtocolChange" @protocolChange="handleProtocolChange"
@refreshTable="refresh" @refreshTable="refresh"
@exportAPI="exportAPI"
@debug="debug"
@saveAsEdit="editApi"
@setModuleOptions="setModuleOptions" @setModuleOptions="setModuleOptions"
@enableTrash="enableTrash"
:is-read-only="true" :is-read-only="true"
:type="'edit'" :type="'edit'"
ref="nodeTree"/> ref="nodeTree"/>
</template> </template>
<ms-table-header :condition.sync="condition" @search="search" title="" :show-create="false"/> <!-- 列表集合 -->
<api-list <api-list
v-if="isApiListEnable" v-if="isApiListEnable"
:current-protocol="currentProtocol" :current-protocol="currentProtocol"
@ -35,12 +25,27 @@
:select-node-ids="selectNodeIds" :select-node-ids="selectNodeIds"
:trash-enable="trashEnable" :trash-enable="trashEnable"
:is-api-list-enable="isApiListEnable" :is-api-list-enable="isApiListEnable"
@editApi="editApi" :is-case-relevance="true"
@handleCase="handleCase" :relevance-project-id="projectId"
@showExecResult="showExecResult" :is-relevance="true"
@isApiListEnableChange="isApiListEnableChange" @isApiListEnableChange="isApiListEnableChange"
ref="apiList"/> ref="apiList"/>
<!--测试用例列表-->
<api-case-simple-list
v-if="!isApiListEnable"
:current-protocol="currentProtocol"
:currentRow="currentRow"
:select-node-ids="selectNodeIds"
:trash-enable="trashEnable"
:is-api-list-enable="isApiListEnable"
:is-case-relevance="true"
:relevance-project-id="projectId"
:plan-id="planId"
:model="'relevance'"
@isApiListEnableChange="isApiListEnableChange"
ref="apiCaseList"/>
</test-case-relevance-base> </test-case-relevance-base>
@ -48,47 +53,32 @@
<script> <script>
import NodeTree from '../../../../common/NodeTree';
import PriorityTableItem from "../../../../common/tableItems/planview/PriorityTableItem";
import TypeTableItem from "../../../../common/tableItems/planview/TypeTableItem";
import MsTableSearchBar from "../../../../../common/components/MsTableSearchBar";
import MsTableAdvSearchBar from "../../../../../common/components/search/MsTableAdvSearchBar";
import MsTableHeader from "../../../../../common/components/MsTableHeader";
import elTableInfiniteScroll from 'el-table-infinite-scroll';
import TestCaseRelevanceBase from "../base/TestCaseRelevanceBase"; import TestCaseRelevanceBase from "../base/TestCaseRelevanceBase";
import ApiList from "../../../../../api/automation/scenario/api/ApiList";
import MsApiModule from "../../../../../api/definition/components/module/ApiModule"; import MsApiModule from "../../../../../api/definition/components/module/ApiModule";
import {getCurrentProjectID} from "../../../../../../../common/js/utils"; import {getCurrentProjectID} from "../../../../../../../common/js/utils";
import ApiList from "../../../../../api/definition/components/list/ApiList";
import ApiCaseSimpleList from "../../../../../api/definition/components/list/ApiCaseSimpleList";
export default { export default {
name: "TestCaseApiRelevance", name: "TestCaseApiRelevance",
components: { components: {
MsApiModule, ApiCaseSimpleList,
ApiList, ApiList,
MsApiModule,
TestCaseRelevanceBase, TestCaseRelevanceBase,
NodeTree,
PriorityTableItem,
TypeTableItem,
MsTableSearchBar,
MsTableAdvSearchBar,
MsTableHeader,
},
directives: {
'el-table-infinite-scroll': elTableInfiniteScroll
}, },
data() { data() {
return { return {
showCasePage: true, showCasePage: true,
apiDefaultTab: 'default',
currentProtocol: null, currentProtocol: null,
currentModule: null, currentModule: null,
selectNodeIds: [], selectNodeIds: [],
currentApi: {},
moduleOptions: {}, moduleOptions: {},
trashEnable: false, trashEnable: false,
isApiListEnable: true, isApiListEnable: true,
condition: {}, condition: {},
currentRow: {} currentRow: {},
projectId: ""
}; };
}, },
props: { props: {
@ -98,97 +88,26 @@
}, },
watch: { watch: {
planId() { planId() {
// this.condition.planId = this.planId; this.condition.planId = this.planId;
}, },
projectId() {
this.condition.projectId = this.projectId;
// this.getProjectNode();
// this.search();
}
},
updated() {
this.toggleSelection(this.testCases);
}, },
methods: { methods: {
open() { open() {
this.$refs.baseRelevance.open(); this.$refs.baseRelevance.open();
}, },
search() {
},
setProject(projectId) { setProject(projectId) {
this.projectId = projectId; this.projectId = projectId;
}, },
isApiListEnableChange(data) { isApiListEnableChange(data) {
this.isApiListEnable = data; this.isApiListEnable = data;
}, },
handleCommand(e) {
switch (e) {
case "ADD":
this.handleTabAdd(e);
break;
case "TEST":
this.handleTabsEdit(this.$t("commons.api"), e);
break;
case "CLOSE_ALL":
this.handleTabClose();
break;
default:
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug");
break;
}
},
debug(id) {
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug", id);
},
editApi(row) {
let name = this.$t('api_test.definition.request.edit_api');
if (row.name) {
name = this.$t('api_test.definition.request.edit_api') + "-" + row.name;
}
// this.handleTabsEdit(name, "ADD", row);
},
handleCase(api) {
this.currentApi = api;
this.showCasePage = false;
},
apiCaseClose() {
this.showCasePage = true;
},
exportAPI() {
if (!this.$refs.apiList[0].tableData) {
return;
}
let obj = {projectName: getCurrentProjectID(), protocol: this.currentProtocol, data: this.$refs.apiList[0].tableData}
// downloadFile("API.json", JSON.stringify(obj));
},
refresh(data) {
this.$refs.apiList[0].initTable(data);
},
setTabTitle(data) {
for (let index in this.apiTabs) {
let tab = this.apiTabs[index];
if (tab.name === this.apiDefaultTab) {
tab.title = this.$t('api_test.definition.request.edit_api') + "-" + data.name;
break;
}
}
this.runTestData = data;
},
runTest(data) {
this.setTabTitle(data);
this.handleCommand("TEST");
},
saveApi(data) {
this.setTabTitle(data);
this.$refs.apiList[0].initApiTable(data);
},
showExecResult(row){ refresh(data) {
this.debug(row); if (this.isApiListEnable) {
this.$refs.apiList.initTable(data);
} else {
this.$refs.apiCaseList.initTable(data);
}
}, },
nodeChange(node, nodeIds, pNodes) { nodeChange(node, nodeIds, pNodes) {
@ -200,26 +119,42 @@
setModuleOptions(data) { setModuleOptions(data) {
this.moduleOptions = data; this.moduleOptions = data;
}, },
enableTrash(data) {
this.trashEnable = data;
},
saveCaseRelevance() { saveCaseRelevance() {
let param = {}; let param = {};
param.planId = this.planId; let url = '';
param.testCaseIds = [...this.selectIds]; let environmentId = undefined;
param.request = this.condition; let selectIds = [];
// if (this.isApiListEnable) {
if (this.testCases.length === param.testCaseIds.length) { url = '/api/definition/relevance';
param.testCaseIds = ['all']; environmentId = this.$refs.apiList.environmentId;
selectIds = Array.from(this.$refs.apiList.selectRows).map(row => row.id);
} else {
url = '/api/testcase/relevance';
environmentId = this.$refs.apiCaseList.environmentId;
selectIds = Array.from(this.$refs.apiCaseList.selectRows).map(row => row.id);
} }
this.result = this.$post('/test/plan/relevance', param, () => {
this.selectIds.clear(); if (!environmentId) {
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
param.planId = this.planId;
param.selectIds = selectIds;
param.environmentId = environmentId;
// param.request = this.condition;
//
// if (this.testCases.length === param.testCaseIds.length) {
// param.testCaseIds = ['all'];
// }
this.result = this.$post(url, param, () => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.$refs.baseRelevance.close();
this.$emit('refresh'); this.$emit('refresh');
this.refresh();
this.$refs.baseRelevance.close();
}); });
}, },
} }
@ -227,4 +162,14 @@
</script> </script>
<style scoped> <style scoped>
/deep/ .select-menu {
margin-bottom: 15px;
}
/deep/ .environment-select {
float: right;
margin-right: 10px;
}
</style> </style>

View File

@ -2,30 +2,34 @@
<ms-test-plan-common-component> <ms-test-plan-common-component>
<template v-slot:aside> <template v-slot:aside>
<node-tree class="node-tree" <ms-api-module
v-loading="result.loading"
@nodeSelectEvent="nodeChange" @nodeSelectEvent="nodeChange"
@refresh="refresh" @protocolChange="handleProtocolChange"
:tree-nodes="treeNodes" @refreshTable="refresh"
:draggable="false" @setModuleOptions="setModuleOptions"
:is-read-only="true"
:type="'edit'"
ref="nodeTree"/> ref="nodeTree"/>
</template> </template>
<template v-slot:main> <template v-slot:main>
<!--测试用例列表-->
<test-plan-api-case-list <test-plan-api-case-list
class="table-list" :current-protocol="currentProtocol"
@openTestCaseRelevanceDialog="openTestCaseRelevanceDialog" :currentRow="currentRow"
@refresh="refresh"
:plan-id="planId"
:select-node-ids="selectNodeIds" :select-node-ids="selectNodeIds"
:select-parent-nodes="selectParentNodes" :trash-enable="trashEnable"
ref="testPlanTestCaseList"/> :is-case-relevance="true"
:model="'plan'"
:plan-id="planId"
@relevanceCase="openTestCaseRelevanceDialog"
ref="apiCaseList"/>
</template> </template>
<test-case-api-relevance <test-case-api-relevance
@refresh="refresh" @refresh="refresh"
:plan-id="planId" :plan-id="planId"
ref="testCaseRelevance"/> ref="apiCaseRelevance"/>
</ms-test-plan-common-component> </ms-test-plan-common-component>
@ -33,84 +37,140 @@
<script> <script>
import NodeTree from "../../../../common/NodeTree"; import NodeTree from "../../../../common/NodeTree";
import TestPlanTestCaseList from "../functional/FunctionalTestCaseList";
import TestCaseRelevance from "../functional/TestCaseFunctionalRelevance"; import TestCaseRelevance from "../functional/TestCaseFunctionalRelevance";
import MsTestPlanCommonComponent from "../base/TestPlanCommonComponent"; import MsTestPlanCommonComponent from "../base/TestPlanCommonComponent";
import TestPlanApiCaseList from "./TestPlanApiCaseList"; import TestPlanApiCaseList from "./TestPlanApiCaseList";
import TestCaseApiRelevance from "./TestCaseApiRelevance"; import TestCaseApiRelevance from "./TestCaseApiRelevance";
import ApiCaseSimpleList from "../../../../../api/definition/components/list/ApiCaseSimpleList";
import MsApiModule from "../../../../../api/definition/components/module/ApiModule";
export default { export default {
name: "TestPlanApi", name: "TestPlanApi",
components: { components: {
MsApiModule,
ApiCaseSimpleList,
TestCaseApiRelevance, TestCaseApiRelevance,
TestPlanApiCaseList, TestPlanApiCaseList,
MsTestPlanCommonComponent, MsTestPlanCommonComponent,
TestCaseRelevance, TestCaseRelevance,
TestPlanTestCaseList,
NodeTree, NodeTree,
}, },
data() { data() {
return { return {
result: {}, result: {},
selectNodeIds: [],
selectParentNodes: [], selectParentNodes: [],
treeNodes: [], treeNodes: [],
currentRow: "",
trashEnable: false,
currentProtocol: null,
currentModule: null,
selectNodeIds: [],
moduleOptions: {},
} }
}, },
props: [ props: [
'planId' 'planId'
], ],
mounted() { mounted() {
this.initData(); // this.initData();
this.openTestCaseEdit(this.$route.path); // this.openTestCaseEdit(this.$route.path);
}, },
watch: { watch: {
'$route'(to, from) { '$route'(to, from) {
this.openTestCaseEdit(to.path); // this.openTestCaseEdit(to.path);
}, },
planId() { planId() {
this.initData(); // this.initData();
} }
}, },
methods: { methods: {
refresh() { setProject(projectId) {
this.selectNodeIds = []; this.projectId = projectId;
this.selectParentNodes = [];
this.$refs.testCaseRelevance.search();
this.getNodeTreeByPlanId();
}, },
initData() { // isApiListEnableChange(data) {
this.getNodeTreeByPlanId(); // this.isApiListEnable = data;
// },
refresh(data) {
this.$refs.nodeTree.list();
this.$refs.apiCaseList.initTable();
}, },
openTestCaseRelevanceDialog() {
this.$refs.testCaseRelevance.open(); nodeChange(node, nodeIds, pNodes) {
},
nodeChange(nodeIds, pNodes) {
this.selectNodeIds = nodeIds; this.selectNodeIds = nodeIds;
this.selectParentNodes = pNodes;
// node
this.$refs.testPlanTestCaseList.currentPage = 1;
this.$refs.testPlanTestCaseList.pageSize = 10;
}, },
getNodeTreeByPlanId() { handleProtocolChange(protocol) {
if (this.planId) { this.currentProtocol = protocol;
this.result = this.$get("/case/node/list/plan/" + this.planId, response => { },
this.treeNodes = response.data; setModuleOptions(data) {
this.moduleOptions = data;
},
saveCaseRelevance() {
let url = '';
let selectIds = [];
// if (this.isApiListEnable) {
// url = '/api/definition/relevance';
// selectIds = Array.from(this.$refs.apiList.selectRows).map(row => row.id);
// } else {
// url = '/api/testcase/relevance';
// selectIds = Array.from(this.$refs.apiCaseList.selectRows).map(row => row.id);
// }
let param = {};
param.planId = this.planId;
param.selectIds = selectIds;
// param.request = this.condition;
//
// if (this.testCases.length === param.testCaseIds.length) {
// param.testCaseIds = ['all'];
// }
this.result = this.$post(url, param, () => {
this.$success(this.$t('commons.save_success'));
this.refresh();
this.$refs.baseRelevance.close();
}); });
}
}, },
openTestCaseEdit(path) { // refresh() {
if (path.indexOf("/plan/view/edit") >= 0) { // this.selectNodeIds = [];
let caseId = this.$route.params.caseId; // this.selectParentNodes = [];
this.$get('/test/plan/case/get/' + caseId, response => { // this.$refs.testCaseRelevance.search();
let testCase = response.data; // this.getNodeTreeByPlanId();
if (testCase) { // },
this.$refs.testPlanTestCaseList.handleEdit(testCase); // initData() {
this.$router.push('/track/plan/view/' + testCase.planId); // this.getNodeTreeByPlanId();
} // },
}); openTestCaseRelevanceDialog() {
} this.$refs.apiCaseRelevance.open();
}, },
// nodeChange(nodeIds, pNodes) {
// this.selectNodeIds = nodeIds;
// this.selectParentNodes = pNodes;
// // node
// this.$refs.testPlanTestCaseList.currentPage = 1;
// this.$refs.testPlanTestCaseList.pageSize = 10;
// },
// getNodeTreeByPlanId() {
// if (this.planId) {
// this.result = this.$get("/case/node/list/plan/" + this.planId, response => {
// this.treeNodes = response.data;
// });
// }
// },
// openTestCaseEdit(path) {
// if (path.indexOf("/plan/view/edit") >= 0) {
// let caseId = this.$route.params.caseId;
// this.$get('/test/plan/case/get/' + caseId, response => {
// let testCase = response.data;
// if (testCase) {
// this.$refs.testPlanTestCaseList.handleEdit(testCase);
// this.$router.push('/track/plan/view/' + testCase.planId);
// }
// });
// }
// },
} }
} }

View File

@ -2,494 +2,265 @@
<div class="card-container"> <div class="card-container">
<el-card class="card-content" v-loading="result.loading"> <el-card class="card-content" v-loading="result.loading">
<template v-slot:header> <template v-slot:header>
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="initTableData" <test-plan-case-list-header
:show-create="false" :tip="$t('commons.search_by_name_or_id')"> :project-id="getProjectId()"
<template v-slot:title> :condition="condition"
<node-breadcrumb class="table-title" :nodes="selectParentNodes" @refresh="breadcrumbRefresh"/> :plan-id="planId"
</template> @refresh="initTable"
<template v-slot:button> @relevanceCase="$emit('relevanceCase')"
<ms-table-button :is-tester-permission="true" v-if="!showMyTestCase" icon="el-icon-s-custom" @setEnvironment="setEnvironment"
:content="$t('test_track.plan_view.my_case')" @click="searchMyTestCase"/> v-if="isPlanModel"/>
<ms-table-button :is-tester-permission="true" v-if="showMyTestCase" icon="el-icon-files"
:content="$t('test_track.plan_view.all_case')" @click="searchMyTestCase"/>
<ms-table-button :is-tester-permission="true" icon="el-icon-connection"
:content="$t('test_track.plan_view.relevance_test_case')"
@click="$emit('openTestCaseRelevanceDialog')"/>
<ms-table-button :is-tester-permission="true" v-if="!testPlan.reportId" icon="el-icon-document"
:content="$t('test_track.plan_view.create_report')" @click="openTestReport"/>
<ms-table-button :is-tester-permission="true" v-if="testPlan.reportId" icon="el-icon-document"
:content="$t('test_track.plan_view.view_report')" @click="openReport"/>
<ms-table-button :is-tester-permission="true" icon="el-icon-document-remove"
:content="$t('test_track.plan_view.cancel_all_relevance')" @click="handleDeleteBatch"/>
</template>
</ms-table-header>
</template> </template>
<executor-edit ref="executorEdit" :select-ids="new Set(Array.from(this.selectRows).map(row => row.id))" <el-table v-loading="result.loading"
@refresh="initTableData"/>
<status-edit ref="statusEdit" :plan-id="planId"
:select-ids="new Set(Array.from(this.selectRows).map(row => row.id))" @refresh="initTableData"/>
<el-table
class="adjust-table"
border border
:data="tableData" row-key="id" class="test-content adjust-table"
@select-all="handleSelectAll" @select-all="handleSelectAll"
@filter-change="filter" @filter-change="filter"
@sort-change="sort" @sort-change="sort"
@select="handleSelectionChange" @select="handleSelect" :height="screenHeight">
row-key="id" <el-table-column type="selection"/>
@row-click="showDetail"
:data="tableData">
<el-table-column
type="selection"/>
<el-table-column width="40" :resizable="false" align="center"> <el-table-column width="40" :resizable="false" align="center">
<template v-slot:default="scope"> <template v-slot:default="scope">
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectRows.size"/> <show-more-btn :is-show="scope.row.showMore && !isReadOnly" :buttons="buttons" :size="selectRows.size"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
prop="num" <el-table-column prop="name" :label="$t('api_test.definition.api_name')" show-overflow-tooltip/>
sortable="custom"
:label="$t('commons.id')"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="name"
:label="$t('commons.name')"
show-overflow-tooltip>
</el-table-column>
<el-table-column <el-table-column
prop="priority" prop="priority"
:filters="priorityFilters" :filters="priorityFilters"
column-key="priority" column-key="priority"
:label="$t('test_track.case.priority')"> :label="$t('test_track.case.priority')"
show-overflow-tooltip>
<template v-slot:default="scope"> <template v-slot:default="scope">
<priority-table-item :value="scope.row.priority" ref="priority"/> <priority-table-item :value="scope.row.priority"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="type" prop="path"
:filters="typeFilters" :label="$t('api_test.definition.api_path')"
column-key="type" show-overflow-tooltip/>
:label="$t('test_track.case.type')"
show-overflow-tooltip>
<template v-slot:default="scope">
<type-table-item :value="scope.row.type"/>
</template>
</el-table-column>
<el-table-column <el-table-column
prop="method" prop="createUser"
:filters="methodFilters" :label="'创建人'"
column-key="method" show-overflow-tooltip/>
:label="$t('test_track.case.method')"
show-overflow-tooltip>
<template v-slot:default="scope">
<method-table-item :value="scope.row.method"/>
</template>
</el-table-column>
<el-table-column <el-table-column
prop="nodePath" sortable="custom"
:label="$t('test_track.case.module')" width="160"
show-overflow-tooltip> :label="$t('api_test.definition.api_last_time')"
</el-table-column> prop="updateTime">
<el-table-column
prop="projectName"
:label="$t('test_track.plan.plan_project')"
show-overflow-tooltip>
</el-table-column>
<el-table-column
:label="$t('test_track.issue.issue')"
show-overflow-tooltip>
<template v-slot:default="scope">
<el-popover
placement="right"
width="400"
trigger="hover">
<el-table border class="adjust-table" :data="scope.row.issuesContent" style="width: 100%">
<el-table-column prop="title" :label="$t('test_track.issue.title')" show-overflow-tooltip/>
<el-table-column prop="description" :label="$t('test_track.issue.description')">
<template v-slot:default="scope">
<el-popover
placement="left"
width="400"
trigger="hover"
>
<ckeditor :editor="editor" disabled :config="editorConfig"
v-model="scope.row.description"/>
<el-button slot="reference" type="text">{{ $t('test_track.issue.preview') }}</el-button>
</el-popover>
</template>
</el-table-column>
<el-table-column prop="platform" :label="$t('test_track.issue.platform')"/>
</el-table>
<el-button slot="reference" type="text">{{ scope.row.issuesSize }}</el-button>
</el-popover>
</template>
</el-table-column>
<el-table-column
prop="executorName"
:filters="executorFilters"
column-key="executor"
:label="$t('test_track.plan_view.executor')">
</el-table-column>
<el-table-column
prop="status"
:filters="statusFilters"
column-key="status"
:label="$t('test_track.plan_view.execute_result')">
<template v-slot:default="scope">
<span @click.stop="clickt = 'stop'">
<el-dropdown class="test-case-status" @command="statusChange">
<span class="el-dropdown-link">
<status-table-item :value="scope.row.status"/>
</span>
<el-dropdown-menu slot="dropdown" chang>
<el-dropdown-item :disabled="!isTestManagerOrTestUser" :command="{id: scope.row.id, status: 'Pass'}">
{{ $t('test_track.plan_view.pass') }}
</el-dropdown-item>
<el-dropdown-item :disabled="!isTestManagerOrTestUser"
:command="{id: scope.row.id, status: 'Failure'}">
{{ $t('test_track.plan_view.failure') }}
</el-dropdown-item>
<el-dropdown-item :disabled="!isTestManagerOrTestUser"
:command="{id: scope.row.id, status: 'Blocking'}">
{{ $t('test_track.plan_view.blocking') }}
</el-dropdown-item>
<el-dropdown-item :disabled="!isTestManagerOrTestUser" :command="{id: scope.row.id, status: 'Skip'}">
{{ $t('test_track.plan_view.skip') }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</span>
</template>
</el-table-column>
<el-table-column
sortable
prop="updateTime"
:label="$t('commons.update_time')"
show-overflow-tooltip>
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span> <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
min-width="100" <el-table-column :label="'执行状态'" min-width="130" align="center">
:label="$t('commons.operating')"> <template v-slot:default="scope" >
<template v-slot:default="scope"> <div v-loading="rowLoading === scope.row.id">
<ms-table-operator-button :is-tester-permission="true" :tip="$t('commons.edit')" icon="el-icon-edit" <el-link type="danger"
@exec="handleEdit(scope.row)"/> v-if="scope.row.execResult && scope.row.execResult === 'error'"
<ms-table-operator-button :is-tester-permission="true" :tip="$t('test_track.plan_view.cancel_relevance')" @click="getReportResult(scope.row)" v-text="getResult(scope.row.execResult)"/>
icon="el-icon-unlock" type="danger" @exec="handleDelete(scope.row)"/> <el-link v-else-if="scope.row.execResult && scope.row.execResult === 'success'"
@click="getReportResult(scope.row)" v-text="getResult(scope.row.execResult)">
</el-link>
<div v-else v-text="getResult(scope.row.execResult)"/>
<div v-if="scope.row.id" style="color: #999999;font-size: 12px">
<span> {{scope.row.updateTime | timestampFormatDate }}</span>
{{scope.row.updateUser}}
</div>
</div>
</template> </template>
</el-table-column> </el-table-column>
</el-table>
<ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize" <el-table-column v-if="!isReadOnly" :label="$t('commons.operating')" align="center">
<template v-slot:default="scope">
<!--<el-button type="text" @click="handleTestCase(scope.row)">{{$t('commons.edit')}}</el-button>-->
<el-button type="text" @click="singleRun(scope.row)">{{$t('api_test.run')}}</el-button>
<el-button type="text" @click="handleDelete(scope.row)" style="color: #F56C6C">{{$t('commons.delete')}}</el-button>
</template>
</el-table-column>
</el-table>
<ms-table-pagination :change="initTable" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/> :total="total"/>
<test-plan-test-case-edit <!--<api-case-list @showExecResult="showExecResult" @refresh="initTable" :currentApi="selectCase" ref="caseList"/>-->
ref="testPlanTestCaseEdit"
:search-param.sync="condition" <test-plan-api-case-result :response="response" ref="apiCaseResult"/>
@refresh="initTableData"
:is-read-only="isReadOnly" <!--批量编辑-->
@refreshTable="search"/> <!--<ms-batch-edit ref="batchEdit" @batchEdit="batchEdit" :typeArr="typeArr" :value-arr="valueArr"/>-->
<!-- 执行组件 -->
<ms-run :debug="false" :type="'API_PLAN'" :reportId="reportId" :run-data="runData"
@runRefresh="runRefresh" ref="runTest"/>
<test-report-template-list @openReport="openReport" ref="testReportTemplateList"/>
<test-case-report-view @refresh="initTableData" ref="testCaseReportView"/>
</el-card> </el-card>
<batch-edit ref="batchEdit" @batchEdit="batchEdit"
:type-arr="typeArr" :value-arr="valueArr" :dialog-title="$t('test_track.case.batch_edit_case')"/>
</div> </div>
</template> </template>
<script> <script>
import ExecutorEdit from '../ExecutorEdit';
import StatusEdit from '../StatusEdit';
import TestPlanTestCaseEdit from "../functional/FunctionalTestCaseEdit";
import MsTipButton from '../../../../../common/components/MsTipButton';
import MsTablePagination from '../../../../../common/pagination/TablePagination';
import MsTableHeader from '../../../../../common/components/MsTableHeader';
import MsTableButton from '../../../../../common/components/MsTableButton';
import NodeBreadcrumb from '../../../../common/NodeBreadcrumb';
import {ROLE_TEST_MANAGER, ROLE_TEST_USER, TokenKey, WORKSPACE_ID} from "@/common/js/constants"; import MsTableOperator from "../../../../../common/components/MsTableOperator";
import {_filter, _sort, checkoutTestManagerOrTestUser, hasRoles} from "@/common/js/utils"; import MsTableOperatorButton from "../../../../../common/components/MsTableOperatorButton";
import PriorityTableItem from "../../../../common/tableItems/planview/PriorityTableItem"; import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent";
import StatusTableItem from "../../../../common/tableItems/planview/StatusTableItem"; import MsTablePagination from "../../../../../common/pagination/TablePagination";
import TypeTableItem from "../../../../common/tableItems/planview/TypeTableItem"; import MsTag from "../../../../../common/components/MsTag";
import MethodTableItem from "../../../../common/tableItems/planview/MethodTableItem"; import MsApiCaseList from "../../../../../api/definition/components/case/ApiCaseList";
import MsTableOperator from "../../../../../common/components/MsTableOperator"; import MsContainer from "../../../../../common/components/MsContainer";
import MsTableOperatorButton from "../../../../../common/components/MsTableOperatorButton"; import MsBottomContainer from "../../../../../api/definition/components/BottomContainer";
import TestReportTemplateList from "../TestReportTemplateList"; import ShowMoreBtn from "../../../../case/components/ShowMoreBtn";
import TestCaseReportView from "../report/TestCaseReportView"; import MsBatchEdit from "../../../../../api/definition/components/basis/BatchEdit";
import {TEST_CASE_CONFIGS} from "../../../../../common/components/search/search-components"; import {API_METHOD_COLOUR, CASE_PRIORITY, RESULT_MAP} from "../../../../../api/definition/model/JsonData";
import ShowMoreBtn from "../../../../case/components/ShowMoreBtn"; import {getCurrentProjectID} from "@/common/js/utils";
import BatchEdit from "../../../../case/components/BatchEdit"; import ApiListContainer from "../../../../../api/definition/components/list/ApiListContainer";
import ClassicEditor from "@ckeditor/ckeditor5-build-classic"; import PriorityTableItem from "../../../../common/tableItems/planview/PriorityTableItem";
import {hub} from "@/business/components/track/plan/event-bus"; import ApiCaseList from "../../../../../api/definition/components/case/ApiCaseList";
import {_filter, _sort, getUUID} from "../../../../../../../common/js/utils";
import TestPlanCaseListHeader from "./TestPlanCaseListHeader";
import MsRun from "../../../../../api/definition/components/Run";
import TestPlanApiCaseResult from "./TestPlanApiCaseResult";
export default {
export default {
name: "TestPlanApiCaseList", name: "TestPlanApiCaseList",
components: { components: {
TestCaseReportView, TestPlanApiCaseResult,
TestReportTemplateList, MsRun,
TestPlanCaseListHeader,
ApiCaseList,
PriorityTableItem,
ApiListContainer,
MsTableOperatorButton, MsTableOperatorButton,
MsTableOperator, MsTableOperator,
MethodTableItem, MsTablePagination,
TypeTableItem, MsTag,
StatusTableItem, MsApiCaseList,
PriorityTableItem, StatusEdit, ExecutorEdit, MsTipButton, MsTablePagination, MsContainer,
TestPlanTestCaseEdit, MsTableHeader, NodeBreadcrumb, MsTableButton, ShowMoreBtn, MsBottomContainer,
BatchEdit ShowMoreBtn,
MsBatchEdit
}, },
data() { data() {
return { return {
condition: {},
selectCase: {},
result: {}, result: {},
moduleId: "",
deletePath: "/test/case/delete", deletePath: "/test/case/delete",
condition: {
components: TEST_CASE_CONFIGS
},
showMyTestCase: false,
tableData: [],
currentPage: 1,
pageSize: 10,
total: 0,
selectRows: new Set(), selectRows: new Set(),
testPlan: {}, buttons: [
isReadOnly: false, {name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch},
isTestManagerOrTestUser: false, // {name: this.$t('api_test.definition.request.batch_edit'), handleClick: this.handleEditBatch}
],
typeArr: [
{id: 'priority', name: this.$t('test_track.case.priority')},
],
priorityFilters: [ priorityFilters: [
{text: 'P0', value: 'P0'}, {text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'}, {text: 'P1', value: 'P1'},
{text: 'P2', value: 'P2'}, {text: 'P2', value: 'P2'},
{text: 'P3', value: 'P3'} {text: 'P3', value: 'P3'}
], ],
methodFilters: [
{text: this.$t('test_track.case.manual'), value: 'manual'},
{text: this.$t('test_track.case.auto'), value: 'auto'}
],
typeFilters: [
{text: this.$t('commons.functional'), value: 'functional'},
{text: this.$t('commons.performance'), value: 'performance'},
{text: this.$t('commons.api'), value: 'api'}
],
statusFilters: [
{text: this.$t('test_track.plan.plan_status_prepare'), value: 'Prepare'},
{text: this.$t('test_track.plan_view.pass'), value: 'Pass'},
{text: this.$t('test_track.plan_view.failure'), value: 'Failure'},
{text: this.$t('test_track.plan_view.blocking'), value: 'Blocking'},
{text: this.$t('test_track.plan_view.skip'), value: 'Skip'},
{text: this.$t('test_track.plan.plan_status_running'), value: 'Underway'},
],
executorFilters: [],
showMore: false,
buttons: [
{
name: this.$t('test_track.case.batch_edit_case'), handleClick: this.handleBatchEdit
},
{
name: this.$t('test_track.case.batch_unlink'), handleClick: this.handleDeleteBatch
}
],
typeArr: [
{id: 'status', name: this.$t('test_track.plan_view.execute_result')},
{id: 'executor', name: this.$t('test_track.plan_view.executor')},
],
valueArr: { valueArr: {
executor: [], priority: CASE_PRIORITY,
status: [
{name: this.$t('test_track.plan_view.pass'), id: 'Pass'},
{name: this.$t('test_track.plan_view.failure'), id: 'Failure'},
{name: this.$t('test_track.plan_view.blocking'), id: 'Blocking'},
{name: this.$t('test_track.plan_view.skip'), id: 'Skip'}
]
},
editor: ClassicEditor,
editorConfig: {
// 'increaseIndent','decreaseIndent'
toolbar: [],
}, },
methodColorMap: new Map(API_METHOD_COLOUR),
tableData: [],
currentPage: 1,
pageSize: 10,
total: 0,
screenHeight: document.documentElement.clientHeight - 330,//
// environmentId: undefined,
currentCaseProjectId: "",
runData: [],
reportId: "",
response: {},
rowLoading: ""
} }
}, },
props: { props: {
planId: { currentProtocol: String,
type: String selectNodeIds: Array,
visible: {
type: Boolean,
default: false,
}, },
selectNodeIds: { isApiListEnable: {
type: Array type: Boolean,
default: false,
}, },
selectParentNodes: { isReadOnly: {
type: Array type: Boolean,
default: false
},
isCaseRelevance: {
type: Boolean,
default: false,
},
model: {
type: String,
default() {
'api'
} }
}, },
planId: String
},
created: function () {
this.initTable();
},
watch: { watch: {
planId() {
this.refreshTableAndPlan();
},
selectNodeIds() { selectNodeIds() {
this.search(); this.initTable();
}
}, },
mounted() { currentProtocol() {
hub.$on("openFailureTestCase", row => { this.initTable();
this.isReadOnly = true; },
this.condition.status = 'Failure'; },
this.$refs.testPlanTestCaseEdit.openTestCaseEdit(row); computed: {
}); //
this.refreshTableAndPlan(); isRelevanceModel() {
this.isTestManagerOrTestUser = checkoutTestManagerOrTestUser(); return this.model === 'relevance'
this.getMaintainerOptions(); },
//
isPlanModel() {
return this.model === 'plan'
},
//
isApiModel() {
return this.model === 'api'
}, },
beforeDestroy() {
hub.$off("openFailureTestCase");
}, },
methods: { methods: {
initTableData() { isApiListEnableChange(data) {
if (this.planId) { this.$emit('isApiListEnableChange', data);
// param.planId = this.planId; },
initTable() {
this.selectRows = new Set();
// this.condition.filters = ["Prepare", "Underway", "Completed"];
this.condition.status = "";
this.condition.moduleIds = this.selectNodeIds;
this.condition.planId = this.planId; this.condition.planId = this.planId;
if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol;
} }
if (this.selectNodeIds && this.selectNodeIds.length > 0) { this.result = this.$post('/test/plan/api/case/list/' + this.currentPage + "/" + this.pageSize, this.condition, response => {
// param.nodeIds = this.selectNodeIds; this.total = response.data.itemCount;
this.condition.nodeIds = this.selectNodeIds; this.tableData = response.data.listObject;
}
if (this.planId) {
this.result = this.$post(this.buildPagePath('/test/plan/case/list'), this.condition, response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;
for (let i = 0; i < this.tableData.length; i++) {
if (this.tableData[i]) {
this.$set(this.tableData[i], "issuesSize", 0);
this.$get("/issues/get/" + this.tableData[i].caseId, response => {
let issues = response.data;
if (this.tableData[i]) {
this.$set(this.tableData[i], "issuesSize", issues.length);
this.$set(this.tableData[i], "issuesContent", issues);
}
})
}
}
this.selectRows.clear();
});
}
},
showDetail(row, event, column) {
this.isReadOnly = true;
this.$refs.testPlanTestCaseEdit.openTestCaseEdit(row);
},
refresh() {
this.condition = {components: TEST_CASE_CONFIGS};
this.selectRows.clear();
this.$emit('refresh');
},
breadcrumbRefresh() {
this.showMyTestCase = false;
this.refresh();
},
refreshTableAndPlan() {
this.getTestPlanById();
this.initTableData();
},
refreshTestPlanRecent() {
if (hasRoles(ROLE_TEST_USER, ROLE_TEST_MANAGER)) {
let param = {};
param.id = this.planId;
param.updateTime = Date.now();
this.$post('/test/plan/edit', param);
}
},
search() {
this.initTableData();
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
handleEdit(testCase, index) {
this.isReadOnly = false;
if (!checkoutTestManagerOrTestUser()) {
this.isReadOnly = true;
}
this.$refs.testPlanTestCaseEdit.openTestCaseEdit(testCase);
},
handleDelete(testCase) {
this.$alert(this.$t('test_track.plan_view.confirm_cancel_relevance') + ' ' + testCase.name + " ", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
this._handleDelete(testCase);
}
}
}); });
}, },
handleDeleteBatch() { handleSelect(selection, row) {
if (this.tableData.length < 1) { row.hashTree = [];
this.$warning(this.$t('test_track.plan_view.no_case_relevance'));
return;
}
this.$alert(this.$t('test_track.plan_view.confirm_cancel_relevance') + " ", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
if (this.selectRows.size > 0) {
let ids = Array.from(this.selectRows).map(row => row.id);
this._handleBatchDelete(ids);
} else {
if (this.planId) {
this.condition.planId = this.planId;
}
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
this.condition.nodeIds = this.selectNodeIds;
}
//
this.$post('/test/plan/case/list/all', this.condition, res => {
let data = res.data;
let ids = data.map(d => d.id);
this._handleBatchDelete(ids);
})
}
}
}
});
},
_handleBatchDelete(ids) {
this.result = this.$post('/test/plan/case/batch/delete', {ids: ids}, () => {
this.selectRows.clear();
this.$emit("refresh");
this.$success(this.$t('test_track.cancel_relevance_success'));
});
},
_handleDelete(testCase) {
let testCaseId = testCase.id;
this.result = this.$post('/test/plan/case/delete/' + testCaseId, {}, () => {
this.$emit("refresh");
this.$success(this.$t('test_track.cancel_relevance_success'));
});
},
handleSelectAll(selection) {
if (selection.length > 0) {
this.tableData.forEach(item => {
this.$set(item, "showMore", true);
this.selectRows.add(item);
});
} else {
this.selectRows.clear();
this.tableData.forEach(row => {
this.$set(row, "showMore", false);
})
}
},
handleSelectionChange(selection, row) {
if (this.selectRows.has(row)) { if (this.selectRows.has(row)) {
this.$set(row, "showMore", false); this.$set(row, "showMore", false);
this.selectRows.delete(row); this.selectRows.delete(row);
@ -497,64 +268,22 @@ export default {
this.$set(row, "showMore", true); this.$set(row, "showMore", true);
this.selectRows.add(row); this.selectRows.add(row);
} }
}, let arr = Array.from(this.selectRows);
handleBatch(type) { // 1
if (this.selectRows.size < 1) { if (this.selectRows.size === 1) {
this.$warning(this.$t('test_track.plan_view.select_manipulate')); this.$set(arr[0], "showMore", false);
return; } else if (this.selectRows.size === 2) {
} arr.forEach(row => {
if (type === 'executor') { this.$set(row, "showMore", true);
this.$refs.executorEdit.openExecutorEdit(); })
} else if (type === 'status') {
this.$refs.statusEdit.openStatusEdit();
} else if (type === 'delete') {
this.handleDeleteBatch();
} }
}, },
searchMyTestCase() { showExecResult(row) {
this.showMyTestCase = !this.showMyTestCase; this.$emit('showExecResult', row);
if (this.showMyTestCase) {
let user = JSON.parse(localStorage.getItem(TokenKey));
this.condition.executor = user.id;
} else {
this.condition.executor = null;
}
this.initTableData();
},
openTestReport() {
this.$refs.testReportTemplateList.open(this.planId);
},
statusChange(param) {
this.$post('/test/plan/case/edit', param, () => {
for (let i = 0; i < this.tableData.length; i++) {
if (this.tableData[i].id == param.id) {
this.tableData[i].status = param.status;
break;
}
}
});
},
getTestPlanById() {
if (this.planId) {
this.$post('/test/plan/get/' + this.planId, {}, response => {
this.testPlan = response.data;
this.refreshTestPlanRecent();
});
}
},
openReport(planId, id) {
this.getTestPlanById();
if (!id) {
id = this.testPlan.reportId;
}
if (!planId) {
planId = this.planId;
}
this.$refs.testCaseReportView.open(planId, id);
}, },
filter(filters) { filter(filters) {
_filter(filters, this.condition); _filter(filters, this.condition);
this.initTableData(); this.initTable();
}, },
sort(column) { sort(column) {
// //
@ -562,46 +291,195 @@ export default {
this.condition.orders = []; this.condition.orders = [];
} }
_sort(column, this.condition); _sort(column, this.condition);
this.initTableData(); this.initTable();
}, },
batchEdit(form) { handleSelectAll(selection) {
let param = {}; if (selection.length > 0) {
param[form.type] = form.value; if (selection.length === 1) {
param.ids = Array.from(this.selectRows).map(row => row.id); selection.hashTree = [];
this.$post('/test/plan/case/batch/edit', param, () => { this.selectRows.add(selection[0]);
} else {
this.tableData.forEach(item => {
item.hashTree = [];
this.$set(item, "showMore", true);
this.selectRows.add(item);
});
}
} else {
this.selectRows.clear(); this.selectRows.clear();
this.status = ''; this.tableData.forEach(row => {
this.$post('/test/plan/edit/status/' + this.planId); this.$set(row, "showMore", false);
})
}
},
search() {
this.initTable();
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
handleTestCase(testCase) {
this.$get('/api/definition/get/' + testCase.apiDefinitionId, (response) => {
let api = response.data;
let selectApi = api;
let request = {};
if (Object.prototype.toString.call(api.request).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
request = api.request;
} else {
request = JSON.parse(api.request);
}
if (!request.hashTree) {
request.hashTree = [];
}
selectApi.url = request.path;
this.currentCaseProjectId = testCase.projectId;
this.$refs.caseList.open(selectApi, testCase.id);
});
},
reductionApi(row) {
let ids = [row.id];
this.$post('/api/testcase/reduction/', ids, () => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.$emit('refresh'); this.search();
}); });
}, },
handleBatchEdit() { handleDeleteBatch() {
this.getMaintainerOptions(); this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', {
this.$refs.batchEdit.open(); confirmButtonText: this.$t('commons.confirm'),
}, callback: (action) => {
getMaintainerOptions() { if (action === 'confirm') {
let workspaceId = localStorage.getItem(WORKSPACE_ID); let param = {};
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => { param.ids = Array.from(this.selectRows).map(row => row.id);
this.valueArr.executor = response.data; param.planId = this.planId;
this.executorFilters = response.data.map(u => { this.$post('/test/plan/api/case/batch/delete', param, () => {
return {text: u.name, value: u.id} this.selectRows.clear();
}); this.initTable();
this.$success(this.$t('commons.delete_success'));
}); });
} }
} }
} });
},
getResult(data) {
if (RESULT_MAP.get(data)) {
return RESULT_MAP.get(data);
} else {
return RESULT_MAP.get("default");
}
},
runRefresh(data) {
this.rowLoading = "";
this.$success(this.$t('schedule.event_success'));
this.initTable();
},
singleRun(row) {
if (!row.environmentId) {
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
this.runData = [];
this.rowLoading = row.id;
this.$get('/api/testcase/get/' + row.caseId, (response) => {
let apiCase = response.data;
let request = JSON.parse(apiCase.request);
request.name = row.id;
request.id = row.id;
request.useEnvironment = row.environmentId;
this.runData.push(request);
/*触发执行操作*/
this.reportId = getUUID().substring(0, 8);
});
},
// batchRun() {
// if (!this.environment) {
// this.$warning(this.$t('api_test.environment.select_environment'));
// return;
// }
// if (this.apiCaseList.length > 0) {
// this.apiCaseList.forEach(item => {
// if (item.id) {
// item.request.name = item.id;
// item.request.useEnvironment = this.environment.id;
// this.runData.push(item.request);
// }
// })
// if (this.runData.length > 0) {
// // this.batchLoading = true;
// /**/
// this.reportId = getUUID().substring(0, 8);
// } else {
// this.$warning("");
// }
// } else {
// this.$warning("");
// }
// },
// handleEditBatch() {
// this.$refs.batchEdit.open();
// },
// batchEdit(form) {
// let arr = Array.from(this.selectRows);
// let ids = arr.map(row => row.id);
// let param = {};
// param[form.type] = form.value;
// param.ids = ids;
// this.$post('/api/testcase/batch/edit', param, () => {
// this.$success(this.$t('commons.save_success'));
// this.initTable();
// });
// },
handleDelete(apiCase) {
this.$get('/test/plan/api/case/delete/' + this.planId + '/' + apiCase.id, () => {
this.$success(this.$t('commons.delete_success'));
this.initTable();
});
return;
},
getProjectId() {
if (!this.isRelevanceModel) {
return getCurrentProjectID();
} else {
return this.currentCaseProjectId;
}
},
setEnvironment(data) {
// this.environmentId = data.id;
},
getReportResult(apiCase) {
let url = "/api/definition/report/getReport/" + apiCase.id + '/' + 'API_PLAN';
this.$get(url, response => {
if (response.data) {
this.response = JSON.parse(response.data.content);
this.$refs.apiCaseResult.open();
}
});
},
},
}
</script> </script>
<style scoped> <style scoped>
.operate-button > div {
.search { display: inline-block;
margin-left: 10px; margin-left: 10px;
width: 240px; }
}
.test-case-status, .el-table { .request-method {
cursor: pointer; padding: 0 5px;
} color: #1E90FF;
}
.api-el-tag {
color: white;
}
.search-input {
float: right;
width: 300px;
/*margin-bottom: 20px;*/
margin-right: 20px;
}
</style> </style>

View File

@ -0,0 +1,32 @@
<template>
<el-dialog :close-on-click-modal="false" :title="'测试结果'" width="30%"
:visible.sync="visible" class="api-import" @close="close">
<ms-request-result-tail :response="response" ref="debugResult"/>
</el-dialog>
</template>
<script>
import MsRequestResultTail from "../../../../../api/definition/components/response/RequestResultTail";
export default {
name: "TestPlanApiCaseResult",
components: {MsRequestResultTail},
props: ['response'],
data() {
return {
visible: false
}
},
methods: {
close() {
this.visible = false;
},
open() {
this.visible = true;
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,48 @@
<template>
<ms-table-header :is-tester-permission="true"
:condition="condition"
@search="$emit('refresh')"
:show-create="false"
:tip="$t('commons.search_by_name_or_id')">
<template v-slot:title>
接口用例
</template>
<template v-slot:button>
<ms-table-button :is-tester-permission="true" icon="el-icon-connection"
:content="$t('test_track.plan_view.relevance_test_case')"
@click="$emit('relevanceCase')"/>
</template>
</ms-table-header>
</template>
<script>
import MsTableHeader from "../../../../../common/components/MsTableHeader";
import MsTableButton from "../../../../../common/components/MsTableButton";
import MsEnvironmentSelect from "../../../../../api/definition/components/case/MsEnvironmentSelect";
export default {
name: "TestPlanCaseListHeader",
components: {MsEnvironmentSelect, MsTableButton, MsTableHeader},
props: ['condition', 'projectId', 'isReadOnly', 'planId'],
methods: {
setEnvironment(data) {
if (this.planId) {
let param = {};
param.id = this.planId;
param.environmentId = data.id;
this.$post('/test/plan/edit', param, () => {
this.$emit('setEnvironment', data);
});
}
}
}
}
</script>
<style scoped>
/deep/ .environment-select {
margin-right: 10px;
}
</style>

View File

@ -885,6 +885,9 @@ export default {
create_user: "Creator", create_user: "Creator",
update_time: "Update time", update_time: "Update time",
}, },
confirm:{
close_title: "Do you want to close this scheduled task",
}
} }
} }
}, },

View File

@ -886,6 +886,9 @@ export default {
create_user: "创建人", create_user: "创建人",
update_time: "更新时间", update_time: "更新时间",
}, },
confirm:{
close_title: "要关闭这条定时任务吗?",
}
} }
} }
}, },

View File

@ -885,6 +885,9 @@ export default {
create_user: "創建人", create_user: "創建人",
update_time: "更新時間", update_time: "更新時間",
}, },
confirm:{
close_title: "要關閉這條定時任務嗎?",
}
} }
} }
}, },