This commit is contained in:
chenjianxing 2020-12-24 13:00:38 +08:00
commit 2415f16200
23 changed files with 366 additions and 339 deletions

View File

@ -44,9 +44,9 @@ public class APIScenarioReportController {
@PostMapping("/add") @PostMapping("/add")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public String add(@RequestBody APIScenarioReportResult node) { public void add(@RequestBody APIScenarioReportResult node) {
node.setExecuteType(ExecuteType.Saved.name()); node.setExecuteType(ExecuteType.Saved.name());
return apiReportService.save(node, ApiRunMode.SCENARIO.name()); apiReportService.save(node, ApiRunMode.SCENARIO.name());
} }
@PostMapping("/update") @PostMapping("/update")

View File

@ -20,7 +20,7 @@ public class TestResult {
private int passAssertions = 0; private int passAssertions = 0;
private final List<ScenarioResult> scenarios = new ArrayList<>(); private List<ScenarioResult> scenarios = new ArrayList<>();
public void addError(int count) { public void addError(int count) {
this.error += count; this.error += count;

View File

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import io.metersphere.api.dto.DeleteAPIReportRequest;
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;
@ -14,6 +15,7 @@ import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
import io.metersphere.api.jmeter.JMeterService; import io.metersphere.api.jmeter.JMeterService;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ApiScenarioMapper; import io.metersphere.base.mapper.ApiScenarioMapper;
import io.metersphere.base.mapper.ApiScenarioReportMapper;
import io.metersphere.base.mapper.TestPlanApiScenarioMapper; import io.metersphere.base.mapper.TestPlanApiScenarioMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper; import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper;
@ -37,13 +39,13 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.jorphan.collections.HashTree; import org.apache.jorphan.collections.HashTree;
import org.apache.jorphan.collections.ListedHashTree; import org.apache.jorphan.collections.ListedHashTree;
import org.python.antlr.ast.Str;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -68,6 +70,8 @@ public class ApiAutomationService {
private ExtTestPlanMapper extTestPlanMapper; private ExtTestPlanMapper extTestPlanMapper;
@Resource @Resource
SqlSessionFactory sqlSessionFactory; SqlSessionFactory sqlSessionFactory;
@Resource
private ApiScenarioReportMapper apiScenarioReportMapper;
public List<ApiScenarioDTO> list(ApiScenarioRequest request) { public List<ApiScenarioDTO> list(ApiScenarioRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
@ -157,6 +161,10 @@ public class ApiAutomationService {
} }
public void preDelete(String scenarioID) { public void preDelete(String scenarioID) {
ApiScenarioReportExample scenarioReportExample = new ApiScenarioReportExample();
scenarioReportExample.createCriteria().andScenarioIdEqualTo(scenarioID);
List<ApiScenarioReport> list = apiScenarioReportMapper.selectByExample(scenarioReportExample);
deleteApiScenarioReport(list);
scheduleService.deleteByResourceId(scenarioID); scheduleService.deleteByResourceId(scenarioID);
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample(); TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
@ -177,9 +185,21 @@ public class ApiAutomationService {
} }
public void preDelete(List<String> scenarioIDList) { private void deleteApiScenarioReport(List<ApiScenarioReport> list) {
if (CollectionUtils.isNotEmpty(list)) {
List<String> ids = list.stream().map(ApiScenarioReport::getId).collect(Collectors.toList());
DeleteAPIReportRequest reportRequest = new DeleteAPIReportRequest();
reportRequest.setIds(ids);
apiReportService.deleteAPIReportBatch(reportRequest);
}
}
public void preDeleteBatch(List<String> scenarioIDList) {
ApiScenarioReportExample scenarioReportExample = new ApiScenarioReportExample();
scenarioReportExample.createCriteria().andScenarioIdIn(scenarioIDList);
List<ApiScenarioReport> list = apiScenarioReportMapper.selectByExample(scenarioReportExample);
deleteApiScenarioReport(list);
List<String> testPlanApiScenarioIdList = new ArrayList<>(); List<String> testPlanApiScenarioIdList = new ArrayList<>();
List<String> scheduleIdList = new ArrayList<>();
for (String id : scenarioIDList) { for (String id : scenarioIDList) {
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample(); TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
example.createCriteria().andApiScenarioIdEqualTo(id); example.createCriteria().andApiScenarioIdEqualTo(id);
@ -201,9 +221,8 @@ public class ApiAutomationService {
} }
public void deleteBatch(List<String> ids) { public void deleteBatch(List<String> ids) {
//及连删除外键表 // 删除外键表
preDelete(ids); preDeleteBatch(ids);
;
ApiScenarioExample example = new ApiScenarioExample(); ApiScenarioExample example = new ApiScenarioExample();
example.createCriteria().andIdIn(ids); example.createCriteria().andIdIn(ids);
apiScenarioMapper.deleteByExample(example); apiScenarioMapper.deleteByExample(example);
@ -388,40 +407,7 @@ public class ApiAutomationService {
apiCaseBatchMapper.insertIfNotExists(testPlanApiCase); apiCaseBatchMapper.insertIfNotExists(testPlanApiCase);
} }
} }
} }
// testPlan的ID先不存储
// list.forEach(item -> {
// if (CollectionUtils.isNotEmpty(request.getApiIds())) {
// if (CollectionUtils.isNotEmpty(request.getApiIds())) {
// if (StringUtils.isEmpty(item.getApiIds())) {
// item.setApiIds(JSON.toJSONString(request.getApiIds()));
// } else {
// // 合并api
// List<String> dbApiIDs = JSON.parseArray(item.getApiIds(), String.class);
// List<String> result = Stream.of(request.getApiIds(), dbApiIDs)
// .flatMap(Collection::stream).distinct().collect(Collectors.toList());
// item.setApiIds(JSON.toJSONString(result));
// }
// item.setScenarioIds(null);
// }
// }
// if (CollectionUtils.isNotEmpty(request.getScenarioIds())) {
// if (CollectionUtils.isNotEmpty(request.getScenarioIds())) {
// if (StringUtils.isEmpty(item.getScenarioIds())) {
// item.setScenarioIds(JSON.toJSONString(request.getScenarioIds()));
// } else {
// // 合并场景ID
// List<String> dbScenarioIDs = JSON.parseArray(item.getScenarioIds(), String.class);
// List<String> result = Stream.of(request.getScenarioIds(), dbScenarioIDs)
// .flatMap(Collection::stream).distinct().collect(Collectors.toList());
// item.setScenarioIds(JSON.toJSONString(result));
// }
// item.setApiIds(null);
// }
// }
// mapper.updatePlan(item);
// });
sqlSession.flushStatements(); sqlSession.flushStatements();
return "success"; return "success";
} }
@ -432,10 +418,8 @@ public class ApiAutomationService {
public long countScenarioByProjectIDAndCreatInThisWeek(String projectId) { public long countScenarioByProjectIDAndCreatInThisWeek(String projectId) {
Map<String, Date> startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date()); Map<String, Date> startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date());
Date firstTime = startAndEndDateInWeek.get("firstTime"); Date firstTime = startAndEndDateInWeek.get("firstTime");
Date lastTime = startAndEndDateInWeek.get("lastTime"); Date lastTime = startAndEndDateInWeek.get("lastTime");
if (firstTime == null || lastTime == null) { if (firstTime == null || lastTime == null) {
return 0; return 0;
} else { } else {

View File

@ -91,6 +91,7 @@ public class ApiScenarioReportService {
} }
report.setContent(new String(detail.getContent(), StandardCharsets.UTF_8)); report.setContent(new String(detail.getContent(), StandardCharsets.UTF_8));
this.save(report, runMode); this.save(report, runMode);
// 此方法适用于前端发起
if (!report.getTriggerMode().equals(ReportTriggerMode.SCHEDULE.name())) { if (!report.getTriggerMode().equals(ReportTriggerMode.SCHEDULE.name())) {
cache.put(report.getId(), report); cache.put(report.getId(), report);
} }
@ -141,19 +142,21 @@ public class ApiScenarioReportService {
} }
} }
public ApiScenarioReport createReport(APIScenarioReportResult test) { public ApiScenarioReport createReport(APIScenarioReportResult test, String scenarioName, String scenarioId, String result) {
checkNameExist(test); checkNameExist(test);
ApiScenarioReport report = new ApiScenarioReport(); ApiScenarioReport report = new ApiScenarioReport();
report.setId(UUID.randomUUID().toString()); report.setId(UUID.randomUUID().toString());
report.setProjectId(test.getProjectId()); report.setProjectId(test.getProjectId());
report.setName(test.getName()); report.setName(scenarioName + "-" + DateUtils.getTimeStr(System.currentTimeMillis()));
report.setTriggerMode(test.getTriggerMode()); report.setTriggerMode(test.getTriggerMode());
report.setDescription(test.getDescription()); report.setDescription(test.getDescription());
report.setCreateTime(System.currentTimeMillis()); report.setCreateTime(System.currentTimeMillis());
report.setUpdateTime(System.currentTimeMillis()); report.setUpdateTime(System.currentTimeMillis());
report.setStatus(test.getStatus()); report.setStatus(result);
report.setUserId(test.getUserId()); report.setUserId(test.getUserId());
report.setExecuteType(test.getExecuteType()); report.setExecuteType(test.getExecuteType());
report.setScenarioId(scenarioId);
report.setScenarioName(scenarioName);
apiScenarioReportMapper.insert(report); apiScenarioReportMapper.insert(report);
return report; return report;
} }
@ -171,33 +174,37 @@ public class ApiScenarioReportService {
report.setStatus(test.getStatus()); report.setStatus(test.getStatus());
report.setUserId(test.getUserId()); report.setUserId(test.getUserId());
report.setExecuteType(test.getExecuteType()); report.setExecuteType(test.getExecuteType());
report.setScenarioId(test.getScenarioId());
report.setScenarioName(test.getScenarioName());
apiScenarioReportMapper.updateByPrimaryKey(report); apiScenarioReportMapper.updateByPrimaryKey(report);
return report; return report;
} }
private TestResult createTestResult(TestResult result) {
TestResult newrResult = new TestResult();
newrResult.setTestId(result.getTestId());
newrResult.setTotal(result.getTotal());
newrResult.setError(result.getError());
newrResult.setPassAssertions(result.getPassAssertions());
newrResult.setSuccess(result.getSuccess());
newrResult.setTotalAssertions(result.getTotalAssertions());
return newrResult;
}
public String save(APIScenarioReportResult test, String runModel) { public void save(APIScenarioReportResult test, String runModel) {
ApiScenarioReport report = createReport(test);
ApiScenarioReportDetail detail = new ApiScenarioReportDetail();
TestResult result = JSON.parseObject(test.getContent(), TestResult.class); TestResult result = JSON.parseObject(test.getContent(), TestResult.class);
// 更新场景 // 更新场景
if (result != null) { if (result != null) {
if (StringUtils.equals(runModel, ApiRunMode.SCENARIO_PLAN.name())) { if (StringUtils.equals(runModel, ApiRunMode.SCENARIO_PLAN.name())) {
updatePlanCase(result, test, report); updatePlanCase(result, test);
} else { } else {
updateScenario(result.getScenarios(), test.getProjectId(), report.getId()); updateScenario(test, result);
} }
} }
detail.setContent(test.getContent().getBytes(StandardCharsets.UTF_8));
detail.setReportId(report.getId());
detail.setProjectId(test.getProjectId());
apiScenarioReportDetailMapper.insert(detail);
return report.getId();
} }
public void updatePlanCase(TestResult result, APIScenarioReportResult test, ApiScenarioReport report) { public void updatePlanCase(TestResult result, APIScenarioReportResult test) {
TestPlanApiScenario testPlanApiScenario = new TestPlanApiScenario(); TestPlanApiScenario testPlanApiScenario = testPlanApiScenarioMapper.selectByPrimaryKey(test.getId());
testPlanApiScenario.setId(test.getId());
ScenarioResult scenarioResult = result.getScenarios().get(0); ScenarioResult scenarioResult = result.getScenarios().get(0);
if (scenarioResult.getError() > 0) { if (scenarioResult.getError() > 0) {
testPlanApiScenario.setLastResult("Fail"); testPlanApiScenario.setLastResult("Fail");
@ -206,14 +213,27 @@ public class ApiScenarioReportService {
} }
String passRate = new DecimalFormat("0%").format((float) scenarioResult.getSuccess() / (scenarioResult.getSuccess() + scenarioResult.getError())); String passRate = new DecimalFormat("0%").format((float) scenarioResult.getSuccess() / (scenarioResult.getSuccess() + scenarioResult.getError()));
testPlanApiScenario.setPassRate(passRate); testPlanApiScenario.setPassRate(passRate);
// 存储场景报告
ApiScenarioReport report = createReport(test, scenarioResult.getName(), testPlanApiScenario.getApiScenarioId(), scenarioResult.getError() == 0 ? "Success" : "Error");
// 报告详情内容
ApiScenarioReportDetail detail = new ApiScenarioReportDetail();
TestResult newResult = createTestResult(result);
List<ScenarioResult> scenarioResults = new ArrayList();
scenarioResults.add(scenarioResult);
newResult.setScenarios(scenarioResults);
detail.setContent(JSON.toJSONString(newResult).getBytes(StandardCharsets.UTF_8));
detail.setReportId(report.getId());
detail.setProjectId(test.getProjectId());
apiScenarioReportDetailMapper.insert(detail);
testPlanApiScenario.setReportId(report.getId()); testPlanApiScenario.setReportId(report.getId());
testPlanApiScenarioMapper.updateByPrimaryKeySelective(testPlanApiScenario); testPlanApiScenarioMapper.updateByPrimaryKeySelective(testPlanApiScenario);
} }
public void updateScenario(List<ScenarioResult> Scenarios, String projectId, String reportId) { public void updateScenario(APIScenarioReportResult test, TestResult result) {
Scenarios.forEach(item -> { result.getScenarios().forEach(item -> {
ApiScenarioExample example = new ApiScenarioExample(); ApiScenarioExample example = new ApiScenarioExample();
example.createCriteria().andNameEqualTo(item.getName()).andProjectIdEqualTo(projectId); example.createCriteria().andNameEqualTo(item.getName()).andProjectIdEqualTo(test.getProjectId());
List<ApiScenario> list = apiScenarioMapper.selectByExample(example); List<ApiScenario> list = apiScenarioMapper.selectByExample(example);
if (list.size() > 0) { if (list.size() > 0) {
ApiScenario scenario = list.get(0); ApiScenario scenario = list.get(0);
@ -224,7 +244,21 @@ public class ApiScenarioReportService {
} }
String passRate = new DecimalFormat("0%").format((float) item.getSuccess() / (item.getSuccess() + item.getError())); String passRate = new DecimalFormat("0%").format((float) item.getSuccess() / (item.getSuccess() + item.getError()));
scenario.setPassRate(passRate); scenario.setPassRate(passRate);
scenario.setReportId(reportId);
// 存储场景报告
ApiScenarioReport report = createReport(test, scenario.getName(), scenario.getId(), scenario.getLastResult());
// 报告详情内容
ApiScenarioReportDetail detail = new ApiScenarioReportDetail();
TestResult newResult = createTestResult(result);
List<ScenarioResult> scenarioResults = new ArrayList();
scenarioResults.add(item);
newResult.setScenarios(scenarioResults);
detail.setContent(JSON.toJSONString(newResult).getBytes(StandardCharsets.UTF_8));
detail.setReportId(report.getId());
detail.setProjectId(scenario.getProjectId());
apiScenarioReportDetailMapper.insert(detail);
// 更新场景状态
scenario.setReportId(report.getId());
apiScenarioMapper.updateByPrimaryKey(scenario); apiScenarioMapper.updateByPrimaryKey(scenario);
} }
}); });

View File

@ -105,7 +105,6 @@ public class ApiTestCaseService {
public void update(SaveApiTestCaseRequest request, List<MultipartFile> bodyFiles) { public void update(SaveApiTestCaseRequest request, List<MultipartFile> bodyFiles) {
deleteFileByTestId(request.getId()); deleteFileByTestId(request.getId());
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
request.setBodyUploadIds(null); request.setBodyUploadIds(null);
ApiTestCase test = updateTest(request); ApiTestCase test = updateTest(request);
@ -134,12 +133,9 @@ public class ApiTestCaseService {
} }
public void delete(String testId) { public void delete(String testId) {
extTestPlanTestCaseMapper.deleteByTestCaseID(testId); extTestPlanTestCaseMapper.deleteByTestCaseID(testId);
deleteFileByTestId(testId); deleteFileByTestId(testId);
extApiDefinitionExecResultMapper.deleteByResourceId(testId); extApiDefinitionExecResultMapper.deleteByResourceId(testId);
apiTestCaseMapper.deleteByPrimaryKey(testId); apiTestCaseMapper.deleteByPrimaryKey(testId);
deleteBodyFiles(testId); deleteBodyFiles(testId);
} }

View File

@ -24,6 +24,10 @@ public class ApiScenarioReport implements Serializable {
private String executeType; private String executeType;
private String scenarioName;
private String scenarioId;
private String description; private String description;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -713,6 +713,146 @@ public class ApiScenarioReportExample {
addCriterion("execute_type not between", value1, value2, "executeType"); addCriterion("execute_type not between", value1, value2, "executeType");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andScenarioNameIsNull() {
addCriterion("scenario_name is null");
return (Criteria) this;
}
public Criteria andScenarioNameIsNotNull() {
addCriterion("scenario_name is not null");
return (Criteria) this;
}
public Criteria andScenarioNameEqualTo(String value) {
addCriterion("scenario_name =", value, "scenarioName");
return (Criteria) this;
}
public Criteria andScenarioNameNotEqualTo(String value) {
addCriterion("scenario_name <>", value, "scenarioName");
return (Criteria) this;
}
public Criteria andScenarioNameGreaterThan(String value) {
addCriterion("scenario_name >", value, "scenarioName");
return (Criteria) this;
}
public Criteria andScenarioNameGreaterThanOrEqualTo(String value) {
addCriterion("scenario_name >=", value, "scenarioName");
return (Criteria) this;
}
public Criteria andScenarioNameLessThan(String value) {
addCriterion("scenario_name <", value, "scenarioName");
return (Criteria) this;
}
public Criteria andScenarioNameLessThanOrEqualTo(String value) {
addCriterion("scenario_name <=", value, "scenarioName");
return (Criteria) this;
}
public Criteria andScenarioNameLike(String value) {
addCriterion("scenario_name like", value, "scenarioName");
return (Criteria) this;
}
public Criteria andScenarioNameNotLike(String value) {
addCriterion("scenario_name not like", value, "scenarioName");
return (Criteria) this;
}
public Criteria andScenarioNameIn(List<String> values) {
addCriterion("scenario_name in", values, "scenarioName");
return (Criteria) this;
}
public Criteria andScenarioNameNotIn(List<String> values) {
addCriterion("scenario_name not in", values, "scenarioName");
return (Criteria) this;
}
public Criteria andScenarioNameBetween(String value1, String value2) {
addCriterion("scenario_name between", value1, value2, "scenarioName");
return (Criteria) this;
}
public Criteria andScenarioNameNotBetween(String value1, String value2) {
addCriterion("scenario_name not between", value1, value2, "scenarioName");
return (Criteria) this;
}
public Criteria andScenarioIdIsNull() {
addCriterion("scenario_id is null");
return (Criteria) this;
}
public Criteria andScenarioIdIsNotNull() {
addCriterion("scenario_id is not null");
return (Criteria) this;
}
public Criteria andScenarioIdEqualTo(String value) {
addCriterion("scenario_id =", value, "scenarioId");
return (Criteria) this;
}
public Criteria andScenarioIdNotEqualTo(String value) {
addCriterion("scenario_id <>", value, "scenarioId");
return (Criteria) this;
}
public Criteria andScenarioIdGreaterThan(String value) {
addCriterion("scenario_id >", value, "scenarioId");
return (Criteria) this;
}
public Criteria andScenarioIdGreaterThanOrEqualTo(String value) {
addCriterion("scenario_id >=", value, "scenarioId");
return (Criteria) this;
}
public Criteria andScenarioIdLessThan(String value) {
addCriterion("scenario_id <", value, "scenarioId");
return (Criteria) this;
}
public Criteria andScenarioIdLessThanOrEqualTo(String value) {
addCriterion("scenario_id <=", value, "scenarioId");
return (Criteria) this;
}
public Criteria andScenarioIdLike(String value) {
addCriterion("scenario_id like", value, "scenarioId");
return (Criteria) this;
}
public Criteria andScenarioIdNotLike(String value) {
addCriterion("scenario_id not like", value, "scenarioId");
return (Criteria) this;
}
public Criteria andScenarioIdIn(List<String> values) {
addCriterion("scenario_id in", values, "scenarioId");
return (Criteria) this;
}
public Criteria andScenarioIdNotIn(List<String> values) {
addCriterion("scenario_id not in", values, "scenarioId");
return (Criteria) this;
}
public Criteria andScenarioIdBetween(String value1, String value2) {
addCriterion("scenario_id between", value1, value2, "scenarioId");
return (Criteria) this;
}
public Criteria andScenarioIdNotBetween(String value1, String value2) {
addCriterion("scenario_id not between", value1, value2, "scenarioId");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -1,8 +1,9 @@
package io.metersphere.base.domain; package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
@Data @Data
public class TestPlan implements Serializable { public class TestPlan implements Serializable {
private String id; private String id;
@ -39,10 +40,6 @@ public class TestPlan implements Serializable {
private String creator; private String creator;
private String apiIds;
private String scenarioIds;
private String tags; private String tags;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -1233,146 +1233,6 @@ public class TestPlanExample {
addCriterion("creator not between", value1, value2, "creator"); addCriterion("creator not between", value1, value2, "creator");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andApiIdsIsNull() {
addCriterion("api_ids is null");
return (Criteria) this;
}
public Criteria andApiIdsIsNotNull() {
addCriterion("api_ids is not null");
return (Criteria) this;
}
public Criteria andApiIdsEqualTo(String value) {
addCriterion("api_ids =", value, "apiIds");
return (Criteria) this;
}
public Criteria andApiIdsNotEqualTo(String value) {
addCriterion("api_ids <>", value, "apiIds");
return (Criteria) this;
}
public Criteria andApiIdsGreaterThan(String value) {
addCriterion("api_ids >", value, "apiIds");
return (Criteria) this;
}
public Criteria andApiIdsGreaterThanOrEqualTo(String value) {
addCriterion("api_ids >=", value, "apiIds");
return (Criteria) this;
}
public Criteria andApiIdsLessThan(String value) {
addCriterion("api_ids <", value, "apiIds");
return (Criteria) this;
}
public Criteria andApiIdsLessThanOrEqualTo(String value) {
addCriterion("api_ids <=", value, "apiIds");
return (Criteria) this;
}
public Criteria andApiIdsLike(String value) {
addCriterion("api_ids like", value, "apiIds");
return (Criteria) this;
}
public Criteria andApiIdsNotLike(String value) {
addCriterion("api_ids not like", value, "apiIds");
return (Criteria) this;
}
public Criteria andApiIdsIn(List<String> values) {
addCriterion("api_ids in", values, "apiIds");
return (Criteria) this;
}
public Criteria andApiIdsNotIn(List<String> values) {
addCriterion("api_ids not in", values, "apiIds");
return (Criteria) this;
}
public Criteria andApiIdsBetween(String value1, String value2) {
addCriterion("api_ids between", value1, value2, "apiIds");
return (Criteria) this;
}
public Criteria andApiIdsNotBetween(String value1, String value2) {
addCriterion("api_ids not between", value1, value2, "apiIds");
return (Criteria) this;
}
public Criteria andScenarioIdsIsNull() {
addCriterion("scenario_ids is null");
return (Criteria) this;
}
public Criteria andScenarioIdsIsNotNull() {
addCriterion("scenario_ids is not null");
return (Criteria) this;
}
public Criteria andScenarioIdsEqualTo(String value) {
addCriterion("scenario_ids =", value, "scenarioIds");
return (Criteria) this;
}
public Criteria andScenarioIdsNotEqualTo(String value) {
addCriterion("scenario_ids <>", value, "scenarioIds");
return (Criteria) this;
}
public Criteria andScenarioIdsGreaterThan(String value) {
addCriterion("scenario_ids >", value, "scenarioIds");
return (Criteria) this;
}
public Criteria andScenarioIdsGreaterThanOrEqualTo(String value) {
addCriterion("scenario_ids >=", value, "scenarioIds");
return (Criteria) this;
}
public Criteria andScenarioIdsLessThan(String value) {
addCriterion("scenario_ids <", value, "scenarioIds");
return (Criteria) this;
}
public Criteria andScenarioIdsLessThanOrEqualTo(String value) {
addCriterion("scenario_ids <=", value, "scenarioIds");
return (Criteria) this;
}
public Criteria andScenarioIdsLike(String value) {
addCriterion("scenario_ids like", value, "scenarioIds");
return (Criteria) this;
}
public Criteria andScenarioIdsNotLike(String value) {
addCriterion("scenario_ids not like", value, "scenarioIds");
return (Criteria) this;
}
public Criteria andScenarioIdsIn(List<String> values) {
addCriterion("scenario_ids in", values, "scenarioIds");
return (Criteria) this;
}
public Criteria andScenarioIdsNotIn(List<String> values) {
addCriterion("scenario_ids not in", values, "scenarioIds");
return (Criteria) this;
}
public Criteria andScenarioIdsBetween(String value1, String value2) {
addCriterion("scenario_ids between", value1, value2, "scenarioIds");
return (Criteria) this;
}
public Criteria andScenarioIdsNotBetween(String value1, String value2) {
addCriterion("scenario_ids not between", value1, value2, "scenarioIds");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -2,9 +2,8 @@ package io.metersphere.base.mapper;
import io.metersphere.base.domain.ApiScenarioReport; import io.metersphere.base.domain.ApiScenarioReport;
import io.metersphere.base.domain.ApiScenarioReportExample; import io.metersphere.base.domain.ApiScenarioReportExample;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface ApiScenarioReportMapper { public interface ApiScenarioReportMapper {
long countByExample(ApiScenarioReportExample example); long countByExample(ApiScenarioReportExample example);

View File

@ -11,6 +11,8 @@
<result column="user_id" jdbcType="VARCHAR" property="userId" /> <result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="trigger_mode" jdbcType="VARCHAR" property="triggerMode" /> <result column="trigger_mode" jdbcType="VARCHAR" property="triggerMode" />
<result column="execute_type" jdbcType="VARCHAR" property="executeType" /> <result column="execute_type" jdbcType="VARCHAR" property="executeType" />
<result column="scenario_name" jdbcType="VARCHAR" property="scenarioName" />
<result column="scenario_id" jdbcType="VARCHAR" property="scenarioId" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiScenarioReport"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiScenarioReport">
<result column="description" jdbcType="LONGVARCHAR" property="description" /> <result column="description" jdbcType="LONGVARCHAR" property="description" />
@ -75,7 +77,7 @@
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, project_id, `name`, create_time, update_time, `status`, user_id, trigger_mode, id, project_id, `name`, create_time, update_time, `status`, user_id, trigger_mode,
execute_type execute_type, scenario_name, scenario_id
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
description description
@ -132,11 +134,13 @@
insert into api_scenario_report (id, project_id, `name`, insert into api_scenario_report (id, project_id, `name`,
create_time, update_time, `status`, create_time, update_time, `status`,
user_id, trigger_mode, execute_type, user_id, trigger_mode, execute_type,
description) scenario_name, scenario_id, description
)
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, #{executeType,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, #{executeType,jdbcType=VARCHAR},
#{description,jdbcType=LONGVARCHAR}) #{scenarioName,jdbcType=VARCHAR}, #{scenarioId,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}
)
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiScenarioReport"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiScenarioReport">
insert into api_scenario_report insert into api_scenario_report
@ -168,6 +172,12 @@
<if test="executeType != null"> <if test="executeType != null">
execute_type, execute_type,
</if> </if>
<if test="scenarioName != null">
scenario_name,
</if>
<if test="scenarioId != null">
scenario_id,
</if>
<if test="description != null"> <if test="description != null">
description, description,
</if> </if>
@ -200,6 +210,12 @@
<if test="executeType != null"> <if test="executeType != null">
#{executeType,jdbcType=VARCHAR}, #{executeType,jdbcType=VARCHAR},
</if> </if>
<if test="scenarioName != null">
#{scenarioName,jdbcType=VARCHAR},
</if>
<if test="scenarioId != null">
#{scenarioId,jdbcType=VARCHAR},
</if>
<if test="description != null"> <if test="description != null">
#{description,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR},
</if> </if>
@ -241,6 +257,12 @@
<if test="record.executeType != null"> <if test="record.executeType != null">
execute_type = #{record.executeType,jdbcType=VARCHAR}, execute_type = #{record.executeType,jdbcType=VARCHAR},
</if> </if>
<if test="record.scenarioName != null">
scenario_name = #{record.scenarioName,jdbcType=VARCHAR},
</if>
<if test="record.scenarioId != null">
scenario_id = #{record.scenarioId,jdbcType=VARCHAR},
</if>
<if test="record.description != null"> <if test="record.description != null">
description = #{record.description,jdbcType=LONGVARCHAR}, description = #{record.description,jdbcType=LONGVARCHAR},
</if> </if>
@ -260,6 +282,8 @@
user_id = #{record.userId,jdbcType=VARCHAR}, user_id = #{record.userId,jdbcType=VARCHAR},
trigger_mode = #{record.triggerMode,jdbcType=VARCHAR}, trigger_mode = #{record.triggerMode,jdbcType=VARCHAR},
execute_type = #{record.executeType,jdbcType=VARCHAR}, execute_type = #{record.executeType,jdbcType=VARCHAR},
scenario_name = #{record.scenarioName,jdbcType=VARCHAR},
scenario_id = #{record.scenarioId,jdbcType=VARCHAR},
description = #{record.description,jdbcType=LONGVARCHAR} description = #{record.description,jdbcType=LONGVARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -275,7 +299,9 @@
`status` = #{record.status,jdbcType=VARCHAR}, `status` = #{record.status,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR}, user_id = #{record.userId,jdbcType=VARCHAR},
trigger_mode = #{record.triggerMode,jdbcType=VARCHAR}, trigger_mode = #{record.triggerMode,jdbcType=VARCHAR},
execute_type = #{record.executeType,jdbcType=VARCHAR} execute_type = #{record.executeType,jdbcType=VARCHAR},
scenario_name = #{record.scenarioName,jdbcType=VARCHAR},
scenario_id = #{record.scenarioId,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>
@ -307,6 +333,12 @@
<if test="executeType != null"> <if test="executeType != null">
execute_type = #{executeType,jdbcType=VARCHAR}, execute_type = #{executeType,jdbcType=VARCHAR},
</if> </if>
<if test="scenarioName != null">
scenario_name = #{scenarioName,jdbcType=VARCHAR},
</if>
<if test="scenarioId != null">
scenario_id = #{scenarioId,jdbcType=VARCHAR},
</if>
<if test="description != null"> <if test="description != null">
description = #{description,jdbcType=LONGVARCHAR}, description = #{description,jdbcType=LONGVARCHAR},
</if> </if>
@ -323,6 +355,8 @@
user_id = #{userId,jdbcType=VARCHAR}, user_id = #{userId,jdbcType=VARCHAR},
trigger_mode = #{triggerMode,jdbcType=VARCHAR}, trigger_mode = #{triggerMode,jdbcType=VARCHAR},
execute_type = #{executeType,jdbcType=VARCHAR}, execute_type = #{executeType,jdbcType=VARCHAR},
scenario_name = #{scenarioName,jdbcType=VARCHAR},
scenario_id = #{scenarioId,jdbcType=VARCHAR},
description = #{description,jdbcType=LONGVARCHAR} description = #{description,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -335,7 +369,9 @@
`status` = #{status,jdbcType=VARCHAR}, `status` = #{status,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR}, user_id = #{userId,jdbcType=VARCHAR},
trigger_mode = #{triggerMode,jdbcType=VARCHAR}, trigger_mode = #{triggerMode,jdbcType=VARCHAR},
execute_type = #{executeType,jdbcType=VARCHAR} execute_type = #{executeType,jdbcType=VARCHAR},
scenario_name = #{scenarioName,jdbcType=VARCHAR},
scenario_id = #{scenarioId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -19,8 +19,6 @@
<result column="planned_end_time" jdbcType="BIGINT" property="plannedEndTime" /> <result column="planned_end_time" jdbcType="BIGINT" property="plannedEndTime" />
<result column="actual_start_time" jdbcType="BIGINT" property="actualStartTime" /> <result column="actual_start_time" jdbcType="BIGINT" property="actualStartTime" />
<result column="creator" jdbcType="VARCHAR" property="creator" /> <result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="api_ids" jdbcType="VARCHAR" property="apiIds" />
<result column="scenario_ids" jdbcType="VARCHAR" property="scenarioIds" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestPlan"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestPlan">
<result column="tags" jdbcType="LONGVARCHAR" property="tags" /> <result column="tags" jdbcType="LONGVARCHAR" property="tags" />
@ -86,7 +84,7 @@
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, workspace_id, report_id, `name`, description, `status`, stage, principal, test_case_match_rule, id, workspace_id, report_id, `name`, description, `status`, stage, principal, test_case_match_rule,
executor_match_rule, create_time, update_time, actual_end_time, planned_start_time, executor_match_rule, create_time, update_time, actual_end_time, planned_start_time,
planned_end_time, actual_start_time, creator, api_ids, scenario_ids planned_end_time, actual_start_time, creator
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
tags tags
@ -145,15 +143,15 @@
stage, principal, test_case_match_rule, stage, principal, test_case_match_rule,
executor_match_rule, create_time, update_time, executor_match_rule, create_time, update_time,
actual_end_time, planned_start_time, planned_end_time, actual_end_time, planned_start_time, planned_end_time,
actual_start_time, creator, api_ids, actual_start_time, creator, tags
scenario_ids, tags) )
values (#{id,jdbcType=VARCHAR}, #{workspaceId,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{workspaceId,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{stage,jdbcType=VARCHAR}, #{principal,jdbcType=VARCHAR}, #{testCaseMatchRule,jdbcType=VARCHAR}, #{stage,jdbcType=VARCHAR}, #{principal,jdbcType=VARCHAR}, #{testCaseMatchRule,jdbcType=VARCHAR},
#{executorMatchRule,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{executorMatchRule,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{actualEndTime,jdbcType=BIGINT}, #{plannedStartTime,jdbcType=BIGINT}, #{plannedEndTime,jdbcType=BIGINT}, #{actualEndTime,jdbcType=BIGINT}, #{plannedStartTime,jdbcType=BIGINT}, #{plannedEndTime,jdbcType=BIGINT},
#{actualStartTime,jdbcType=BIGINT}, #{creator,jdbcType=VARCHAR}, #{apiIds,jdbcType=VARCHAR}, #{actualStartTime,jdbcType=BIGINT}, #{creator,jdbcType=VARCHAR}, #{tags,jdbcType=LONGVARCHAR}
#{scenarioIds,jdbcType=VARCHAR}, #{tags,jdbcType=LONGVARCHAR}) )
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlan"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlan">
insert into test_plan insert into test_plan
@ -209,12 +207,6 @@
<if test="creator != null"> <if test="creator != null">
creator, creator,
</if> </if>
<if test="apiIds != null">
api_ids,
</if>
<if test="scenarioIds != null">
scenario_ids,
</if>
<if test="tags != null"> <if test="tags != null">
tags, tags,
</if> </if>
@ -271,12 +263,6 @@
<if test="creator != null"> <if test="creator != null">
#{creator,jdbcType=VARCHAR}, #{creator,jdbcType=VARCHAR},
</if> </if>
<if test="apiIds != null">
#{apiIds,jdbcType=VARCHAR},
</if>
<if test="scenarioIds != null">
#{scenarioIds,jdbcType=VARCHAR},
</if>
<if test="tags != null"> <if test="tags != null">
#{tags,jdbcType=LONGVARCHAR}, #{tags,jdbcType=LONGVARCHAR},
</if> </if>
@ -342,12 +328,6 @@
<if test="record.creator != null"> <if test="record.creator != null">
creator = #{record.creator,jdbcType=VARCHAR}, creator = #{record.creator,jdbcType=VARCHAR},
</if> </if>
<if test="record.apiIds != null">
api_ids = #{record.apiIds,jdbcType=VARCHAR},
</if>
<if test="record.scenarioIds != null">
scenario_ids = #{record.scenarioIds,jdbcType=VARCHAR},
</if>
<if test="record.tags != null"> <if test="record.tags != null">
tags = #{record.tags,jdbcType=LONGVARCHAR}, tags = #{record.tags,jdbcType=LONGVARCHAR},
</if> </if>
@ -375,8 +355,6 @@
planned_end_time = #{record.plannedEndTime,jdbcType=BIGINT}, planned_end_time = #{record.plannedEndTime,jdbcType=BIGINT},
actual_start_time = #{record.actualStartTime,jdbcType=BIGINT}, actual_start_time = #{record.actualStartTime,jdbcType=BIGINT},
creator = #{record.creator,jdbcType=VARCHAR}, creator = #{record.creator,jdbcType=VARCHAR},
api_ids = #{record.apiIds,jdbcType=VARCHAR},
scenario_ids = #{record.scenarioIds,jdbcType=VARCHAR},
tags = #{record.tags,jdbcType=LONGVARCHAR} tags = #{record.tags,jdbcType=LONGVARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -400,9 +378,7 @@
planned_start_time = #{record.plannedStartTime,jdbcType=BIGINT}, planned_start_time = #{record.plannedStartTime,jdbcType=BIGINT},
planned_end_time = #{record.plannedEndTime,jdbcType=BIGINT}, planned_end_time = #{record.plannedEndTime,jdbcType=BIGINT},
actual_start_time = #{record.actualStartTime,jdbcType=BIGINT}, actual_start_time = #{record.actualStartTime,jdbcType=BIGINT},
creator = #{record.creator,jdbcType=VARCHAR}, creator = #{record.creator,jdbcType=VARCHAR}
api_ids = #{record.apiIds,jdbcType=VARCHAR},
scenario_ids = #{record.scenarioIds,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>
@ -458,12 +434,6 @@
<if test="creator != null"> <if test="creator != null">
creator = #{creator,jdbcType=VARCHAR}, creator = #{creator,jdbcType=VARCHAR},
</if> </if>
<if test="apiIds != null">
api_ids = #{apiIds,jdbcType=VARCHAR},
</if>
<if test="scenarioIds != null">
scenario_ids = #{scenarioIds,jdbcType=VARCHAR},
</if>
<if test="tags != null"> <if test="tags != null">
tags = #{tags,jdbcType=LONGVARCHAR}, tags = #{tags,jdbcType=LONGVARCHAR},
</if> </if>
@ -488,8 +458,6 @@
planned_end_time = #{plannedEndTime,jdbcType=BIGINT}, planned_end_time = #{plannedEndTime,jdbcType=BIGINT},
actual_start_time = #{actualStartTime,jdbcType=BIGINT}, actual_start_time = #{actualStartTime,jdbcType=BIGINT},
creator = #{creator,jdbcType=VARCHAR}, creator = #{creator,jdbcType=VARCHAR},
api_ids = #{apiIds,jdbcType=VARCHAR},
scenario_ids = #{scenarioIds,jdbcType=VARCHAR},
tags = #{tags,jdbcType=LONGVARCHAR} tags = #{tags,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -510,9 +478,7 @@
planned_start_time = #{plannedStartTime,jdbcType=BIGINT}, planned_start_time = #{plannedStartTime,jdbcType=BIGINT},
planned_end_time = #{plannedEndTime,jdbcType=BIGINT}, planned_end_time = #{plannedEndTime,jdbcType=BIGINT},
actual_start_time = #{actualStartTime,jdbcType=BIGINT}, actual_start_time = #{actualStartTime,jdbcType=BIGINT},
creator = #{creator,jdbcType=VARCHAR}, creator = #{creator,jdbcType=VARCHAR}
api_ids = #{apiIds,jdbcType=VARCHAR},
scenario_ids = #{scenarioIds,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -100,7 +100,7 @@
<select id="list" resultMap="BaseResultMap"> <select id="list" resultMap="BaseResultMap">
SELECT r.name AS test_name, SELECT r.name AS test_name,
r.name, r.description, r.id, r.project_id, r.create_time, r.update_time, r.status, r.trigger_mode, r.name, r.description, r.id, r.project_id, r.create_time, r.update_time, r.status, r.trigger_mode,r.scenario_name,
project.name AS project_name, user.name AS user_name project.name AS project_name, user.name AS user_name
FROM api_scenario_report r FROM api_scenario_report r
LEFT JOIN project ON project.id = r.project_id LEFT JOIN project ON project.id = r.project_id

View File

@ -17,12 +17,9 @@ public interface ExtTestPlanMapper {
List<TestPlanDTO> selectByIds(@Param("list") List<String> ids); List<TestPlanDTO> selectByIds(@Param("list") List<String> ids);
int updatePlan(@Param("plan") TestPlanDTO plan);
List<TestPlanDTO> selectReference(@Param("request") QueryTestPlanRequest params);
/** /**
* 通过关联表(test_plan_api_case/test_plan_api_scenario)查询testPlan * 通过关联表(test_plan_api_case/test_plan_api_scenario)查询testPlan
*
* @param params * @param params
* @return * @return
*/ */

View File

@ -182,21 +182,6 @@
order by test_plan.update_time desc order by test_plan.update_time desc
</select> </select>
<update id="updatePlan" parameterType="io.metersphere.track.dto.TestPlanDTO">
update test_plan
<set>
<if test="plan.apiIds != null">
api_ids = #{plan.apiIds,jdbcType=VARCHAR}
</if>
<if test="plan.scenarioIds != null">
scenario_ids = #{plan.scenarioIds,jdbcType=VARCHAR}
</if>
</set>
<where>
id = #{plan.id}
</where>
</update>
<select id="selectByIds" resultMap="BaseResultMap" parameterType="java.util.List"> <select id="selectByIds" resultMap="BaseResultMap" parameterType="java.util.List">
SELECT * FROM TEST_PLAN p where p.id in SELECT * FROM TEST_PLAN p where p.id in
<foreach collection="list" item="planId" open="(" close=")" separator=","> <foreach collection="list" item="planId" open="(" close=")" separator=",">
@ -204,18 +189,6 @@
</foreach> </foreach>
</select> </select>
<select id="selectReference" resultMap="BaseResultMap" parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest">
SELECT * FROM TEST_PLAN p LEFT JOIN test_plan_project t ON t.test_plan_id=p.id
<where>
<if test="request.scenarioId != null">
AND p.scenario_ids like CONCAT('%', #{request.scenarioId},'%')
</if>
<if test="request.apiId != null">
AND p.api_ids like CONCAT('%', #{request.apiId},'%')
</if>
</where>
</select>
<select id="checkIsHave" resultType="int"> <select id="checkIsHave" resultType="int">
SELECT COUNT(1) SELECT COUNT(1)
FROM test_plan_project, project FROM test_plan_project, project

View File

@ -41,6 +41,10 @@ public class DateUtils {
return dateFormat.format(timeStamp); return dateFormat.format(timeStamp);
} }
public static String getTimeStr(long timeStamp) {
SimpleDateFormat dateFormat = new SimpleDateFormat(TIME_PATTERN);
return dateFormat.format(timeStamp);
}
public static Date dateSum (Date date,int countDays){ public static Date dateSum (Date date,int countDays){

View File

@ -55,7 +55,7 @@ public class ApiScenarioTestJob extends MsScheduleJob {
request.setReportId(id); request.setReportId(id);
request.setProjectId(projectID); request.setProjectId(projectID);
request.setTriggerMode(ReportTriggerMode.SCHEDULE.name()); request.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
request.setExecuteType(ExecuteType.Completed.name()); request.setExecuteType(ExecuteType.Saved.name());
request.setScenarioIds(this.scenarioIds); request.setScenarioIds(this.scenarioIds);
request.setReportUserID(this.userId); request.setReportUserID(this.userId);

@ -1 +1 @@
Subproject commit 9f4a9bbf46fc1333dbcccea21f83e27e3ec10b1f Subproject commit 79343a2763b014355f91fc21b2356a95ae437973

View File

@ -0,0 +1,4 @@
ALTER TABLE api_scenario_report ADD scenario_name varchar(255) NULL;
ALTER TABLE api_scenario_report ADD scenario_id varchar(100) NULL;
ALTER TABLE test_plan DROP COLUMN api_ids;
ALTER TABLE test_plan DROP COLUMN scenario_ids;

View File

@ -20,10 +20,8 @@
</el-table-column> </el-table-column>
<el-table-column :label="$t('commons.name')" width="200" show-overflow-tooltip prop="name"> <el-table-column :label="$t('commons.name')" width="200" show-overflow-tooltip prop="name">
</el-table-column> </el-table-column>
<!--
<el-table-column prop="testName" :label="$t('api_report.test_name')" width="200" show-overflow-tooltip/> <el-table-column prop="scenarioName" :label="$t('api_test.automation.scenario_name')" width="150" show-overflow-tooltip/>
-->
<el-table-column prop="projectName" :label="$t('load_test.project_name')" width="150" show-overflow-tooltip/>
<el-table-column prop="userName" :label="$t('api_test.creator')" width="150" show-overflow-tooltip/> <el-table-column prop="userName" :label="$t('api_test.creator')" width="150" show-overflow-tooltip/>
<el-table-column prop="createTime" width="250" :label="$t('commons.create_time')" sortable> <el-table-column prop="createTime" width="250" :label="$t('commons.create_time')" sortable>
<template v-slot:default="scope"> <template v-slot:default="scope">

View File

@ -1,6 +1,6 @@
<template> <template>
<el-card class="card-content"> <el-card>
<div> <div class="card-content">
<div class="ms-main-div" @click="showAll"> <div class="ms-main-div" @click="showAll">
<el-row> <el-row>
<el-col> <el-col>
@ -14,28 +14,28 @@
<el-form :model="currentScenario" label-position="right" label-width="80px" size="small" :rules="rules" ref="currentScenario" style="margin-right: 20px"> <el-form :model="currentScenario" label-position="right" label-width="80px" size="small" :rules="rules" ref="currentScenario" style="margin-right: 20px">
<!-- 基础信息 --> <!-- 基础信息 -->
<el-row> <el-row>
<el-col :span="12"> <el-col :span="7">
<el-form-item :label="$t('commons.name')" prop="name"> <el-form-item :label="$t('commons.name')" prop="name">
<el-input class="ms-scenario-input" size="small" v-model="currentScenario.name"/> <el-input class="ms-scenario-input" size="small" v-model="currentScenario.name"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="7">
<el-form-item :label="$t('test_track.module.module')" prop="apiScenarioModuleId"> <el-form-item :label="$t('test_track.module.module')" prop="apiScenarioModuleId">
<el-select class="ms-scenario-input" size="small" v-model="currentScenario.apiScenarioModuleId"> <el-select class="ms-scenario-input" size="small" v-model="currentScenario.apiScenarioModuleId">
<el-option v-for="item in moduleOptions" :key="item.id" :label="item.path" :value="item.id"/> <el-option v-for="item in moduleOptions" :key="item.id" :label="item.path" :value="item.id"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> <el-col :span="7">
<el-row>
<el-col :span="12">
<el-form-item :label="$t('commons.status')" prop="status"> <el-form-item :label="$t('commons.status')" prop="status">
<el-select class="ms-scenario-input" size="small" v-model="currentScenario.status"> <el-select class="ms-scenario-input" size="small" v-model="currentScenario.status">
<el-option v-for="item in options" :key="item.id" :label="item.label" :value="item.id"/> <el-option v-for="item in options" :key="item.id" :label="item.label" :value="item.id"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> </el-row>
<el-row>
<el-col :span="7">
<el-form-item :label="$t('api_test.definition.request.responsible')" prop="principal"> <el-form-item :label="$t('api_test.definition.request.responsible')" prop="principal">
<el-select v-model="currentScenario.principal" <el-select v-model="currentScenario.principal"
:placeholder="$t('api_test.definition.request.responsible')" filterable size="small" :placeholder="$t('api_test.definition.request.responsible')" filterable size="small"
@ -47,20 +47,16 @@
:value="item.id"> :value="item.id">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> <el-col :span="7">
<el-row>
<el-col :span="12">
<el-form-item :label="$t('test_track.case.priority')" prop="level"> <el-form-item :label="$t('test_track.case.priority')" prop="level">
<el-select class="ms-scenario-input" size="small" v-model="currentScenario.level"> <el-select class="ms-scenario-input" size="small" v-model="currentScenario.level">
<el-option v-for="item in levels" :key="item.id" :label="item.label" :value="item.id"/> <el-option v-for="item in levels" :key="item.id" :label="item.label" :value="item.id"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="7">
<el-form-item :label="$t('api_test.automation.follow_people')" prop="followPeople"> <el-form-item :label="$t('api_test.automation.follow_people')" prop="followPeople">
<el-select v-model="currentScenario.followPeople" <el-select v-model="currentScenario.followPeople"
:placeholder="$t('api_test.automation.follow_people')" filterable size="small" :placeholder="$t('api_test.automation.follow_people')" filterable size="small"
@ -76,14 +72,13 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="7">
<el-form-item label="Tag" prop="tags"> <el-form-item label="Tag" prop="tags">
<ms-input-tag :currentScenario="currentScenario" ref="tag"/> <ms-input-tag :currentScenario="currentScenario" ref="tag"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="7">
<el-form-item :label="$t('commons.description')" prop="description"> <el-form-item :label="$t('commons.description')" prop="description">
<el-input class="ms-http-textarea" <el-input class="ms-http-textarea"
v-model="currentScenario.description" v-model="currentScenario.description"
@ -181,9 +176,9 @@
</div> </div>
</el-col> </el-col>
<!-- 按钮列表 --> <!-- 按钮列表 -->
<div>
<el-col :span="3"> <el-col :span="3">
<vue-fab id="fab" mainBtnColor="#783887" :click-auto-close="false"> <vue-fab id="fab" mainBtnColor="#783887" size="small" :global-options="globalOptions"
:click-auto-close="false" v-outside-click="outsideClick">
<fab-item <fab-item
v-for="(item, index) in buttons" v-for="(item, index) in buttons"
:key="index" :key="index"
@ -196,7 +191,6 @@
@clickItem="item.click"/> @clickItem="item.click"/>
</vue-fab> </vue-fab>
</el-col> </el-col>
</div>
</el-row> </el-row>
</div> </div>
@ -253,6 +247,7 @@
import ApiImport from "../../definition/components/import/ApiImport"; import ApiImport from "../../definition/components/import/ApiImport";
import InputTag from 'vue-input-tag' import InputTag from 'vue-input-tag'
import "@/common/css/material-icons.css" import "@/common/css/material-icons.css"
import OutsideClick from "@/common/js/outside-click";
import ScenarioApiRelevance from "./api/ScenarioApiRelevance"; import ScenarioApiRelevance from "./api/ScenarioApiRelevance";
import ScenarioRelevance from "./api/ScenarioRelevance"; import ScenarioRelevance from "./api/ScenarioRelevance";
@ -319,6 +314,9 @@
reportId: "", reportId: "",
projectId: "", projectId: "",
enableCookieShare: false, enableCookieShare: false,
globalOptions: {
spacing: 30
}
} }
} }
, ,
@ -334,6 +332,7 @@
, ,
watch: {} watch: {}
, ,
directives: {OutsideClick},
computed: { computed: {
buttons() { buttons() {
let buttons = [ let buttons = [
@ -441,7 +440,7 @@
}, },
methods: { methods: {
getIdx(index) { getIdx(index) {
return -1 * index - 2.25; // return index - 0.33
}, },
showButton(...names) { showButton(...names) {
for (const name of names) { for (const name of names) {
@ -451,6 +450,9 @@
} }
return false; return false;
}, },
outsideClick() {
this.operatingElements = ELEMENTS.get("ALL");
},
addComponent(type) { addComponent(type) {
switch (type) { switch (type) {
case ELEMENT_TYPE.IfController: case ELEMENT_TYPE.IfController:
@ -878,6 +880,10 @@
</script> </script>
<style scoped> <style scoped>
.card-content {
height: calc(100vh - 196px);
overflow-y: auto;
}
.ms-scenario-input { .ms-scenario-input {
width: 100%; width: 100%;
} }
@ -892,10 +898,9 @@
} }
.ms-debug-div { .ms-debug-div {
margin-left: 20px;
border: 1px #DCDFE6 solid; border: 1px #DCDFE6 solid;
border-radius: 4px; border-radius: 4px;
margin-right: 10px; margin-right: 20px;
} }
.ms-scenario-button { .ms-scenario-button {
@ -928,7 +933,6 @@
} }
#fab { #fab {
bottom: unset;
right: 90px; right: 90px;
z-index: 5; z-index: 5;
} }

View File

@ -112,8 +112,8 @@ export default {
threadGroups: [], threadGroups: [],
} }
}, },
mounted() { activated() {
// this.getJmxContent(); this.getJmxContent();
}, },
methods: { methods: {
calculateLoadConfiguration: function (data) { calculateLoadConfiguration: function (data) {

View File

@ -0,0 +1,31 @@
const OutsideClick = {
// 初始化指令
bind(el, binding, vnode) {
function documentHandler(e) {
// 这里判断点击的元素是否是本身,是本身,则返回
if (el.contains(e.target)) {
return false;
}
// 判断指令中是否绑定了函数
if (binding.expression) {
// 如果绑定了函数 则调用那个函数此处binding.value就是handleClose方法
binding.value(e);
}
}
// 给当前元素绑定个私有变量方便在unbind中可以解除事件监听
el.__vueClickOutside__ = documentHandler;
document.addEventListener('click', documentHandler);
},
update() {
},
unbind(el, binding) {
// 解除事件监听
document.removeEventListener('click', el.__vueClickOutside__);
delete el.__vueClickOutside__;
},
};
export default OutsideClick;