perf(接口测试): 接口测试报告查询SQL语句需优化
--user=郭雨琦 接口测试报告查询SQL语句需优化 chore: sync
This commit is contained in:
parent
b35a0468ab
commit
cb5c5a507f
|
@ -9,6 +9,8 @@ import io.metersphere.api.dto.automation.APIScenarioReportResult;
|
||||||
import io.metersphere.api.dto.automation.ExecuteType;
|
import io.metersphere.api.dto.automation.ExecuteType;
|
||||||
import io.metersphere.api.service.ApiScenarioReportService;
|
import io.metersphere.api.service.ApiScenarioReportService;
|
||||||
import io.metersphere.base.domain.ApiScenarioReport;
|
import io.metersphere.base.domain.ApiScenarioReport;
|
||||||
|
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
|
||||||
|
import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper;
|
||||||
import io.metersphere.commons.constants.NoticeConstants;
|
import io.metersphere.commons.constants.NoticeConstants;
|
||||||
import io.metersphere.commons.constants.OperLogConstants;
|
import io.metersphere.commons.constants.OperLogConstants;
|
||||||
import io.metersphere.commons.constants.OperLogModule;
|
import io.metersphere.commons.constants.OperLogModule;
|
||||||
|
@ -27,6 +29,10 @@ public class APIScenarioReportController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ApiScenarioReportService apiReportService;
|
private ApiScenarioReportService apiReportService;
|
||||||
|
@Resource
|
||||||
|
private ExtApiScenarioReportMapper extApiScenarioReportMapper;
|
||||||
|
@Resource
|
||||||
|
private ExtApiDefinitionExecResultMapper extApiDefinitionExecResultMapper;
|
||||||
|
|
||||||
@GetMapping("/get/{reportId}")
|
@GetMapping("/get/{reportId}")
|
||||||
public APIScenarioReportResult get(@PathVariable String reportId) {
|
public APIScenarioReportResult get(@PathVariable String reportId) {
|
||||||
|
@ -35,9 +41,12 @@ public class APIScenarioReportController {
|
||||||
|
|
||||||
@PostMapping("/list/{goPage}/{pageSize}")
|
@PostMapping("/list/{goPage}/{pageSize}")
|
||||||
public Pager<List<APIScenarioReportResult>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryAPIReportRequest request) {
|
public Pager<List<APIScenarioReportResult>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryAPIReportRequest request) {
|
||||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
Page<Object> page = new Page(goPage, pageSize*2, true);
|
||||||
request.setLimit("LIMIT " + (goPage - 1) * pageSize + "," + pageSize * 50);
|
long scenarioCount = extApiScenarioReportMapper.selectCountByRequest(request);
|
||||||
return PageUtils.setPageInfo(page, apiReportService.list(request));
|
long definitionCount = extApiDefinitionExecResultMapper.selectCountByRequest(request);
|
||||||
|
long totalCount = scenarioCount + definitionCount;
|
||||||
|
page.setTotal(totalCount);
|
||||||
|
return PageUtils.setPageInfo(page, apiReportService.list(goPage,pageSize*2,request));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
|
|
|
@ -22,4 +22,7 @@ public class QueryAPIReportRequest {
|
||||||
private Map<String, Object> combine;
|
private Map<String, Object> combine;
|
||||||
|
|
||||||
private String limit;
|
private String limit;
|
||||||
|
|
||||||
|
private Integer goPage;
|
||||||
|
private Integer pageSize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,7 @@ import io.metersphere.api.exec.scenario.ApiScenarioSerialService;
|
||||||
import io.metersphere.api.exec.utils.ApiDefinitionExecResultUtil;
|
import io.metersphere.api.exec.utils.ApiDefinitionExecResultUtil;
|
||||||
import io.metersphere.api.service.*;
|
import io.metersphere.api.service.*;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.ApiScenarioReportMapper;
|
import io.metersphere.base.mapper.*;
|
||||||
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
|
||||||
import io.metersphere.base.mapper.TestPlanApiCaseMapper;
|
|
||||||
import io.metersphere.base.mapper.TestPlanMapper;
|
|
||||||
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
||||||
import io.metersphere.commons.constants.*;
|
import io.metersphere.commons.constants.*;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
|
@ -61,6 +58,8 @@ public class ApiCaseExecuteService {
|
||||||
private ApiScenarioReportMapper apiScenarioReportMapper;
|
private ApiScenarioReportMapper apiScenarioReportMapper;
|
||||||
@Resource
|
@Resource
|
||||||
ApiScenarioReportStructureService apiScenarioReportStructureService;
|
ApiScenarioReportStructureService apiScenarioReportStructureService;
|
||||||
|
@Resource
|
||||||
|
private ApiDefinitionScenarioRelevanceMapper apiDefinitionScenarioRelevanceMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试计划case执行
|
* 测试计划case执行
|
||||||
|
@ -222,7 +221,10 @@ public class ApiCaseExecuteService {
|
||||||
request.getConfig().setAmassReport(serialReportId);
|
request.getConfig().setAmassReport(serialReportId);
|
||||||
report.setStatus(APITestStatus.Running.name());
|
report.setStatus(APITestStatus.Running.name());
|
||||||
apiScenarioReportMapper.insert(report);
|
apiScenarioReportMapper.insert(report);
|
||||||
|
//生成关系数据
|
||||||
|
ApiDefinitionScenarioRelevance apiDefinitionScenarioRelevance = new ApiDefinitionScenarioRelevance();
|
||||||
|
apiDefinitionScenarioRelevance.setReportId(report.getId());
|
||||||
|
apiDefinitionScenarioRelevanceMapper.insert(apiDefinitionScenarioRelevance);
|
||||||
apiScenarioReportStructureService.save(serialReportId, new ArrayList<>());
|
apiScenarioReportStructureService.save(serialReportId, new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import io.metersphere.api.service.ApiTestEnvironmentService;
|
||||||
import io.metersphere.api.service.TcpApiParamService;
|
import io.metersphere.api.service.TcpApiParamService;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
||||||
|
import io.metersphere.base.mapper.ApiDefinitionScenarioRelevanceMapper;
|
||||||
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
||||||
import io.metersphere.base.mapper.TestPlanApiCaseMapper;
|
import io.metersphere.base.mapper.TestPlanApiCaseMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
||||||
|
@ -60,6 +61,8 @@ public class ApiExecuteService {
|
||||||
private TcpApiParamService tcpApiParamService;
|
private TcpApiParamService tcpApiParamService;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtApiTestCaseMapper extApiTestCaseMapper;
|
private ExtApiTestCaseMapper extApiTestCaseMapper;
|
||||||
|
@Resource
|
||||||
|
private ApiDefinitionScenarioRelevanceMapper apiDefinitionScenarioRelevanceMapper;
|
||||||
|
|
||||||
public MsExecResponseDTO jenkinsRun(RunCaseRequest request) {
|
public MsExecResponseDTO jenkinsRun(RunCaseRequest request) {
|
||||||
ApiTestCaseWithBLOBs caseWithBLOBs = null;
|
ApiTestCaseWithBLOBs caseWithBLOBs = null;
|
||||||
|
@ -85,6 +88,10 @@ public class ApiExecuteService {
|
||||||
report.setType(ApiRunMode.JENKINS.name());
|
report.setType(ApiRunMode.JENKINS.name());
|
||||||
report.setProjectId(caseWithBLOBs.getProjectId());
|
report.setProjectId(caseWithBLOBs.getProjectId());
|
||||||
apiDefinitionExecResultMapper.insert(report);
|
apiDefinitionExecResultMapper.insert(report);
|
||||||
|
//生成关系数据
|
||||||
|
ApiDefinitionScenarioRelevance apiDefinitionScenarioRelevance = new ApiDefinitionScenarioRelevance();
|
||||||
|
apiDefinitionScenarioRelevance.setReportId(report.getId());
|
||||||
|
apiDefinitionScenarioRelevanceMapper.insert(apiDefinitionScenarioRelevance);
|
||||||
//更新接口案例的最后执行状态等信息
|
//更新接口案例的最后执行状态等信息
|
||||||
caseWithBLOBs.setLastResultId(report.getId());
|
caseWithBLOBs.setLastResultId(report.getId());
|
||||||
caseWithBLOBs.setUpdateTime(System.currentTimeMillis());
|
caseWithBLOBs.setUpdateTime(System.currentTimeMillis());
|
||||||
|
|
|
@ -15,9 +15,11 @@ import io.metersphere.api.service.ApiExecutionQueueService;
|
||||||
import io.metersphere.api.service.ApiScenarioReportService;
|
import io.metersphere.api.service.ApiScenarioReportService;
|
||||||
import io.metersphere.api.service.ApiScenarioReportStructureService;
|
import io.metersphere.api.service.ApiScenarioReportStructureService;
|
||||||
import io.metersphere.api.service.TcpApiParamService;
|
import io.metersphere.api.service.TcpApiParamService;
|
||||||
|
import io.metersphere.base.domain.ApiDefinitionScenarioRelevance;
|
||||||
import io.metersphere.base.domain.ApiScenarioExample;
|
import io.metersphere.base.domain.ApiScenarioExample;
|
||||||
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
||||||
import io.metersphere.base.domain.TestPlanApiScenario;
|
import io.metersphere.base.domain.TestPlanApiScenario;
|
||||||
|
import io.metersphere.base.mapper.ApiDefinitionScenarioRelevanceMapper;
|
||||||
import io.metersphere.base.mapper.ApiScenarioMapper;
|
import io.metersphere.base.mapper.ApiScenarioMapper;
|
||||||
import io.metersphere.base.mapper.ApiScenarioReportMapper;
|
import io.metersphere.base.mapper.ApiScenarioReportMapper;
|
||||||
import io.metersphere.base.mapper.TestPlanApiScenarioMapper;
|
import io.metersphere.base.mapper.TestPlanApiScenarioMapper;
|
||||||
|
@ -86,6 +88,9 @@ public class ApiScenarioExecuteService {
|
||||||
private TcpApiParamService tcpApiParamService;
|
private TcpApiParamService tcpApiParamService;
|
||||||
@Resource
|
@Resource
|
||||||
private JMeterService jMeterService;
|
private JMeterService jMeterService;
|
||||||
|
@Resource
|
||||||
|
private ApiDefinitionScenarioRelevanceMapper apiDefinitionScenarioRelevanceMapper;
|
||||||
|
|
||||||
|
|
||||||
public List<MsExecResponseDTO> run(RunScenarioRequest request) {
|
public List<MsExecResponseDTO> run(RunScenarioRequest request) {
|
||||||
if (LoggerUtil.getLogger().isDebugEnabled()) {
|
if (LoggerUtil.getLogger().isDebugEnabled()) {
|
||||||
|
@ -159,6 +164,9 @@ public class ApiScenarioExecuteService {
|
||||||
request.getConfig().setAmassReport(serialReportId);
|
request.getConfig().setAmassReport(serialReportId);
|
||||||
report.setStatus(APITestStatus.Running.name());
|
report.setStatus(APITestStatus.Running.name());
|
||||||
apiScenarioReportMapper.insert(report);
|
apiScenarioReportMapper.insert(report);
|
||||||
|
ApiDefinitionScenarioRelevance apiDefinitionScenarioRelevance = new ApiDefinitionScenarioRelevance();
|
||||||
|
apiDefinitionScenarioRelevance.setReportId(report.getId());
|
||||||
|
apiDefinitionScenarioRelevanceMapper.insert(apiDefinitionScenarioRelevance);
|
||||||
|
|
||||||
responseDTOS.add(new MsExecResponseDTO(JSON.toJSONString(scenarioIds), serialReportId, request.getRunMode()));
|
responseDTOS.add(new MsExecResponseDTO(JSON.toJSONString(scenarioIds), serialReportId, request.getRunMode()));
|
||||||
reportStructureService.save(apiScenarios, serialReportId, request.getConfig().getReportType());
|
reportStructureService.save(apiScenarios, serialReportId, request.getConfig().getReportType());
|
||||||
|
@ -361,6 +369,11 @@ public class ApiScenarioExecuteService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apiScenarioReportMapper.insert(report);
|
apiScenarioReportMapper.insert(report);
|
||||||
|
if(report.getExecuteType().equals(ExecuteType.Saved.name())){
|
||||||
|
ApiDefinitionScenarioRelevance apiDefinitionScenarioRelevance = new ApiDefinitionScenarioRelevance();
|
||||||
|
apiDefinitionScenarioRelevance.setReportId(report.getId());
|
||||||
|
apiDefinitionScenarioRelevanceMapper.insert(apiDefinitionScenarioRelevance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String runMode = StringUtils.isEmpty(request.getRunMode()) ? ApiRunMode.SCENARIO.name() : request.getRunMode();
|
String runMode = StringUtils.isEmpty(request.getRunMode()) ? ApiRunMode.SCENARIO.name() : request.getRunMode();
|
||||||
// 调用执行方法
|
// 调用执行方法
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
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)
|
||||||
|
@ -69,6 +70,8 @@ public class ApiDefinitionExecResultService {
|
||||||
private ProjectMapper projectMapper;
|
private ProjectMapper projectMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private SqlSessionFactory sqlSessionFactory;
|
private SqlSessionFactory sqlSessionFactory;
|
||||||
|
@Resource
|
||||||
|
private ApiDefinitionScenarioRelevanceMapper apiDefinitionScenarioRelevanceMapper;
|
||||||
|
|
||||||
public void saveApiResult(List<RequestResult> requestResults, ResultDTO dto) {
|
public void saveApiResult(List<RequestResult> requestResults, ResultDTO dto) {
|
||||||
LoggerUtil.info("接收到API/CASE执行结果【 " + requestResults.size() + " 】");
|
LoggerUtil.info("接收到API/CASE执行结果【 " + requestResults.size() + " 】");
|
||||||
|
@ -350,6 +353,8 @@ public class ApiDefinitionExecResultService {
|
||||||
public void deleteByResourceId(String resourceId) {
|
public void deleteByResourceId(String resourceId) {
|
||||||
ApiDefinitionExecResultExample example = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample example = new ApiDefinitionExecResultExample();
|
||||||
example.createCriteria().andResourceIdEqualTo(resourceId);
|
example.createCriteria().andResourceIdEqualTo(resourceId);
|
||||||
|
ApiDefinitionExecResult result = extApiDefinitionExecResultMapper.selectMaxResultByResourceId(resourceId);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByPrimaryKey(result.getId());
|
||||||
apiDefinitionExecResultMapper.deleteByExample(example);
|
apiDefinitionExecResultMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,6 +364,13 @@ public class ApiDefinitionExecResultService {
|
||||||
}
|
}
|
||||||
ApiDefinitionExecResultExample example = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample example = new ApiDefinitionExecResultExample();
|
||||||
example.createCriteria().andResourceIdIn(ids);
|
example.createCriteria().andResourceIdIn(ids);
|
||||||
|
List<ApiDefinitionExecResult> apiDefinitionExecResults = apiDefinitionExecResultMapper.selectByExample(example);
|
||||||
|
if(apiDefinitionExecResults!=null&&apiDefinitionExecResults.size()!=0){
|
||||||
|
List<String> reportIds = apiDefinitionExecResults.stream().map(ApiDefinitionExecResult::getId).collect(Collectors.toList());
|
||||||
|
ApiDefinitionScenarioRelevanceExample sexample = new ApiDefinitionScenarioRelevanceExample();
|
||||||
|
sexample.createCriteria().andReportIdIn(reportIds);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByExample(sexample);
|
||||||
|
}
|
||||||
apiDefinitionExecResultMapper.deleteByExample(example);
|
apiDefinitionExecResultMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,8 @@ public class ApiDefinitionService {
|
||||||
private ExtProjectVersionMapper extProjectVersionMapper;
|
private ExtProjectVersionMapper extProjectVersionMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ProjectApplicationService projectApplicationService;
|
private ProjectApplicationService projectApplicationService;
|
||||||
|
@Resource
|
||||||
|
private ApiDefinitionScenarioRelevanceMapper apiDefinitionScenarioRelevanceMapper;
|
||||||
|
|
||||||
private ThreadLocal<Long> currentApiOrder = new ThreadLocal<>();
|
private ThreadLocal<Long> currentApiOrder = new ThreadLocal<>();
|
||||||
private ThreadLocal<Long> currentApiCaseOrder = new ThreadLocal<>();
|
private ThreadLocal<Long> currentApiCaseOrder = new ThreadLocal<>();
|
||||||
|
@ -346,6 +348,8 @@ public class ApiDefinitionService {
|
||||||
apiDefinitions.forEach(api -> {
|
apiDefinitions.forEach(api -> {
|
||||||
apiTestCaseService.deleteTestCase(api.getId());
|
apiTestCaseService.deleteTestCase(api.getId());
|
||||||
deleteFileByTestId(api.getId());
|
deleteFileByTestId(api.getId());
|
||||||
|
ApiDefinitionExecResult result = extApiDefinitionExecResultMapper.selectMaxResultByResourceId(api.getId());
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByPrimaryKey(result.getId());
|
||||||
extApiDefinitionExecResultMapper.deleteByResourceId(api.getId());
|
extApiDefinitionExecResultMapper.deleteByResourceId(api.getId());
|
||||||
apiDefinitionMapper.deleteByPrimaryKey(api.getId());
|
apiDefinitionMapper.deleteByPrimaryKey(api.getId());
|
||||||
esbApiParamService.deleteByResourceId(api.getId());
|
esbApiParamService.deleteByResourceId(api.getId());
|
||||||
|
@ -1052,6 +1056,10 @@ public class ApiDefinitionService {
|
||||||
result.setProjectId(request.getProjectId());
|
result.setProjectId(request.getProjectId());
|
||||||
result.setTriggerMode(TriggerMode.MANUAL.name());
|
result.setTriggerMode(TriggerMode.MANUAL.name());
|
||||||
apiDefinitionExecResultMapper.insert(result);
|
apiDefinitionExecResultMapper.insert(result);
|
||||||
|
//生成关系数据
|
||||||
|
ApiDefinitionScenarioRelevance apiDefinitionScenarioRelevance = new ApiDefinitionScenarioRelevance();
|
||||||
|
apiDefinitionScenarioRelevance.setReportId(result.getId());
|
||||||
|
apiDefinitionScenarioRelevanceMapper.insert(apiDefinitionScenarioRelevance);
|
||||||
}
|
}
|
||||||
return apiExecuteService.debug(request, bodyFiles);
|
return apiExecuteService.debug(request, bodyFiles);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,7 @@ import io.metersphere.base.mapper.*;
|
||||||
import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper;
|
import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper;
|
||||||
import io.metersphere.commons.constants.*;
|
import io.metersphere.commons.constants.*;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.DateUtils;
|
import io.metersphere.commons.utils.*;
|
||||||
import io.metersphere.commons.utils.ServiceUtils;
|
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
|
||||||
import io.metersphere.constants.RunModeConstants;
|
import io.metersphere.constants.RunModeConstants;
|
||||||
import io.metersphere.dto.*;
|
import io.metersphere.dto.*;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
|
@ -78,6 +76,9 @@ public class ApiScenarioReportService {
|
||||||
private ApiScenarioReportStructureMapper apiScenarioReportStructureMapper;
|
private ApiScenarioReportStructureMapper apiScenarioReportStructureMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiDefinitionExecResultMapper definitionExecResultMapper;
|
private ApiDefinitionExecResultMapper definitionExecResultMapper;
|
||||||
|
@Resource
|
||||||
|
private ApiDefinitionScenarioRelevanceMapper apiDefinitionScenarioRelevanceMapper;
|
||||||
|
|
||||||
|
|
||||||
public void saveResult(List<RequestResult> requestResults, ResultDTO dto) {
|
public void saveResult(List<RequestResult> requestResults, ResultDTO dto) {
|
||||||
// 报告详情内容
|
// 报告详情内容
|
||||||
|
@ -132,18 +133,97 @@ public class ApiScenarioReportService {
|
||||||
return reportResult;
|
return reportResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<APIScenarioReportResult> list(QueryAPIReportRequest request) {
|
public List<APIScenarioReportResult> list(int goPage,int pageSize,QueryAPIReportRequest request) {
|
||||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||||
|
request.setGoPage((goPage - 1) * pageSize/2);
|
||||||
|
request.setPageSize(pageSize);
|
||||||
List<APIScenarioReportResult> list = extApiScenarioReportMapper.list(request);
|
List<APIScenarioReportResult> list = extApiScenarioReportMapper.list(request);
|
||||||
List<String> userIds = list.stream().map(APIScenarioReportResult::getUserId)
|
List<APIScenarioReportResult> collect = new ArrayList<>();
|
||||||
|
Comparator<APIScenarioReportResult> comparing = null;
|
||||||
|
if(request.getOrders().size()==0){
|
||||||
|
collect = list;
|
||||||
|
} else if(request.getOrders().size()==1){
|
||||||
|
String name = request.getOrders().get(0).getName();
|
||||||
|
String type = request.getOrders().get(0).getType();
|
||||||
|
if(StringUtils.equals(name,"name")){
|
||||||
|
comparing = Comparator.comparing(APIScenarioReportResult::getName);
|
||||||
|
if(StringUtils.equals(type,"DESC")){
|
||||||
|
Comparator.comparing(APIScenarioReportResult::getName,Comparator.reverseOrder());
|
||||||
|
}
|
||||||
|
collect = getApiScenarioReportResults(pageSize,list,comparing);
|
||||||
|
}
|
||||||
|
if(StringUtils.equals(name,"create_time")){
|
||||||
|
comparing =Comparator.comparing(APIScenarioReportResult::getCreateTime);
|
||||||
|
if(StringUtils.equals(type,"DESC")){
|
||||||
|
comparing = Comparator.comparing(APIScenarioReportResult::getCreateTime,Comparator.reverseOrder());
|
||||||
|
}
|
||||||
|
collect = getApiScenarioReportResults(pageSize,list,comparing);
|
||||||
|
}
|
||||||
|
if(StringUtils.equals(name,"update_time")){
|
||||||
|
if(StringUtils.equals(type,"DESC")){
|
||||||
|
comparing = Comparator.comparing(APIScenarioReportResult::getUpdateTime,Comparator.reverseOrder());
|
||||||
|
}else {
|
||||||
|
comparing =Comparator.comparing(APIScenarioReportResult::getUpdateTime);
|
||||||
|
}
|
||||||
|
collect = getApiScenarioReportResults(pageSize,list,comparing);
|
||||||
|
}
|
||||||
|
if(StringUtils.equals(name,"end_time")){
|
||||||
|
comparing =Comparator.comparing(APIScenarioReportResult::getEndTime);
|
||||||
|
if(StringUtils.equals(type,"DESC")){
|
||||||
|
comparing = Comparator.comparing(APIScenarioReportResult::getEndTime,Comparator.reverseOrder());
|
||||||
|
}
|
||||||
|
collect = getApiScenarioReportResults(pageSize,list,comparing);
|
||||||
|
}
|
||||||
|
}else if(request.getOrders().size()>1){
|
||||||
|
for (int i = 1; i < request.getOrders().size(); i++) {
|
||||||
|
String name1 = request.getOrders().get(i).getName();
|
||||||
|
String type1 = request.getOrders().get(i).getType();
|
||||||
|
if(StringUtils.equals(name1,"name")){
|
||||||
|
if(StringUtils.equals(type1,"DESC")){
|
||||||
|
comparing.thenComparing(APIScenarioReportResult::getName,Comparator.reverseOrder());
|
||||||
|
}else{
|
||||||
|
comparing.thenComparing(APIScenarioReportResult::getName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(StringUtils.equals(name1,"update_time")){
|
||||||
|
if(StringUtils.equals(type1,"DESC")){
|
||||||
|
comparing.thenComparing(APIScenarioReportResult::getUpdateTime,Comparator.reverseOrder());
|
||||||
|
}else{
|
||||||
|
comparing.thenComparing(APIScenarioReportResult::getUpdateTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(StringUtils.equals(name1,"create_time")){
|
||||||
|
if(StringUtils.equals(type1,"DESC")){
|
||||||
|
comparing.thenComparing(APIScenarioReportResult::getCreateTime,Comparator.reverseOrder());
|
||||||
|
}else{
|
||||||
|
comparing.thenComparing(APIScenarioReportResult::getCreateTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(StringUtils.equals(name1,"end_time")){
|
||||||
|
if(StringUtils.equals(type1,"DESC")){
|
||||||
|
comparing.thenComparing(APIScenarioReportResult::getEndTime,Comparator.reverseOrder());
|
||||||
|
}else{
|
||||||
|
comparing.thenComparing(APIScenarioReportResult::getEndTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
collect = getApiScenarioReportResults(pageSize,list,comparing);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> userIds = collect.stream().map(APIScenarioReportResult::getUserId)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
Map<String, User> userMap = ServiceUtils.getUserMap(userIds);
|
Map<String, User> userMap = ServiceUtils.getUserMap(userIds);
|
||||||
list.forEach(item -> {
|
collect.forEach(item -> {
|
||||||
User user = userMap.get(item.getUserId());
|
User user = userMap.get(item.getUserId());
|
||||||
if (user != null)
|
if (user != null)
|
||||||
item.setUserName(user.getName());
|
item.setUserName(user.getName());
|
||||||
});
|
});
|
||||||
return list;
|
|
||||||
|
return collect;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<APIScenarioReportResult> getApiScenarioReportResults(int pageSize,List<APIScenarioReportResult> list, Comparator<APIScenarioReportResult> comparing) {
|
||||||
|
return list.stream().sorted(comparing).limit(pageSize/2).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> idList(QueryAPIReportRequest request) {
|
public List<String> idList(QueryAPIReportRequest request) {
|
||||||
|
@ -183,6 +263,9 @@ public class ApiScenarioReportService {
|
||||||
report.setTriggerMode(TriggerMode.MANUAL.name());
|
report.setTriggerMode(TriggerMode.MANUAL.name());
|
||||||
}
|
}
|
||||||
apiScenarioReportMapper.insert(report);
|
apiScenarioReportMapper.insert(report);
|
||||||
|
ApiDefinitionScenarioRelevance apiDefinitionScenarioRelevance = new ApiDefinitionScenarioRelevance();
|
||||||
|
apiDefinitionScenarioRelevance.setReportId(report.getId());
|
||||||
|
apiDefinitionScenarioRelevanceMapper.insert(apiDefinitionScenarioRelevance);
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,6 +559,13 @@ public class ApiScenarioReportService {
|
||||||
apiScenarioReportDetailMapper.deleteByPrimaryKey(request.getId());
|
apiScenarioReportDetailMapper.deleteByPrimaryKey(request.getId());
|
||||||
ApiScenarioReportResultExample example = new ApiScenarioReportResultExample();
|
ApiScenarioReportResultExample example = new ApiScenarioReportResultExample();
|
||||||
example.createCriteria().andReportIdEqualTo(request.getId());
|
example.createCriteria().andReportIdEqualTo(request.getId());
|
||||||
|
List<ApiScenarioReportResult> apiScenarioReportResults = apiScenarioReportResultMapper.selectByExample(example);
|
||||||
|
if(apiScenarioReportResults!=null&&apiScenarioReportResults.size()!=0){
|
||||||
|
List<String> reportIds = apiScenarioReportResults.stream().map(ApiScenarioReportResult::getId).collect(Collectors.toList());
|
||||||
|
ApiDefinitionScenarioRelevanceExample sexample = new ApiDefinitionScenarioRelevanceExample();
|
||||||
|
sexample.createCriteria().andReportIdIn(reportIds);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByExample(sexample);
|
||||||
|
}
|
||||||
apiScenarioReportResultMapper.deleteByExample(example);
|
apiScenarioReportResultMapper.deleteByExample(example);
|
||||||
|
|
||||||
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
|
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
|
||||||
|
@ -484,10 +574,18 @@ public class ApiScenarioReportService {
|
||||||
|
|
||||||
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
||||||
definitionExecResultExample.createCriteria().andIdEqualTo(request.getId());
|
definitionExecResultExample.createCriteria().andIdEqualTo(request.getId());
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByPrimaryKey(request.getId());
|
||||||
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
||||||
|
|
||||||
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
||||||
execResultExample.createCriteria().andIntegratedReportIdEqualTo(request.getId());
|
execResultExample.createCriteria().andIntegratedReportIdEqualTo(request.getId());
|
||||||
|
List<ApiDefinitionExecResult> apiDefinitionExecResults = definitionExecResultMapper.selectByExample(execResultExample);
|
||||||
|
if(apiDefinitionExecResults!=null&&apiDefinitionExecResults.size()!=0){
|
||||||
|
List<String> reportIds = apiDefinitionExecResults.stream().map(ApiDefinitionExecResult::getId).collect(Collectors.toList());
|
||||||
|
ApiDefinitionScenarioRelevanceExample sexample = new ApiDefinitionScenarioRelevanceExample();
|
||||||
|
sexample.createCriteria().andReportIdIn(reportIds);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByExample(sexample);
|
||||||
|
}
|
||||||
definitionExecResultMapper.deleteByExample(execResultExample);
|
definitionExecResultMapper.deleteByExample(execResultExample);
|
||||||
|
|
||||||
// 补充逻辑,如果是集成报告则把零时报告全部删除
|
// 补充逻辑,如果是集成报告则把零时报告全部删除
|
||||||
|
@ -508,6 +606,13 @@ public class ApiScenarioReportService {
|
||||||
apiScenarioReportMapper.deleteByPrimaryKey(id);
|
apiScenarioReportMapper.deleteByPrimaryKey(id);
|
||||||
ApiScenarioReportResultExample example = new ApiScenarioReportResultExample();
|
ApiScenarioReportResultExample example = new ApiScenarioReportResultExample();
|
||||||
example.createCriteria().andReportIdEqualTo(id);
|
example.createCriteria().andReportIdEqualTo(id);
|
||||||
|
List<ApiScenarioReportResult> apiScenarioReportResults = apiScenarioReportResultMapper.selectByExample(example);
|
||||||
|
if(apiScenarioReportResults!=null&&apiScenarioReportResults.size()!=0){
|
||||||
|
List<String> reportIds = apiScenarioReportResults.stream().map(ApiScenarioReportResult::getId).collect(Collectors.toList());
|
||||||
|
ApiDefinitionScenarioRelevanceExample sexample = new ApiDefinitionScenarioRelevanceExample();
|
||||||
|
sexample.createCriteria().andReportIdIn(reportIds);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByExample(sexample);
|
||||||
|
}
|
||||||
apiScenarioReportResultMapper.deleteByExample(example);
|
apiScenarioReportResultMapper.deleteByExample(example);
|
||||||
|
|
||||||
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
|
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
|
||||||
|
@ -517,9 +622,17 @@ public class ApiScenarioReportService {
|
||||||
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
||||||
definitionExecResultExample.createCriteria().andIdEqualTo(id);
|
definitionExecResultExample.createCriteria().andIdEqualTo(id);
|
||||||
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByPrimaryKey(id);
|
||||||
|
|
||||||
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
||||||
execResultExample.createCriteria().andIntegratedReportIdEqualTo(id);
|
execResultExample.createCriteria().andIntegratedReportIdEqualTo(id);
|
||||||
|
List<ApiDefinitionExecResult> apiDefinitionExecResults = definitionExecResultMapper.selectByExample(execResultExample);
|
||||||
|
if(apiDefinitionExecResults!=null&&apiDefinitionExecResults.size()!=0){
|
||||||
|
List<String> ids = apiDefinitionExecResults.stream().map(ApiDefinitionExecResult::getId).collect(Collectors.toList());
|
||||||
|
ApiDefinitionScenarioRelevanceExample sexample = new ApiDefinitionScenarioRelevanceExample();
|
||||||
|
sexample.createCriteria().andReportIdIn(ids);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByExample(sexample);
|
||||||
|
}
|
||||||
definitionExecResultMapper.deleteByExample(execResultExample);
|
definitionExecResultMapper.deleteByExample(execResultExample);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -535,6 +648,13 @@ public class ApiScenarioReportService {
|
||||||
|
|
||||||
ApiScenarioReportResultExample reportResultExample = new ApiScenarioReportResultExample();
|
ApiScenarioReportResultExample reportResultExample = new ApiScenarioReportResultExample();
|
||||||
reportResultExample.createCriteria().andReportIdIn(ids);
|
reportResultExample.createCriteria().andReportIdIn(ids);
|
||||||
|
List<ApiScenarioReportResult> apiScenarioReportResults = apiScenarioReportResultMapper.selectByExample(reportResultExample);
|
||||||
|
if(apiScenarioReportResults!=null&&apiScenarioReportResults.size()!=0){
|
||||||
|
List<String> reportIds = apiScenarioReportResults.stream().map(ApiScenarioReportResult::getId).collect(Collectors.toList());
|
||||||
|
ApiDefinitionScenarioRelevanceExample sexample = new ApiDefinitionScenarioRelevanceExample();
|
||||||
|
sexample.createCriteria().andReportIdIn(reportIds);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByExample(sexample);
|
||||||
|
}
|
||||||
apiScenarioReportResultMapper.deleteByExample(reportResultExample);
|
apiScenarioReportResultMapper.deleteByExample(reportResultExample);
|
||||||
|
|
||||||
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
|
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
|
||||||
|
@ -543,10 +663,20 @@ public class ApiScenarioReportService {
|
||||||
|
|
||||||
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
||||||
definitionExecResultExample.createCriteria().andIdIn(ids);
|
definitionExecResultExample.createCriteria().andIdIn(ids);
|
||||||
|
ApiDefinitionScenarioRelevanceExample sexample = new ApiDefinitionScenarioRelevanceExample();
|
||||||
|
sexample.createCriteria().andReportIdIn(ids);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByExample(sexample);
|
||||||
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
||||||
|
|
||||||
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
||||||
execResultExample.createCriteria().andIntegratedReportIdIn(ids);
|
execResultExample.createCriteria().andIntegratedReportIdIn(ids);
|
||||||
|
List<ApiDefinitionExecResult> apiDefinitionExecResultList = definitionExecResultMapper.selectByExample(execResultExample);
|
||||||
|
if(apiDefinitionExecResultList!=null&&apiDefinitionExecResultList.size()!=0){
|
||||||
|
List<String> reportIds = apiDefinitionExecResultList.stream().map(ApiDefinitionExecResult::getId).collect(Collectors.toList());
|
||||||
|
ApiDefinitionScenarioRelevanceExample asexample = new ApiDefinitionScenarioRelevanceExample();
|
||||||
|
asexample.createCriteria().andReportIdIn(reportIds);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByExample(asexample);
|
||||||
|
}
|
||||||
definitionExecResultMapper.deleteByExample(execResultExample);
|
definitionExecResultMapper.deleteByExample(execResultExample);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -596,6 +726,13 @@ public class ApiScenarioReportService {
|
||||||
|
|
||||||
ApiScenarioReportResultExample reportResultExample = new ApiScenarioReportResultExample();
|
ApiScenarioReportResultExample reportResultExample = new ApiScenarioReportResultExample();
|
||||||
reportResultExample.createCriteria().andReportIdIn(handleIdList);
|
reportResultExample.createCriteria().andReportIdIn(handleIdList);
|
||||||
|
List<ApiScenarioReportResult> apiScenarioReportResults = apiScenarioReportResultMapper.selectByExample(reportResultExample);
|
||||||
|
if(apiScenarioReportResults!=null&&apiScenarioReportResults.size()!=0){
|
||||||
|
List<String> reportIds = apiScenarioReportResults.stream().map(ApiScenarioReportResult::getId).collect(Collectors.toList());
|
||||||
|
ApiDefinitionScenarioRelevanceExample sexample = new ApiDefinitionScenarioRelevanceExample();
|
||||||
|
sexample.createCriteria().andReportIdIn(reportIds);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByExample(sexample);
|
||||||
|
}
|
||||||
apiScenarioReportResultMapper.deleteByExample(reportResultExample);
|
apiScenarioReportResultMapper.deleteByExample(reportResultExample);
|
||||||
|
|
||||||
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
|
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
|
||||||
|
@ -604,10 +741,20 @@ public class ApiScenarioReportService {
|
||||||
|
|
||||||
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
||||||
definitionExecResultExample.createCriteria().andIdIn(handleIdList);
|
definitionExecResultExample.createCriteria().andIdIn(handleIdList);
|
||||||
|
ApiDefinitionScenarioRelevanceExample sexample = new ApiDefinitionScenarioRelevanceExample();
|
||||||
|
sexample.createCriteria().andReportIdIn(handleIdList);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByExample(sexample);
|
||||||
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
||||||
|
|
||||||
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
||||||
execResultExample.createCriteria().andIntegratedReportIdIn(handleIdList);
|
execResultExample.createCriteria().andIntegratedReportIdIn(handleIdList);
|
||||||
|
List<ApiDefinitionExecResult> apiDefinitionExecResults = definitionExecResultMapper.selectByExample(execResultExample);
|
||||||
|
if(apiDefinitionExecResults!=null&&apiDefinitionExecResults.size()!=0){
|
||||||
|
List<String> reportIds = apiDefinitionExecResults.stream().map(ApiDefinitionExecResult::getId).collect(Collectors.toList());
|
||||||
|
ApiDefinitionScenarioRelevanceExample asexample = new ApiDefinitionScenarioRelevanceExample();
|
||||||
|
asexample.createCriteria().andReportIdIn(reportIds);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByExample(asexample);
|
||||||
|
}
|
||||||
definitionExecResultMapper.deleteByExample(execResultExample);
|
definitionExecResultMapper.deleteByExample(execResultExample);
|
||||||
|
|
||||||
//转存剩余的数据
|
//转存剩余的数据
|
||||||
|
@ -625,6 +772,13 @@ public class ApiScenarioReportService {
|
||||||
|
|
||||||
ApiScenarioReportResultExample reportResultExample = new ApiScenarioReportResultExample();
|
ApiScenarioReportResultExample reportResultExample = new ApiScenarioReportResultExample();
|
||||||
reportResultExample.createCriteria().andReportIdIn(ids);
|
reportResultExample.createCriteria().andReportIdIn(ids);
|
||||||
|
List<ApiScenarioReportResult> apiScenarioReportResults = apiScenarioReportResultMapper.selectByExample(reportResultExample);
|
||||||
|
if(apiScenarioReportResults!=null&&apiScenarioReportResults.size()!=0){
|
||||||
|
List<String> reportIds = apiScenarioReportResults.stream().map(ApiScenarioReportResult::getId).collect(Collectors.toList());
|
||||||
|
ApiDefinitionScenarioRelevanceExample sexample = new ApiDefinitionScenarioRelevanceExample();
|
||||||
|
sexample.createCriteria().andReportIdIn(reportIds);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByExample(sexample);
|
||||||
|
}
|
||||||
apiScenarioReportResultMapper.deleteByExample(reportResultExample);
|
apiScenarioReportResultMapper.deleteByExample(reportResultExample);
|
||||||
|
|
||||||
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
|
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
|
||||||
|
@ -633,10 +787,20 @@ public class ApiScenarioReportService {
|
||||||
|
|
||||||
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
||||||
definitionExecResultExample.createCriteria().andIdIn(ids);
|
definitionExecResultExample.createCriteria().andIdIn(ids);
|
||||||
|
ApiDefinitionScenarioRelevanceExample sexample = new ApiDefinitionScenarioRelevanceExample();
|
||||||
|
sexample.createCriteria().andReportIdIn(ids);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByExample(sexample);
|
||||||
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
||||||
|
|
||||||
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
||||||
execResultExample.createCriteria().andIntegratedReportIdIn(ids);
|
execResultExample.createCriteria().andIntegratedReportIdIn(ids);
|
||||||
|
List<ApiDefinitionExecResult> apiDefinitionExecResults = definitionExecResultMapper.selectByExample(execResultExample);
|
||||||
|
if(apiDefinitionExecResults!=null&&apiDefinitionExecResults.size()!=0){
|
||||||
|
List<String> reportIds = apiDefinitionExecResults.stream().map(ApiDefinitionExecResult::getId).collect(Collectors.toList());
|
||||||
|
ApiDefinitionScenarioRelevanceExample asexample = new ApiDefinitionScenarioRelevanceExample();
|
||||||
|
asexample.createCriteria().andReportIdIn(reportIds);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByExample(asexample);
|
||||||
|
}
|
||||||
definitionExecResultMapper.deleteByExample(execResultExample);
|
definitionExecResultMapper.deleteByExample(execResultExample);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,9 @@ public class ApiTestCaseService {
|
||||||
private ExtProjectVersionMapper extProjectVersionMapper;
|
private ExtProjectVersionMapper extProjectVersionMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private TcpApiParamService tcpApiParamService;
|
private TcpApiParamService tcpApiParamService;
|
||||||
|
@Resource
|
||||||
|
private ApiDefinitionScenarioRelevanceMapper apiDefinitionScenarioRelevanceMapper;
|
||||||
|
|
||||||
|
|
||||||
private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR;
|
private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR;
|
||||||
|
|
||||||
|
@ -257,6 +260,8 @@ public class ApiTestCaseService {
|
||||||
public void delete(String testId) {
|
public void delete(String testId) {
|
||||||
extTestPlanTestCaseMapper.deleteByTestCaseID(testId);
|
extTestPlanTestCaseMapper.deleteByTestCaseID(testId);
|
||||||
deleteFileByTestId(testId);
|
deleteFileByTestId(testId);
|
||||||
|
ApiDefinitionExecResult result = extApiDefinitionExecResultMapper.selectMaxResultByResourceId(testId);
|
||||||
|
apiDefinitionScenarioRelevanceMapper.deleteByPrimaryKey(result.getId());
|
||||||
extApiDefinitionExecResultMapper.deleteByResourceId(testId);
|
extApiDefinitionExecResultMapper.deleteByResourceId(testId);
|
||||||
apiTestCaseMapper.deleteByPrimaryKey(testId);
|
apiTestCaseMapper.deleteByPrimaryKey(testId);
|
||||||
esbApiParamService.deleteByResourceId(testId);
|
esbApiParamService.deleteByResourceId(testId);
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package io.metersphere.base.domain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApiDefinitionScenarioRelevance implements Serializable {
|
||||||
|
private String reportId;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
|
@ -0,0 +1,270 @@
|
||||||
|
package io.metersphere.base.domain;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ApiDefinitionScenarioRelevanceExample {
|
||||||
|
protected String orderByClause;
|
||||||
|
|
||||||
|
protected boolean distinct;
|
||||||
|
|
||||||
|
protected List<Criteria> oredCriteria;
|
||||||
|
|
||||||
|
public ApiDefinitionScenarioRelevanceExample() {
|
||||||
|
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 andReportIdIsNull() {
|
||||||
|
addCriterion("report_id is null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andReportIdIsNotNull() {
|
||||||
|
addCriterion("report_id is not null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andReportIdEqualTo(String value) {
|
||||||
|
addCriterion("report_id =", value, "reportId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andReportIdNotEqualTo(String value) {
|
||||||
|
addCriterion("report_id <>", value, "reportId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andReportIdGreaterThan(String value) {
|
||||||
|
addCriterion("report_id >", value, "reportId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andReportIdGreaterThanOrEqualTo(String value) {
|
||||||
|
addCriterion("report_id >=", value, "reportId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andReportIdLessThan(String value) {
|
||||||
|
addCriterion("report_id <", value, "reportId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andReportIdLessThanOrEqualTo(String value) {
|
||||||
|
addCriterion("report_id <=", value, "reportId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andReportIdLike(String value) {
|
||||||
|
addCriterion("report_id like", value, "reportId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andReportIdNotLike(String value) {
|
||||||
|
addCriterion("report_id not like", value, "reportId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andReportIdIn(List<String> values) {
|
||||||
|
addCriterion("report_id in", values, "reportId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andReportIdNotIn(List<String> values) {
|
||||||
|
addCriterion("report_id not in", values, "reportId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andReportIdBetween(String value1, String value2) {
|
||||||
|
addCriterion("report_id between", value1, value2, "reportId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andReportIdNotBetween(String value1, String value2) {
|
||||||
|
addCriterion("report_id not between", value1, value2, "reportId");
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package io.metersphere.base.mapper;
|
||||||
|
|
||||||
|
import io.metersphere.base.domain.ApiDefinitionScenarioRelevance;
|
||||||
|
import io.metersphere.base.domain.ApiDefinitionScenarioRelevanceExample;
|
||||||
|
import java.util.List;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
public interface ApiDefinitionScenarioRelevanceMapper {
|
||||||
|
long countByExample(ApiDefinitionScenarioRelevanceExample example);
|
||||||
|
|
||||||
|
int deleteByExample(ApiDefinitionScenarioRelevanceExample example);
|
||||||
|
|
||||||
|
int deleteByPrimaryKey(String reportId);
|
||||||
|
|
||||||
|
int insert(ApiDefinitionScenarioRelevance record);
|
||||||
|
|
||||||
|
int insertSelective(ApiDefinitionScenarioRelevance record);
|
||||||
|
|
||||||
|
List<ApiDefinitionScenarioRelevance> selectByExample(ApiDefinitionScenarioRelevanceExample example);
|
||||||
|
|
||||||
|
int updateByExampleSelective(@Param("record") ApiDefinitionScenarioRelevance record, @Param("example") ApiDefinitionScenarioRelevanceExample example);
|
||||||
|
|
||||||
|
int updateByExample(@Param("record") ApiDefinitionScenarioRelevance record, @Param("example") ApiDefinitionScenarioRelevanceExample example);
|
||||||
|
}
|
|
@ -0,0 +1,133 @@
|
||||||
|
<?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.ApiDefinitionScenarioRelevanceMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.ApiDefinitionScenarioRelevance">
|
||||||
|
<id column="report_id" jdbcType="VARCHAR" property="reportId" />
|
||||||
|
</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">
|
||||||
|
report_id
|
||||||
|
</sql>
|
||||||
|
<select id="selectByExample" parameterType="io.metersphere.base.domain.ApiDefinitionScenarioRelevanceExample" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<if test="distinct">
|
||||||
|
distinct
|
||||||
|
</if>
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from api_definition_scenario_relevance
|
||||||
|
<if test="_parameter != null">
|
||||||
|
<include refid="Example_Where_Clause" />
|
||||||
|
</if>
|
||||||
|
<if test="orderByClause != null">
|
||||||
|
order by ${orderByClause}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||||
|
delete from api_definition_scenario_relevance
|
||||||
|
where report_id = #{reportId,jdbcType=VARCHAR}
|
||||||
|
</delete>
|
||||||
|
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.ApiDefinitionScenarioRelevanceExample">
|
||||||
|
delete from api_definition_scenario_relevance
|
||||||
|
<if test="_parameter != null">
|
||||||
|
<include refid="Example_Where_Clause" />
|
||||||
|
</if>
|
||||||
|
</delete>
|
||||||
|
<insert id="insert" parameterType="io.metersphere.base.domain.ApiDefinitionScenarioRelevance">
|
||||||
|
insert into api_definition_scenario_relevance (report_id)
|
||||||
|
values (#{reportId,jdbcType=VARCHAR})
|
||||||
|
</insert>
|
||||||
|
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiDefinitionScenarioRelevance">
|
||||||
|
insert into api_definition_scenario_relevance
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="reportId != null">
|
||||||
|
report_id,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="reportId != null">
|
||||||
|
#{reportId,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<select id="countByExample" parameterType="io.metersphere.base.domain.ApiDefinitionScenarioRelevanceExample" resultType="java.lang.Long">
|
||||||
|
select count(*) from api_definition_scenario_relevance
|
||||||
|
<if test="_parameter != null">
|
||||||
|
<include refid="Example_Where_Clause" />
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
<update id="updateByExampleSelective" parameterType="map">
|
||||||
|
update api_definition_scenario_relevance
|
||||||
|
<set>
|
||||||
|
<if test="record.reportId != null">
|
||||||
|
report_id = #{record.reportId,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
<if test="_parameter != null">
|
||||||
|
<include refid="Update_By_Example_Where_Clause" />
|
||||||
|
</if>
|
||||||
|
</update>
|
||||||
|
<update id="updateByExample" parameterType="map">
|
||||||
|
update api_definition_scenario_relevance
|
||||||
|
set report_id = #{record.reportId,jdbcType=VARCHAR}
|
||||||
|
<if test="_parameter != null">
|
||||||
|
<include refid="Update_By_Example_Where_Clause" />
|
||||||
|
</if>
|
||||||
|
</update>
|
||||||
|
</mapper>
|
|
@ -1,5 +1,6 @@
|
||||||
package io.metersphere.base.mapper.ext;
|
package io.metersphere.base.mapper.ext;
|
||||||
|
|
||||||
|
import io.metersphere.api.dto.QueryAPIReportRequest;
|
||||||
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 io.metersphere.track.dto.PlanReportCaseDTO;
|
import io.metersphere.track.dto.PlanReportCaseDTO;
|
||||||
|
@ -32,6 +33,8 @@ public interface ExtApiDefinitionExecResultMapper {
|
||||||
|
|
||||||
List<ApiDefinitionExecResult> selectApiResultByProjectId(String projectId);
|
List<ApiDefinitionExecResult> selectApiResultByProjectId(String projectId);
|
||||||
|
|
||||||
|
long selectCountByRequest(@Param("request") QueryAPIReportRequest request);
|
||||||
|
|
||||||
List<PlanReportCaseDTO> selectForPlanReport(@Param("ids") List<String> apiReportIds);
|
List<PlanReportCaseDTO> selectForPlanReport(@Param("ids") List<String> apiReportIds);
|
||||||
|
|
||||||
void update(@Param("ids") List<String> ids);
|
void update(@Param("ids") List<String> ids);
|
||||||
|
|
|
@ -122,6 +122,139 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectCountByRequest" resultType="java.lang.Long">
|
||||||
|
select
|
||||||
|
count(*)
|
||||||
|
from api_definition_exec_result a_r
|
||||||
|
FORCE INDEX(PRIMARY)
|
||||||
|
where (a_r.integrated_report_id is null or a_r.integrated_report_id = 'null')
|
||||||
|
<if test="request.combine != null">
|
||||||
|
<include refid="listCombine">
|
||||||
|
<property name="condition" value="request.combine"/>
|
||||||
|
<property name="name" value="request.name"/>
|
||||||
|
</include>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="request.name != null">
|
||||||
|
and a_r.name like CONCAT('%', #{request.name},'%')
|
||||||
|
</if>
|
||||||
|
<if test="request.userId != null">
|
||||||
|
AND a_r.user_id = #{request.userId,jdbcType=VARCHAR}
|
||||||
|
</if>
|
||||||
|
<if test="request.projectId != null">
|
||||||
|
AND a_r.project_id = #{request.projectId}
|
||||||
|
</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=='status'">
|
||||||
|
and a_r.status in
|
||||||
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
|
#{value}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
<when test="key=='trigger_mode'">
|
||||||
|
and a_r.trigger_mode 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">
|
||||||
|
${order.name} ${order.type}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<sql id="condition">
|
||||||
|
<choose>
|
||||||
|
<when test='${object}.operator == "like"'>
|
||||||
|
like CONCAT('%', #{${object}.value},'%')
|
||||||
|
</when>
|
||||||
|
<when test='${object}.operator == "not like"'>
|
||||||
|
not like CONCAT('%', #{${object}.value},'%')
|
||||||
|
</when>
|
||||||
|
<when test='${object}.operator == "in"'>
|
||||||
|
in
|
||||||
|
<foreach collection="${object}.value" item="v" separator="," open="(" close=")">
|
||||||
|
#{v}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
<when test='${object}.operator == "not in"'>
|
||||||
|
not in
|
||||||
|
<foreach collection="${object}.value" item="v" separator="," open="(" close=")">
|
||||||
|
#{v}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
<when test='${object}.operator == "between"'>
|
||||||
|
between #{${object}.value[0]} and #{${object}.value[1]}
|
||||||
|
</when>
|
||||||
|
<when test='${object}.operator == "gt"'>
|
||||||
|
> #{${object}.value}
|
||||||
|
</when>
|
||||||
|
<when test='${object}.operator == "lt"'>
|
||||||
|
< #{${object}.value}
|
||||||
|
</when>
|
||||||
|
<when test='${object}.operator == "ge"'>
|
||||||
|
>= #{${object}.value}
|
||||||
|
</when>
|
||||||
|
<when test='${object}.operator == "le"'>
|
||||||
|
<= #{${object}.value}
|
||||||
|
</when>
|
||||||
|
<when test='${object}.operator == "current user"'>
|
||||||
|
= '${@io.metersphere.commons.utils.SessionUtils@getUserId()}'
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
= #{${object}.value}
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<sql id="listCombine">
|
||||||
|
<if test='${condition}.name != null and (${name} == null or ${name} == "")'>
|
||||||
|
and `name`
|
||||||
|
<include refid="condition">
|
||||||
|
<property name="object" value="${condition}.name"/>
|
||||||
|
</include>
|
||||||
|
</if>
|
||||||
|
<if test="${condition}.testName != null">
|
||||||
|
and `name`
|
||||||
|
<include refid="condition">
|
||||||
|
<property name="object" value="${condition}.testName"/>
|
||||||
|
</include>
|
||||||
|
</if>
|
||||||
|
<if test="${condition}.createTime != null">
|
||||||
|
and create_time
|
||||||
|
<include refid="condition">
|
||||||
|
<property name="object" value="${condition}.createTime"/>
|
||||||
|
</include>
|
||||||
|
</if>
|
||||||
|
<if test="${condition}.status != null">
|
||||||
|
and status
|
||||||
|
<include refid="condition">
|
||||||
|
<property name="object" value="${condition}.status"/>
|
||||||
|
</include>
|
||||||
|
</if>
|
||||||
|
<if test="${condition}.triggerMode != null">
|
||||||
|
and trigger_mode
|
||||||
|
<include refid="condition">
|
||||||
|
<property name="object" value="${condition}.triggerMode"/>
|
||||||
|
</include>
|
||||||
|
</if>
|
||||||
|
<if test="${condition}.creator != null">
|
||||||
|
and user_id
|
||||||
|
<include refid="condition">
|
||||||
|
<property name="object" value="${condition}.creator"/>
|
||||||
|
</include>
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
|
|
||||||
<update id="update" parameterType="java.util.List">
|
<update id="update" parameterType="java.util.List">
|
||||||
update api_definition_exec_result set status="STOP" where id in
|
update api_definition_exec_result set status="STOP" where id in
|
||||||
<foreach collection="ids" item="value" separator="," open="(" close=")">
|
<foreach collection="ids" item="value" separator="," open="(" close=")">
|
||||||
|
|
|
@ -6,11 +6,21 @@ import java.util.List;
|
||||||
|
|
||||||
public class ExtApiDefinitionExecResultProvider {
|
public class ExtApiDefinitionExecResultProvider {
|
||||||
public String insertListSql(List<ApiDefinitionExecResult> list) {
|
public String insertListSql(List<ApiDefinitionExecResult> list) {
|
||||||
|
StringBuffer rsqlList = new StringBuffer();
|
||||||
|
rsqlList.append(";").append("insert into api_definition_scenario_relevance ( report_id ) values ");
|
||||||
StringBuffer sqlList = new StringBuffer();
|
StringBuffer sqlList = new StringBuffer();
|
||||||
sqlList.append("insert into api_definition_exec_result (id, `name`, resource_id, `status`, user_id, start_time, end_time," +
|
sqlList.append("insert into api_definition_exec_result (id, `name`, resource_id, `status`, user_id, start_time, end_time," +
|
||||||
" create_time, `type`, actuator, trigger_mode, version_id, error_code,project_id,integrated_report_id, content) values ");
|
" create_time, `type`, actuator, trigger_mode, version_id, error_code,project_id,integrated_report_id, content) values ");
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
ApiDefinitionExecResult result = list.get(i);
|
ApiDefinitionExecResult result = list.get(i);
|
||||||
|
rsqlList.append(" (")
|
||||||
|
.append("'")
|
||||||
|
.append(result.getId())
|
||||||
|
.append("'")
|
||||||
|
.append(")");
|
||||||
|
if (i < list.size() - 1) {
|
||||||
|
rsqlList.append(",");
|
||||||
|
}
|
||||||
sqlList.append(" (")
|
sqlList.append(" (")
|
||||||
.append("'")
|
.append("'")
|
||||||
.append(result.getId())
|
.append(result.getId())
|
||||||
|
@ -50,6 +60,9 @@ public class ExtApiDefinitionExecResultProvider {
|
||||||
sqlList.append(",");
|
sqlList.append(",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rsqlList.append(";");
|
||||||
|
sqlList.append(";");
|
||||||
|
sqlList.append(rsqlList);
|
||||||
return sqlList.toString();
|
return sqlList.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,13 @@ package io.metersphere.base.mapper.ext;
|
||||||
import io.metersphere.api.dto.QueryAPIReportRequest;
|
import io.metersphere.api.dto.QueryAPIReportRequest;
|
||||||
import io.metersphere.api.dto.automation.APIScenarioReportResult;
|
import io.metersphere.api.dto.automation.APIScenarioReportResult;
|
||||||
import io.metersphere.api.dto.datacount.ApiDataCountResult;
|
import io.metersphere.api.dto.datacount.ApiDataCountResult;
|
||||||
|
import io.metersphere.base.domain.ApiDefinitionExecResult;
|
||||||
import io.metersphere.base.domain.ApiScenarioReport;
|
import io.metersphere.base.domain.ApiScenarioReport;
|
||||||
import io.metersphere.dto.ApiReportCountDTO;
|
import io.metersphere.dto.ApiReportCountDTO;
|
||||||
import io.metersphere.track.dto.PlanReportCaseDTO;
|
import io.metersphere.track.dto.PlanReportCaseDTO;
|
||||||
import org.apache.ibatis.annotations.InsertProvider;
|
import org.apache.ibatis.annotations.InsertProvider;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.SelectProvider;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -41,7 +43,10 @@ public interface ExtApiScenarioReportMapper {
|
||||||
|
|
||||||
void update(@Param("ids") List<String> ids);
|
void update(@Param("ids") List<String> ids);
|
||||||
|
|
||||||
|
long selectCountByRequest(@Param("request") QueryAPIReportRequest request);
|
||||||
|
|
||||||
@InsertProvider(type = ExtApiScenarioReportProvider.class, method = "insertListSql")
|
@InsertProvider(type = ExtApiScenarioReportProvider.class, method = "insertListSql")
|
||||||
void sqlInsert(List<APIScenarioReportResult> list);
|
void sqlInsert(List<APIScenarioReportResult> list);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,20 +138,29 @@
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="list" resultMap="BaseResultMap">
|
<select id="list" resultMap="BaseResultMap">
|
||||||
select * from (
|
select if(a_s_r.id is null, a_d_r.id,a_s_r.id) as id ,if(a_s_r.id is null, a_d_r.name,a_s_r.name) as name ,if(a_s_r.id is null, a_d_r.end_time,a_s_r.end_time) as end_time ,
|
||||||
SELECT s_r.name AS test_name,
|
if(a_s_r.id is null, a_d_r.user_id,a_s_r.user_id) as user_id ,
|
||||||
s_r.end_time,
|
if(a_s_r.id is null, a_d_r.project_id,a_s_r.project_id) as project_id ,
|
||||||
s_r.user_id,
|
if(a_s_r.id is null, a_d_r.create_time,a_s_r.create_time) as create_time ,
|
||||||
s_r.name,
|
if(a_s_r.id is null, a_d_r.update_time,a_s_r.update_time) as update_time ,
|
||||||
s_r.id,
|
if(a_s_r.id is null, a_d_r.status,a_s_r.status) as status ,
|
||||||
s_r.project_id,
|
if(a_s_r.id is null, a_d_r.trigger_mode,a_s_r.trigger_mode) as trigger_mode ,
|
||||||
s_r.create_time,
|
if(a_s_r.id is null, a_d_r.execute_type,a_s_r.execute_type) as execute_type ,
|
||||||
s_r.update_time,
|
if(a_s_r.id is null, a_d_r.report_type,a_s_r.report_type) as report_type from api_definition_scenario_relevance d_s_r
|
||||||
s_r.status,
|
left join (
|
||||||
s_r.trigger_mode,
|
SELECT
|
||||||
s_r.execute_type,
|
s_r.end_time,
|
||||||
s_r.report_type
|
s_r.user_id,
|
||||||
FROM api_scenario_report s_r
|
s_r.name,
|
||||||
|
s_r.id,
|
||||||
|
s_r.project_id,
|
||||||
|
s_r.create_time,
|
||||||
|
s_r.update_time,
|
||||||
|
s_r.status,
|
||||||
|
s_r.trigger_mode,
|
||||||
|
s_r.execute_type,
|
||||||
|
s_r.report_type
|
||||||
|
FROM api_scenario_report s_r
|
||||||
<where>
|
<where>
|
||||||
<if test="request.combine != null">
|
<if test="request.combine != null">
|
||||||
<include refid="listCombine">
|
<include refid="listCombine">
|
||||||
|
@ -196,9 +205,15 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
AND s_r.execute_type = 'Saved'
|
AND s_r.execute_type = 'Saved'
|
||||||
</where>
|
<if test="request.orders != null and request.orders.size() > 0">
|
||||||
union all
|
order by
|
||||||
select a_r.name as test_name,
|
<foreach collection="request.orders" separator="," item="order">
|
||||||
|
s_r.${order.name} ${order.type}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>) a_s_r on d_s_r.report_id = a_s_r.id
|
||||||
|
left join
|
||||||
|
( select
|
||||||
a_r.end_time,
|
a_r.end_time,
|
||||||
a_r.user_id,
|
a_r.user_id,
|
||||||
a_r.name,
|
a_r.name,
|
||||||
|
@ -248,47 +263,87 @@
|
||||||
</if>
|
</if>
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
) r
|
|
||||||
where 1 = 1
|
|
||||||
<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=='report_type'">
|
|
||||||
and r.report_type 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">
|
<if test="request.orders != null and request.orders.size() > 0">
|
||||||
order by
|
order by
|
||||||
<foreach collection="request.orders" separator="," item="order">
|
<foreach collection="request.orders" separator="," item="order">
|
||||||
r.${order.name} ${order.type}
|
${order.name} ${order.type}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
) a_d_r on d_s_r.report_id = a_d_r.id
|
||||||
|
<if test="request.goPage != null and request.pageSize != null">
|
||||||
|
limit #{request.goPage},#{request.pageSize}
|
||||||
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="idList" resultType="java.lang.String">
|
<select id="idList" resultType="java.lang.String">
|
||||||
select r.id from (
|
select if(s_r.id is null, a_r.id,s_r.id) as id from api_definition_scenario_relevance d_s_r
|
||||||
SELECT s_r.name AS test_name,
|
left join (
|
||||||
s_r.end_time,
|
SELECT
|
||||||
s_r.user_id,
|
s_r.end_time,
|
||||||
s_r.name,
|
s_r.user_id,
|
||||||
s_r.id,
|
s_r.name,
|
||||||
s_r.project_id,
|
s_r.id,
|
||||||
s_r.create_time,
|
s_r.project_id,
|
||||||
s_r.update_time,
|
s_r.create_time,
|
||||||
s_r.status,
|
s_r.update_time,
|
||||||
s_r.trigger_mode,
|
s_r.status,
|
||||||
s_r.execute_type,
|
s_r.trigger_mode,
|
||||||
s_r.report_type
|
s_r.execute_type,
|
||||||
|
s_r.report_type
|
||||||
FROM api_scenario_report s_r
|
FROM api_scenario_report s_r
|
||||||
union all
|
<where>
|
||||||
select a_r.name as test_name,
|
<if test="request.combine != null">
|
||||||
|
<include refid="listCombine">
|
||||||
|
<property name="condition" value="request.combine"/>
|
||||||
|
<property name="name" value="request.name"/>
|
||||||
|
</include>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="request.name != null">
|
||||||
|
and s_r.name like CONCAT('%', #{request.name},'%')
|
||||||
|
</if>
|
||||||
|
<if test="request.userId != null">
|
||||||
|
AND s_r.user_id = #{request.userId,jdbcType=VARCHAR}
|
||||||
|
</if>
|
||||||
|
<if test="request.projectId != null">
|
||||||
|
AND s_r.project_id = #{request.projectId}
|
||||||
|
</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=='status'">
|
||||||
|
and s_r.status in
|
||||||
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
|
#{value}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
<when test="key=='report_type'">
|
||||||
|
and s_r.report_type in
|
||||||
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
|
#{value}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
and s_r.trigger_mode in
|
||||||
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
|
#{value}
|
||||||
|
</foreach>
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</if>
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
AND s_r.execute_type = 'Saved'
|
||||||
|
<if test="request.orders != null and request.orders.size() > 0">
|
||||||
|
order by
|
||||||
|
<foreach collection="request.orders" separator="," item="order">
|
||||||
|
s_r.${order.name} ${order.type}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>) s_r on d_s_r.report_id = s_r.id
|
||||||
|
left join(
|
||||||
|
select
|
||||||
a_r.end_time,
|
a_r.end_time,
|
||||||
a_r.user_id,
|
a_r.user_id,
|
||||||
a_r.name,
|
a_r.name,
|
||||||
|
@ -301,59 +356,50 @@
|
||||||
'Saved' as execute_type,
|
'Saved' as execute_type,
|
||||||
'API_INDEPENDENT' as report_type
|
'API_INDEPENDENT' as report_type
|
||||||
from api_definition_exec_result a_r
|
from api_definition_exec_result a_r
|
||||||
where a_r.integrated_report_id is null or a_r.integrated_report_id = 'null'
|
where (a_r.integrated_report_id is null or a_r.integrated_report_id = 'null')
|
||||||
) r
|
<if test="request.combine != null">
|
||||||
<where>
|
<include refid="listCombine">
|
||||||
<if test="request.combine != null">
|
<property name="condition" value="request.combine"/>
|
||||||
<include refid="combine">
|
<property name="name" value="request.name"/>
|
||||||
<property name="condition" value="request.combine"/>
|
</include>
|
||||||
<property name="name" value="request.name"/>
|
</if>
|
||||||
</include>
|
|
||||||
</if>
|
|
||||||
|
|
||||||
<if test="request.name != null">
|
<if test="request.name != null">
|
||||||
and r.name like CONCAT('%', #{request.name},'%')
|
and a_r.name like CONCAT('%', #{request.name},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="request.userId != null">
|
<if test="request.userId != null">
|
||||||
AND r.user_id = #{request.userId,jdbcType=VARCHAR}
|
AND a_r.user_id = #{request.userId,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
<if test="request.projectId != null">
|
<if test="request.projectId != null">
|
||||||
AND r.project_id = #{request.projectId}
|
AND a_r.project_id = #{request.projectId}
|
||||||
</if>
|
</if>
|
||||||
<if test="request.filters != null and request.filters.size() > 0">
|
<if test="request.filters != null and request.filters.size() > 0">
|
||||||
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
||||||
<if test="values != null and values.size() > 0">
|
<if test="values != null and values.size() > 0">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="key=='status'">
|
<when test="key=='status'">
|
||||||
and r.status in
|
and a_r.status in
|
||||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
#{value}
|
#{value}
|
||||||
</foreach>
|
</foreach>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='report_type'">
|
<when test="key=='trigger_mode'">
|
||||||
and r.report_type in
|
and a_r.trigger_mode in
|
||||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
#{value}
|
#{value}
|
||||||
</foreach>
|
</foreach>
|
||||||
</when>
|
</when>
|
||||||
<otherwise>
|
</choose>
|
||||||
and r.trigger_mode in
|
</if>
|
||||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
</foreach>
|
||||||
#{value}
|
</if>
|
||||||
</foreach>
|
|
||||||
</otherwise>
|
|
||||||
</choose>
|
|
||||||
</if>
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
AND r.execute_type = 'Saved'
|
|
||||||
</where>
|
|
||||||
<if test="request.orders != null and request.orders.size() > 0">
|
<if test="request.orders != null and request.orders.size() > 0">
|
||||||
order by
|
order by
|
||||||
<foreach collection="request.orders" separator="," item="order">
|
<foreach collection="request.orders" separator="," item="order">
|
||||||
r.${order.name} ${order.type}
|
a_r.${order.name} ${order.type}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
) a_r on d_s_r.report_id = a_r.id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="get" resultType="io.metersphere.api.dto.automation.APIScenarioReportResult">
|
<select id="get" resultType="io.metersphere.api.dto.automation.APIScenarioReportResult">
|
||||||
|
@ -471,6 +517,62 @@
|
||||||
#{value}
|
#{value}
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectCountByRequest" resultType="java.lang.Long">
|
||||||
|
SELECT
|
||||||
|
count(s_r.id)
|
||||||
|
FROM api_scenario_report s_r
|
||||||
|
<where>
|
||||||
|
<if test="request.combine != null">
|
||||||
|
<include refid="listCombine">
|
||||||
|
<property name="condition" value="request.combine"/>
|
||||||
|
<property name="name" value="request.name"/>
|
||||||
|
</include>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="request.name != null">
|
||||||
|
and s_r.name like CONCAT('%', #{request.name},'%')
|
||||||
|
</if>
|
||||||
|
<if test="request.userId != null">
|
||||||
|
AND s_r.user_id = #{request.userId,jdbcType=VARCHAR}
|
||||||
|
</if>
|
||||||
|
<if test="request.projectId != null">
|
||||||
|
AND s_r.project_id = #{request.projectId}
|
||||||
|
</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=='status'">
|
||||||
|
and s_r.status in
|
||||||
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
|
#{value}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
<when test="key=='report_type'">
|
||||||
|
and s_r.report_type in
|
||||||
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
|
#{value}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
and s_r.trigger_mode in
|
||||||
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
|
#{value}
|
||||||
|
</foreach>
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</if>
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
AND s_r.execute_type = 'Saved'
|
||||||
|
<if test="request.orders != null and request.orders.size() > 0">
|
||||||
|
order by
|
||||||
|
<foreach collection="request.orders" separator="," item="order">
|
||||||
|
s_r.${order.name} ${order.type}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
<update id="update" parameterType="java.util.List">
|
<update id="update" parameterType="java.util.List">
|
||||||
update api_scenario_report set status="STOP" where id in
|
update api_scenario_report set status="STOP" where id in
|
||||||
|
|
|
@ -1,16 +1,27 @@
|
||||||
package io.metersphere.base.mapper.ext;
|
package io.metersphere.base.mapper.ext;
|
||||||
|
|
||||||
|
import io.metersphere.api.dto.QueryAPIReportRequest;
|
||||||
import io.metersphere.api.dto.automation.APIScenarioReportResult;
|
import io.metersphere.api.dto.automation.APIScenarioReportResult;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ExtApiScenarioReportProvider {
|
public class ExtApiScenarioReportProvider {
|
||||||
public String insertListSql(List<APIScenarioReportResult> list) {
|
public String insertListSql(List<APIScenarioReportResult> list) {
|
||||||
|
StringBuffer rsqlList = new StringBuffer();
|
||||||
|
rsqlList.append(";").append("insert into api_definition_scenario_relevance ( report_id ) values ");
|
||||||
StringBuffer sqlList = new StringBuffer();
|
StringBuffer sqlList = new StringBuffer();
|
||||||
sqlList.append("INSERT INTO api_scenario_report (id, project_id, `name`, create_time, update_time, `status`, user_id, trigger_mode," +
|
sqlList.append("INSERT INTO api_scenario_report (id, project_id, `name`, create_time, update_time, `status`, user_id, trigger_mode," +
|
||||||
" execute_type, scenario_name, scenario_id, create_user, actuator, end_time, report_version, version_id, description,report_type) VALUES ");
|
" execute_type, scenario_name, scenario_id, create_user, actuator, end_time, report_version, version_id, description,report_type) VALUES ");
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
APIScenarioReportResult result = list.get(i);
|
APIScenarioReportResult result = list.get(i);
|
||||||
|
rsqlList.append(" (")
|
||||||
|
.append("'")
|
||||||
|
.append(result.getId())
|
||||||
|
.append("'")
|
||||||
|
.append(")");
|
||||||
|
if (i < list.size() - 1) {
|
||||||
|
rsqlList.append(",");
|
||||||
|
}
|
||||||
sqlList.append(" (")
|
sqlList.append(" (")
|
||||||
.append("'")
|
.append("'")
|
||||||
.append(result.getId())
|
.append(result.getId())
|
||||||
|
@ -54,6 +65,12 @@ public class ExtApiScenarioReportProvider {
|
||||||
sqlList.append(",");
|
sqlList.append(",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rsqlList.append(";");
|
||||||
|
sqlList.append(";");
|
||||||
|
sqlList.append(rsqlList);
|
||||||
return sqlList.toString();
|
return sqlList.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7e6272ea7fe3f835c3698ba06efa0168f6403f26
|
Subproject commit f9cd070c384d29d3e11bdab008a79aa5d403cc12
|
|
@ -0,0 +1,28 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS `api_definition_scenario_relevance`
|
||||||
|
(
|
||||||
|
`report_id` varchar(50) NOT NULL COMMENT 'ID',
|
||||||
|
PRIMARY KEY (`report_id`),
|
||||||
|
KEY `relevance_report_id_index` (`report_id`)
|
||||||
|
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_general_ci;
|
||||||
|
|
||||||
|
ALTER TABLE `api_scenario_report` ADD INDEX update_time_index ( `update_time` );
|
||||||
|
|
||||||
|
ALTER TABLE `api_definition_exec_result` ADD INDEX update_time_index ( `create_time` );
|
||||||
|
|
||||||
|
ALTER TABLE `api_definition_exec_result` ADD INDEX integrated_report_id_index ( `integrated_report_id` );
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO api_definition_scenario_relevance (report_id)
|
||||||
|
SELECT s_r.id
|
||||||
|
FROM api_scenario_report s_r
|
||||||
|
where s_r.execute_type = 'Saved';
|
||||||
|
|
||||||
|
INSERT INTO api_definition_scenario_relevance (report_id)
|
||||||
|
select a_r.id
|
||||||
|
from api_definition_exec_result a_r
|
||||||
|
where (a_r.integrated_report_id is null or a_r.integrated_report_id = 'null');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,31 +64,28 @@
|
||||||
|
|
||||||
<!--要生成的数据库表 -->
|
<!--要生成的数据库表 -->
|
||||||
|
|
||||||
<!--<table tableName="test_plan_test_case"/>-->
|
<table tableName="api_definition_scenario_relevance"/>
|
||||||
<!--<table tableName="swagger_url_project"/>
|
<!--<table tableName="swagger_url_project"/>
|
||||||
<table tableName="user_header"/>-->
|
<table tableName="user_header"/>-->
|
||||||
<!--<table tableName="test_plan"/>-->
|
<!--<table tableName="test_plan"/>-->
|
||||||
<!--<table tableName="test_plan"/>-->
|
<!--<table tableName="test_plan"/>-->
|
||||||
<!--<table tableName="api_scenario_report"/>-->
|
<!--<table tableName="api_scenario_report"/>-->
|
||||||
<!--<table tableName="test_case_review"/>-->
|
<!--<table tableName="test_case_review"/>-->
|
||||||
<!-- <table tableName="project">-->
|
<!--<table tableName="project">
|
||||||
<!-- <ignoreColumn column="custom_num"/>-->
|
<ignoreColumn column="custom_num"/>
|
||||||
<!-- <ignoreColumn column="scenario_custom_num"/>-->
|
<ignoreColumn column="scenario_custom_num"/>
|
||||||
<!-- <ignoreColumn column="mock_tcp_port"/>-->
|
<ignoreColumn column="mock_tcp_port"/>
|
||||||
<!-- <ignoreColumn column="is_mock_tcp_open"/>-->
|
<ignoreColumn column="is_mock_tcp_open"/>
|
||||||
<!-- <ignoreColumn column="api_quick"/>-->
|
<ignoreColumn column="api_quick"/>
|
||||||
<!-- <ignoreColumn column="case_public"/>-->
|
<ignoreColumn column="case_public"/>
|
||||||
<!-- <ignoreColumn column="clean_track_report"/>-->
|
<ignoreColumn column="clean_track_report"/>
|
||||||
<!-- <ignoreColumn column="clean_track_report_expr"/>-->
|
<ignoreColumn column="clean_track_report_expr"/>
|
||||||
<!-- <ignoreColumn column="clean_api_report"/>-->
|
<ignoreColumn column="clean_api_report"/>
|
||||||
<!-- <ignoreColumn column="clean_api_report_expr"/>-->
|
<ignoreColumn column="clean_api_report_expr"/>
|
||||||
<!-- <ignoreColumn column="clean_load_report"/>-->
|
<ignoreColumn column="clean_load_report"/>
|
||||||
<!-- <ignoreColumn column="clean_load_report_expr"/>-->
|
<ignoreColumn column="clean_load_report_expr"/>
|
||||||
<!-- <ignoreColumn column="repeatable"/>-->
|
<ignoreColumn column="repeatable"/>
|
||||||
<!-- </table>-->
|
</table>-->
|
||||||
<table tableName="api_test_environment">
|
|
||||||
|
|
||||||
</table>
|
|
||||||
<!--<table tableName="enterprise_test_report_send_record"/>-->
|
<!--<table tableName="enterprise_test_report_send_record"/>-->
|
||||||
<!--<table tableName="test_case_review_api_case"/>
|
<!--<table tableName="test_case_review_api_case"/>
|
||||||
<table tableName="test_case_review_load"/>
|
<table tableName="test_case_review_load"/>
|
||||||
|
|
Loading…
Reference in New Issue