Merge remote-tracking branch 'origin/master'
# Conflicts: # frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue
This commit is contained in:
commit
0c2631883c
|
@ -6,17 +6,24 @@ import io.metersphere.api.dto.APIReportResult;
|
|||
import io.metersphere.api.dto.ApiTestImportRequest;
|
||||
import io.metersphere.api.dto.automation.ApiScenarioRequest;
|
||||
import io.metersphere.api.dto.automation.ReferenceDTO;
|
||||
import io.metersphere.api.dto.datacount.request.ScheduleInfoRequest;
|
||||
import io.metersphere.api.dto.datacount.response.TaskInfoResult;
|
||||
import io.metersphere.api.dto.definition.*;
|
||||
import io.metersphere.api.dto.definition.parse.ApiDefinitionImport;
|
||||
import io.metersphere.api.dto.definition.request.ScheduleInfoSwaggerUrlRequest;
|
||||
import io.metersphere.api.dto.swaggerurl.SwaggerTaskResult;
|
||||
import io.metersphere.api.dto.swaggerurl.SwaggerUrlRequest;
|
||||
import io.metersphere.api.service.ApiDefinitionService;
|
||||
import io.metersphere.base.domain.ApiDefinition;
|
||||
import io.metersphere.base.domain.Schedule;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.commons.json.JSONSchemaGenerator;
|
||||
import io.metersphere.commons.utils.CronUtils;
|
||||
import io.metersphere.commons.utils.PageUtils;
|
||||
import io.metersphere.commons.utils.Pager;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.service.CheckPermissionService;
|
||||
import io.metersphere.service.ScheduleService;
|
||||
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
|
@ -24,6 +31,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
@ -31,6 +39,8 @@ import java.util.List;
|
|||
@RequestMapping(value = "/api/definition")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
|
||||
public class ApiDefinitionController {
|
||||
@Resource
|
||||
private ScheduleService scheduleService;
|
||||
@Resource
|
||||
private ApiDefinitionService apiDefinitionService;
|
||||
@Resource
|
||||
|
@ -139,7 +149,7 @@ public class ApiDefinitionController {
|
|||
public ApiDefinitionImport testCaseImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) {
|
||||
return apiDefinitionService.apiTestImport(file, request);
|
||||
}
|
||||
|
||||
//定时任务创建
|
||||
@PostMapping(value = "/schedule/create")
|
||||
public void createSchedule(@RequestBody Schedule request) {
|
||||
apiDefinitionService.createSchedule(request);
|
||||
|
@ -148,7 +158,38 @@ public class ApiDefinitionController {
|
|||
public void updateSchedule(@RequestBody Schedule request){
|
||||
apiDefinitionService.updateSchedule(request);
|
||||
}
|
||||
|
||||
//查找定时任务资源Id
|
||||
@PostMapping(value = "/getResourceId")
|
||||
public String getResourceId(@RequestBody SwaggerUrlRequest swaggerUrlRequest){
|
||||
return apiDefinitionService.getResourceId(swaggerUrlRequest);
|
||||
}
|
||||
//查找定时任务列表
|
||||
@GetMapping("/scheduleTask/{projectId}")
|
||||
public List<SwaggerTaskResult> getSwaggerScheduleList(@PathVariable String projectId) {
|
||||
List<SwaggerTaskResult> resultList = apiDefinitionService.getSwaggerScheduleList(projectId);
|
||||
int dataIndex = 1;
|
||||
for (SwaggerTaskResult swaggerTaskResult :
|
||||
resultList) {
|
||||
swaggerTaskResult.setIndex(dataIndex++);
|
||||
Date nextExecutionTime = CronUtils.getNextTriggerTime(swaggerTaskResult.getRule());
|
||||
if(nextExecutionTime!=null){
|
||||
swaggerTaskResult.setNextExecutionTime(nextExecutionTime.getTime());
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
//更新定时任务
|
||||
@PostMapping(value = "/schedule/updateByPrimyKey")
|
||||
public void updateScheduleEnableByPrimyKey(@RequestBody ScheduleInfoSwaggerUrlRequest request) {
|
||||
Schedule schedule = scheduleService.getSchedule(request.getTaskId());
|
||||
schedule.setEnable(request.getTaskStatus());
|
||||
apiDefinitionService.updateSchedule(schedule);
|
||||
}
|
||||
//删除定时任务和swaggereUrl
|
||||
@PostMapping("/schedule/deleteByPrimyKey")
|
||||
public void deleteSchedule(@RequestBody ScheduleInfoSwaggerUrlRequest request) {
|
||||
apiDefinitionService.deleteSchedule(request);
|
||||
}
|
||||
@PostMapping("/getReference")
|
||||
public ReferenceDTO getReference(@RequestBody ApiScenarioRequest request) {
|
||||
return apiDefinitionService.getReference(request);
|
||||
|
|
|
@ -16,4 +16,9 @@ public class ApiTestImportRequest {
|
|||
// 来自场景的导入不需要存储
|
||||
private boolean saved = true;
|
||||
private String swaggerUrl;
|
||||
//导入策略
|
||||
private String modeId;
|
||||
private String userId;
|
||||
//调用类型
|
||||
private String type;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class ApiScenarioRequest {
|
|||
private String planId;
|
||||
private boolean recent = false;
|
||||
private List<OrderRequest> orders;
|
||||
private List<String> filters;
|
||||
private Map<String, List<String>> filters;
|
||||
private Map<String, Object> combine;
|
||||
private List<String> ids;
|
||||
private boolean isSelectThisWeedData;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class RunScenarioRequest {
|
|||
*/
|
||||
private boolean isSelectAllDate;
|
||||
|
||||
private List<String> filters;
|
||||
private Map<String, List<String>> filters;
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import lombok.Getter;
|
|||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -23,7 +24,7 @@ public class SaveApiPlanRequest {
|
|||
*/
|
||||
private boolean isSelectAllDate;
|
||||
|
||||
private List<String> filters;
|
||||
private Map<String, List<String>> filters;
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import lombok.Getter;
|
|||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
|
@ -47,7 +48,7 @@ public class SaveApiScenarioRequest {
|
|||
|
||||
private boolean isSelectAllDate;
|
||||
|
||||
private List<String> filters;
|
||||
private Map<String, List<String>> filters;
|
||||
|
||||
private List<String> moduleIds;
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.base.domain.Schedule;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiSwaggerUrlDTO extends Schedule {
|
||||
//序号
|
||||
private int index;
|
||||
private String id;
|
||||
private String projectId;
|
||||
private String swaggerUrl;
|
||||
private String scheduleId;
|
||||
//下次执行时间
|
||||
private Long nextExecutionTime;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.api.dto.definition.request;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ScheduleInfoSwaggerUrlRequest {
|
||||
private String taskId;
|
||||
private Boolean taskStatus;
|
||||
private String id;
|
||||
}
|
|
@ -50,6 +50,8 @@ public class MsJDBCSampler extends MsTestElement {
|
|||
private Object requestResult;
|
||||
@JSONField(ordinal = 28)
|
||||
private String dataSourceId;
|
||||
@JSONField(ordinal = 29)
|
||||
private String protocol="SQL";
|
||||
|
||||
@Override
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||
|
|
|
@ -65,6 +65,8 @@ public class MsTCPSampler extends MsTestElement {
|
|||
private String useEnvironment;
|
||||
@JSONField(ordinal = 37)
|
||||
private MsJSR223PreProcessor tcpPreProcessor;
|
||||
@JSONField(ordinal = 38)
|
||||
private String protocol = "TCP";
|
||||
|
||||
@Override
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||
|
@ -132,10 +134,12 @@ public class MsTCPSampler extends MsTestElement {
|
|||
userParameters.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("UserParametersGui"));
|
||||
List<StringProperty> names = new ArrayList<>();
|
||||
List<StringProperty> threadValues = new ArrayList<>();
|
||||
this.parameters.forEach(item -> {
|
||||
names.add(new StringProperty(new Integer(new Random().nextInt(1000000)).toString(), item.getName()));
|
||||
threadValues.add(new StringProperty(new Integer(new Random().nextInt(1000000)).toString(), item.getValue()));
|
||||
});
|
||||
if (CollectionUtils.isNotEmpty(this.parameters)) {
|
||||
this.parameters.forEach(item -> {
|
||||
names.add(new StringProperty(new Integer(new Random().nextInt(1000000)).toString(), item.getName()));
|
||||
threadValues.add(new StringProperty(new Integer(new Random().nextInt(1000000)).toString(), item.getValue()));
|
||||
});
|
||||
}
|
||||
userParameters.setNames(new CollectionProperty(UserParameters.NAMES, names));
|
||||
List<CollectionProperty> collectionPropertyList = new ArrayList<>();
|
||||
collectionPropertyList.add(new CollectionProperty(new Integer(new Random().nextInt(1000000)).toString(), threadValues));
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package io.metersphere.api.dto.swaggerurl;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SwaggerTaskResult {
|
||||
//序号
|
||||
private int index;
|
||||
//定时任务号
|
||||
private String taskId;
|
||||
//SwaggerUrlId
|
||||
private String SwaggerUrlId;
|
||||
//SwaggerUrl
|
||||
private String swaggerUrl;
|
||||
//导入模块
|
||||
private String modulePath;
|
||||
//同步规则
|
||||
private String rule;
|
||||
//下次同步时间
|
||||
private Long nextExecutionTime;
|
||||
//同步开关
|
||||
private boolean taskStatus;
|
||||
//定时任务类型 swaggerUrlType
|
||||
private String taskType;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.api.dto.swaggerurl;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SwaggerUrlRequest {
|
||||
private String projectId;
|
||||
private String swaggerUrl;
|
||||
private String moduleId;
|
||||
}
|
|
@ -174,6 +174,9 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
if (StringUtils.isBlank(debugReportId)) {
|
||||
apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.DEFINITION.name());
|
||||
}
|
||||
} else if (StringUtils.equals(this.runMode, ApiRunMode.JENKINS.name())) {
|
||||
apiDefinitionService.addResult(testResult);
|
||||
apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.DEFINITION.name());
|
||||
} else if (StringUtils.equalsAny(this.runMode, ApiRunMode.API_PLAN.name(), ApiRunMode.SCHEDULE_API_PLAN.name())) {
|
||||
apiDefinitionService.addResult(testResult);
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
|
|||
import io.metersphere.api.dto.scenario.Body;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import io.metersphere.api.dto.scenario.Scenario;
|
||||
import io.metersphere.api.dto.scenario.request.HttpRequest;
|
||||
import io.metersphere.api.dto.scenario.request.RequestType;
|
||||
import io.metersphere.api.service.ApiModuleService;
|
||||
import io.metersphere.base.domain.ApiModule;
|
||||
|
@ -152,7 +151,7 @@ public abstract class ApiImportAbstractParser implements ApiImportParser {
|
|||
}
|
||||
}
|
||||
|
||||
protected ApiDefinitionResult buildApiDefinition(String id, String name, String path, String method) {
|
||||
protected ApiDefinitionResult buildApiDefinition(String id, String name, String path, String method, ApiTestImportRequest importRequest) {
|
||||
ApiDefinitionResult apiDefinition = new ApiDefinitionResult();
|
||||
apiDefinition.setName(name);
|
||||
apiDefinition.setPath(formatPath(path));
|
||||
|
@ -160,7 +159,11 @@ public abstract class ApiImportAbstractParser implements ApiImportParser {
|
|||
apiDefinition.setMethod(method);
|
||||
apiDefinition.setId(id);
|
||||
apiDefinition.setProjectId(this.projectId);
|
||||
apiDefinition.setUserId(SessionUtils.getUserId());
|
||||
if (StringUtils.equalsIgnoreCase("schedule", importRequest.getType())) {
|
||||
apiDefinition.setUserId(importRequest.getUserId());
|
||||
} else {
|
||||
apiDefinition.setUserId(SessionUtils.getUserId());
|
||||
}
|
||||
return apiDefinition;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public class MsParser extends ApiImportAbstractParser {
|
|||
String method = requestObject.getString("method");
|
||||
|
||||
MsHTTPSamplerProxy request = buildRequest(requestName, path, method);
|
||||
ApiDefinitionResult apiDefinition = buildApiDefinition(request.getId(), requestName, path, method);
|
||||
ApiDefinitionResult apiDefinition = buildApiDefinition(request.getId(), requestName, path, method,importRequest);
|
||||
apiDefinition.setModuleId(module.getId());
|
||||
apiDefinition.setProjectId(this.projectId);
|
||||
parseBody(requestObject, request.getBody());
|
||||
|
|
|
@ -60,7 +60,7 @@ public class PostmanParser extends ApiImportAbstractParser {
|
|||
PostmanUrl url = requestDesc.getUrl();
|
||||
MsHTTPSamplerProxy request = buildRequest(requestItem.getName(), url.getRaw(), requestDesc.getMethod());
|
||||
ApiDefinitionResult apiDefinition =
|
||||
buildApiDefinition(request.getId(), requestItem.getName(), url.getRaw(), requestDesc.getMethod());
|
||||
buildApiDefinition(request.getId(), requestItem.getName(), url.getRaw(), requestDesc.getMethod(),new ApiTestImportRequest());
|
||||
if (StringUtils.isNotBlank(request.getPath())) {
|
||||
String path = request.getPath().split("\\?")[0];
|
||||
path = path.replace("{{", "${");
|
||||
|
|
|
@ -66,7 +66,7 @@ public class Swagger2Parser extends SwaggerAbstractParser {
|
|||
for (HttpMethod method : httpMethods) {
|
||||
Operation operation = operationMap.get(method);
|
||||
MsHTTPSamplerProxy request = buildRequest(operation, pathName, method.name());
|
||||
ApiDefinitionResult apiDefinition = buildApiDefinition(request.getId(), operation, pathName, method.name());
|
||||
ApiDefinitionResult apiDefinition = buildApiDefinition(request.getId(), operation, pathName, method.name(),importRequest);
|
||||
parseParameters(operation, request);
|
||||
addBodyHeader(request);
|
||||
apiDefinition.setRequest(JSON.toJSONString(request));
|
||||
|
@ -80,7 +80,7 @@ public class Swagger2Parser extends SwaggerAbstractParser {
|
|||
return results;
|
||||
}
|
||||
|
||||
private ApiDefinitionResult buildApiDefinition(String id, Operation operation, String path, String method) {
|
||||
private ApiDefinitionResult buildApiDefinition(String id, Operation operation, String path, String method,ApiTestImportRequest importRequest) {
|
||||
String name = "";
|
||||
if (StringUtils.isNotBlank(operation.getSummary())) {
|
||||
name = operation.getSummary();
|
||||
|
@ -89,7 +89,7 @@ public class Swagger2Parser extends SwaggerAbstractParser {
|
|||
} else {
|
||||
name = path;
|
||||
}
|
||||
return buildApiDefinition(id, name, path, method);
|
||||
return buildApiDefinition(id, name, path, method,importRequest);
|
||||
}
|
||||
|
||||
private MsHTTPSamplerProxy buildRequest(Operation operation, String path, String method) {
|
||||
|
|
|
@ -97,7 +97,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
|||
Operation operation = operationsMap.get(method);
|
||||
if (operation != null) {
|
||||
MsHTTPSamplerProxy request = buildRequest(operation, pathName, method);
|
||||
ApiDefinitionResult apiDefinition = buildApiDefinition(request.getId(), operation, pathName, method);
|
||||
ApiDefinitionResult apiDefinition = buildApiDefinition(request.getId(), operation, pathName, method,importRequest);
|
||||
parseParameters(operation, request);
|
||||
parseRequestBody(operation.getRequestBody(), request.getBody());
|
||||
addBodyHeader(request);
|
||||
|
@ -112,7 +112,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
|||
return results;
|
||||
}
|
||||
|
||||
private ApiDefinitionResult buildApiDefinition(String id, Operation operation, String path, String method) {
|
||||
private ApiDefinitionResult buildApiDefinition(String id, Operation operation, String path, String method,ApiTestImportRequest importRequest) {
|
||||
String name = "";
|
||||
if (StringUtils.isNotBlank(operation.getSummary())) {
|
||||
name = operation.getSummary();
|
||||
|
@ -121,7 +121,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
|||
} else {
|
||||
name = path;
|
||||
}
|
||||
return buildApiDefinition(id, name, path, method);
|
||||
return buildApiDefinition(id, name, path, method,importRequest);
|
||||
}
|
||||
|
||||
private MsHTTPSamplerProxy buildRequest(Operation operation, String path, String method) {
|
||||
|
|
|
@ -464,7 +464,7 @@ public class ApiAutomationService {
|
|||
* @param unSelectIds 未勾选ID_前台没有勾选的ID
|
||||
* @return
|
||||
*/
|
||||
private List<String> getAllScenarioIdsByFontedSelect(List<String> moduleIds, String name, String projectId, List<String> filters, List<String> unSelectIds) {
|
||||
private List<String> getAllScenarioIdsByFontedSelect(List<String> moduleIds, String name, String projectId, Map<String, List<String>> filters, List<String> unSelectIds) {
|
||||
ApiScenarioRequest selectRequest = new ApiScenarioRequest();
|
||||
selectRequest.setModuleIds(moduleIds);
|
||||
selectRequest.setName(name);
|
||||
|
|
|
@ -9,19 +9,17 @@ import io.metersphere.api.dto.automation.ReferenceDTO;
|
|||
import io.metersphere.api.dto.datacount.ApiDataCountResult;
|
||||
import io.metersphere.api.dto.definition.*;
|
||||
import io.metersphere.api.dto.definition.parse.ApiDefinitionImport;
|
||||
import io.metersphere.api.dto.definition.request.ScheduleInfoSwaggerUrlRequest;
|
||||
import io.metersphere.api.dto.scenario.request.RequestType;
|
||||
import io.metersphere.api.dto.swaggerurl.SwaggerTaskResult;
|
||||
import io.metersphere.api.dto.swaggerurl.SwaggerUrlRequest;
|
||||
import io.metersphere.api.jmeter.JMeterService;
|
||||
import io.metersphere.api.jmeter.TestResult;
|
||||
import io.metersphere.api.parse.ApiImportParser;
|
||||
import io.metersphere.api.parse.ApiImportParserFactory;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.ApiDefinitionMapper;
|
||||
import io.metersphere.base.mapper.ApiTestFileMapper;
|
||||
import io.metersphere.base.mapper.ProjectMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiDefinitionMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
|
||||
import io.metersphere.base.mapper.*;
|
||||
import io.metersphere.base.mapper.ext.*;
|
||||
import io.metersphere.commons.constants.APITestStatus;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.constants.ScheduleGroup;
|
||||
|
@ -79,6 +77,12 @@ public class ApiDefinitionService {
|
|||
private ProjectMapper projectMapper;
|
||||
@Resource
|
||||
private ScheduleService scheduleService;
|
||||
@Resource
|
||||
private SwaggerUrlProjectMapper swaggerUrlProjectMapper;
|
||||
@Resource
|
||||
private ExtSwaggerUrlScheduleMapper extSwaggerUrlScheduleMapper;
|
||||
@Resource
|
||||
private ScheduleMapper scheduleMapper;
|
||||
|
||||
private static Cache cache = Cache.newHardMemoryCache(0, 3600 * 24);
|
||||
|
||||
|
@ -293,7 +297,7 @@ public class ApiDefinitionService {
|
|||
}
|
||||
}
|
||||
|
||||
private ApiDefinition importCreate(ApiDefinitionResult request, ApiDefinitionMapper batchMapper) {
|
||||
private ApiDefinition importCreate(ApiDefinitionResult request, ApiDefinitionMapper batchMapper,ApiTestImportRequest apiTestImportRequest) {
|
||||
SaveApiDefinitionRequest saveReq = new SaveApiDefinitionRequest();
|
||||
BeanUtils.copyBean(saveReq, request);
|
||||
final ApiDefinitionWithBLOBs apiDefinition = new ApiDefinitionWithBLOBs();
|
||||
|
@ -309,13 +313,26 @@ public class ApiDefinitionService {
|
|||
apiDefinition.setDescription(request.getDescription());
|
||||
|
||||
List<ApiDefinition> sameRequest = getSameRequest(saveReq);
|
||||
if (CollectionUtils.isEmpty(sameRequest)) {
|
||||
if(StringUtils.equals("fullCoverage",apiTestImportRequest.getModeId())){
|
||||
if (CollectionUtils.isEmpty(sameRequest)) {
|
||||
batchMapper.insert(apiDefinition);
|
||||
} else {
|
||||
//如果存在则修改
|
||||
apiDefinition.setId(sameRequest.get(0).getId());
|
||||
apiDefinitionMapper.updateByPrimaryKeyWithBLOBs(apiDefinition);
|
||||
}
|
||||
}else if(StringUtils.equals("incrementalMerge",apiTestImportRequest.getModeId())){
|
||||
batchMapper.insert(apiDefinition);
|
||||
} else {
|
||||
//如果存在则修改
|
||||
apiDefinition.setId(sameRequest.get(0).getId());
|
||||
apiDefinitionMapper.updateByPrimaryKeyWithBLOBs(apiDefinition);
|
||||
}else{
|
||||
if (CollectionUtils.isEmpty(sameRequest)) {
|
||||
batchMapper.insert(apiDefinition);
|
||||
} else {
|
||||
//如果存在则修改
|
||||
apiDefinition.setId(sameRequest.get(0).getId());
|
||||
apiDefinitionMapper.updateByPrimaryKeyWithBLOBs(apiDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
return apiDefinition;
|
||||
}
|
||||
|
||||
|
@ -434,7 +451,7 @@ public class ApiDefinitionService {
|
|||
item.setName(item.getName().substring(0, 255));
|
||||
}
|
||||
item.setNum(num++);
|
||||
importCreate(item, batchMapper);
|
||||
importCreate(item, batchMapper,request);
|
||||
if (i % 300 == 0) {
|
||||
sqlSession.flushStatements();
|
||||
}
|
||||
|
@ -596,6 +613,16 @@ public class ApiDefinitionService {
|
|||
|
||||
/*swagger定时导入*/
|
||||
public void createSchedule(Schedule request) {
|
||||
/*保存swaggerUrl*/
|
||||
SwaggerUrlProject swaggerUrlProject=new SwaggerUrlProject();
|
||||
swaggerUrlProject.setId(UUID.randomUUID().toString());
|
||||
swaggerUrlProject.setProjectId(request.getProjectId());
|
||||
swaggerUrlProject.setSwaggerUrl(request.getResourceId());
|
||||
swaggerUrlProject.setModuleId(request.getModuleId());
|
||||
swaggerUrlProject.setModulePath(request.getModulePath());
|
||||
swaggerUrlProject.setModeId(request.getModeId());
|
||||
scheduleService.addSwaggerUrlSchedule(swaggerUrlProject);
|
||||
request.setResourceId(swaggerUrlProject.getId());
|
||||
Schedule schedule = scheduleService.buildApiTestSchedule(request);
|
||||
schedule.setJob(SwaggerUrlImportJob.class.getName());
|
||||
schedule.setGroup(ScheduleGroup.SWAGGER_IMPORT.name());
|
||||
|
@ -604,12 +631,37 @@ public class ApiDefinitionService {
|
|||
this.addOrUpdateSwaggerImportCronJob(request);
|
||||
|
||||
}
|
||||
//关闭
|
||||
public void updateSchedule(Schedule request){
|
||||
scheduleService.editSchedule(request);
|
||||
this.addOrUpdateSwaggerImportCronJob(request);
|
||||
}
|
||||
//删除
|
||||
public void deleteSchedule(ScheduleInfoSwaggerUrlRequest request){
|
||||
swaggerUrlProjectMapper.deleteByPrimaryKey(request.getId());
|
||||
scheduleMapper.deleteByPrimaryKey(request.getTaskId());
|
||||
|
||||
}
|
||||
//查询swaggerUrl详情
|
||||
public SwaggerUrlProject getSwaggerInfo(String resourceId){
|
||||
return swaggerUrlProjectMapper.selectByPrimaryKey(resourceId);
|
||||
}
|
||||
public String getResourceId(SwaggerUrlRequest swaggerUrlRequest){
|
||||
SwaggerUrlProjectExample swaggerUrlProjectExample=new SwaggerUrlProjectExample();
|
||||
SwaggerUrlProjectExample.Criteria criteria=swaggerUrlProjectExample.createCriteria();
|
||||
criteria.andProjectIdEqualTo(swaggerUrlRequest.getProjectId()).andSwaggerUrlEqualTo(swaggerUrlRequest.getSwaggerUrl()).andModuleIdEqualTo(swaggerUrlRequest.getModuleId());
|
||||
List<SwaggerUrlProject> list=swaggerUrlProjectMapper.selectByExample(swaggerUrlProjectExample);
|
||||
String resourceId="";
|
||||
if(list.size()==1){
|
||||
resourceId=list.get(0).getId();
|
||||
}
|
||||
return resourceId;
|
||||
}
|
||||
public List<SwaggerTaskResult> getSwaggerScheduleList(String projectId){
|
||||
return extSwaggerUrlScheduleMapper.getSwaggerTaskList(projectId);
|
||||
}
|
||||
|
||||
private void addOrUpdateSwaggerImportCronJob(Schedule request) {
|
||||
scheduleService.addOrUpdateCronJob(request, SwaggerUrlImportJob.getJobKey(request.getResourceId()), SwaggerUrlImportJob.getTriggerKey(request.getResourceId()), SwaggerUrlImportJob.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
|
|||
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.*;
|
||||
import io.metersphere.i18n.Translator;
|
||||
|
@ -470,9 +469,11 @@ public class ApiTestCaseService {
|
|||
if (testCaseWithBLOBs != null && StringUtils.isNotEmpty(testCaseWithBLOBs.getRequest())) {
|
||||
try {
|
||||
HashTree jmeterHashTree = this.generateHashTree(request, testCaseWithBLOBs);
|
||||
String runMode = ApiRunMode.DEFINITION.name();
|
||||
/*
|
||||
String runMode = ApiRunMode.JENKINS.name();
|
||||
*/
|
||||
// 调用执行方法
|
||||
jMeterService.runDefinition(request.getReportId(), jmeterHashTree, request.getReportId(), runMode);
|
||||
jMeterService.runDefinition(request.getReportId(), jmeterHashTree, request.getReportId(), request.getRunMode());
|
||||
|
||||
} catch (Exception ex) {
|
||||
LogUtil.error(ex.getMessage());
|
||||
|
@ -540,10 +541,7 @@ public class ApiTestCaseService {
|
|||
}
|
||||
|
||||
public String getExecResult(String id) {
|
||||
ApiDefinitionExecResultExample apidefinitionexecresultexample = new ApiDefinitionExecResultExample();
|
||||
ApiDefinitionExecResultExample.Criteria criteria = apidefinitionexecresultexample.createCriteria();
|
||||
criteria.andResourceIdEqualTo(id);
|
||||
String status = apiDefinitionExecResultMapper.selectByExample(apidefinitionexecresultexample).get(0).getStatus();
|
||||
String status = apiDefinitionExecResultMapper.selectExecResult(id);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,15 @@ public class HistoricalDataUpgradeService {
|
|||
}
|
||||
}
|
||||
|
||||
private MsScenario createScenarioByTest(ApiTest test) {
|
||||
MsScenario scenario = new MsScenario();
|
||||
scenario.setName(test.getName());
|
||||
scenario.setReferenced("Upgrade");
|
||||
scenario.setResourceId(UUID.randomUUID().toString());
|
||||
scenario.setId(test.getId());
|
||||
return scenario;
|
||||
}
|
||||
|
||||
private MsScenario createScenario(Scenario oldScenario) {
|
||||
MsScenario scenario = new MsScenario();
|
||||
scenario.setOldVariables(oldScenario.getVariables());
|
||||
|
@ -147,6 +156,9 @@ public class HistoricalDataUpgradeService {
|
|||
BeanUtils.copyBean(element, request1);
|
||||
((MsHTTPSamplerProxy) element).setProtocol(RequestType.HTTP);
|
||||
((MsHTTPSamplerProxy) element).setArguments(request1.getParameters());
|
||||
List<KeyValue> keyValues = new LinkedList<>();
|
||||
keyValues.add(new KeyValue("", ""));
|
||||
((MsHTTPSamplerProxy) element).setRest(keyValues);
|
||||
if (StringUtils.isEmpty(element.getName())) {
|
||||
element.setName(request1.getPath());
|
||||
}
|
||||
|
@ -251,9 +263,9 @@ public class HistoricalDataUpgradeService {
|
|||
return scenario;
|
||||
}
|
||||
|
||||
private ApiScenarioWithBLOBs checkNameExist(Scenario oldScenario, String projectId, ApiScenarioMapper mapper) {
|
||||
private ApiScenarioWithBLOBs getScenario(String oldScenarioId, ApiScenarioMapper mapper) {
|
||||
ApiScenarioExample example = new ApiScenarioExample();
|
||||
example.createCriteria().andIdEqualTo(oldScenario.getId());
|
||||
example.createCriteria().andIdEqualTo(oldScenarioId);
|
||||
List<ApiScenarioWithBLOBs> list = mapper.selectByExampleWithBLOBs(example);
|
||||
if (list.size() > 0) {
|
||||
return list.get(0);
|
||||
|
@ -333,20 +345,20 @@ public class HistoricalDataUpgradeService {
|
|||
copyDir(dir, BODY_FILE_DIR);
|
||||
}
|
||||
|
||||
private void createApiScenarioWithBLOBs(SaveHistoricalDataUpgrade saveHistoricalDataUpgrade, Scenario oldScenario, String scenarioDefinition, ApiScenarioMapper mapper, int num) {
|
||||
if (StringUtils.isEmpty(oldScenario.getName())) {
|
||||
oldScenario.setName("默认名称-" + DateUtils.getTimeStr(System.currentTimeMillis()));
|
||||
private void createApiScenarioWithBLOBs(SaveHistoricalDataUpgrade saveHistoricalDataUpgrade, String id, String name, int total, String scenarioDefinition, ApiScenarioMapper mapper, int num) {
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
name = "默认名称-" + DateUtils.getTimeStr(System.currentTimeMillis());
|
||||
}
|
||||
ApiScenarioWithBLOBs scenario = checkNameExist(oldScenario, saveHistoricalDataUpgrade.getProjectId(), mapper);
|
||||
ApiScenarioWithBLOBs scenario = getScenario(id, mapper);
|
||||
if (scenario != null) {
|
||||
scenario.setName(oldScenario.getName());
|
||||
scenario.setName(name);
|
||||
scenario.setProjectId(saveHistoricalDataUpgrade.getProjectId());
|
||||
scenario.setTags(scenario.getTags());
|
||||
scenario.setLevel("P0");
|
||||
scenario.setModulePath(saveHistoricalDataUpgrade.getModulePath());
|
||||
scenario.setApiScenarioModuleId(saveHistoricalDataUpgrade.getModuleId());
|
||||
scenario.setPrincipal(Objects.requireNonNull(SessionUtils.getUser()).getId());
|
||||
scenario.setStepTotal(oldScenario.getRequests().size());
|
||||
scenario.setStepTotal(total);
|
||||
scenario.setScenarioDefinition(scenarioDefinition);
|
||||
scenario.setUpdateTime(System.currentTimeMillis());
|
||||
scenario.setStatus(ScenarioStatus.Underway.name());
|
||||
|
@ -354,15 +366,15 @@ public class HistoricalDataUpgradeService {
|
|||
mapper.updateByPrimaryKeySelective(scenario);
|
||||
} else {
|
||||
scenario = new ApiScenarioWithBLOBs();
|
||||
scenario.setId(oldScenario.getId());
|
||||
scenario.setName(oldScenario.getName());
|
||||
scenario.setId(id);
|
||||
scenario.setName(name);
|
||||
scenario.setProjectId(saveHistoricalDataUpgrade.getProjectId());
|
||||
scenario.setTags(scenario.getTags());
|
||||
scenario.setLevel("P0");
|
||||
scenario.setModulePath(saveHistoricalDataUpgrade.getModulePath());
|
||||
scenario.setApiScenarioModuleId(saveHistoricalDataUpgrade.getModuleId());
|
||||
scenario.setPrincipal(Objects.requireNonNull(SessionUtils.getUser()).getId());
|
||||
scenario.setStepTotal(oldScenario.getRequests().size());
|
||||
scenario.setStepTotal(total);
|
||||
scenario.setScenarioDefinition(scenarioDefinition);
|
||||
scenario.setCreateTime(System.currentTimeMillis());
|
||||
scenario.setUpdateTime(System.currentTimeMillis());
|
||||
|
@ -386,7 +398,9 @@ public class HistoricalDataUpgradeService {
|
|||
for (ApiTest test : blobs) {
|
||||
// 附件迁移
|
||||
createBodyFiles(test.getId());
|
||||
|
||||
// 把test 生成一个场景,旧场景数据变成引用步骤
|
||||
MsScenario scenarioTest = createScenarioByTest(test);
|
||||
LinkedList<MsTestElement> listSteps = new LinkedList<>();
|
||||
List<Scenario> scenarios = JSON.parseArray(test.getScenarioDefinition(), Scenario.class);
|
||||
if (CollectionUtils.isNotEmpty(scenarios)) {
|
||||
// 批量处理
|
||||
|
@ -394,9 +408,20 @@ public class HistoricalDataUpgradeService {
|
|||
MsScenario scenario1 = createScenario(scenario);
|
||||
String scenarioDefinition = JSON.toJSONString(scenario1);
|
||||
num++;
|
||||
createApiScenarioWithBLOBs(saveHistoricalDataUpgrade, scenario, scenarioDefinition, mapper, num);
|
||||
createApiScenarioWithBLOBs(saveHistoricalDataUpgrade, scenario.getId(), scenario.getName(), scenario.getRequests().size(), scenarioDefinition, mapper, num);
|
||||
MsScenario step = new MsScenario();
|
||||
step.setId(scenario1.getId());
|
||||
step.setName(scenario1.getName());
|
||||
step.setType("scenario");
|
||||
step.setResourceId(UUID.randomUUID().toString());
|
||||
step.setReferenced("REF");
|
||||
listSteps.add(step);
|
||||
}
|
||||
}
|
||||
num++;
|
||||
scenarioTest.setHashTree(listSteps);
|
||||
String scenarioDefinition = JSON.toJSONString(scenarioTest);
|
||||
createApiScenarioWithBLOBs(saveHistoricalDataUpgrade, scenarioTest.getId(), scenarioTest.getName(), listSteps.size(), scenarioDefinition, mapper, num);
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
return null;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AuthSource implements Serializable {
|
||||
|
|
|
@ -37,5 +37,11 @@ public class Schedule implements Serializable {
|
|||
//定时任务来源: 测试计划/测试场景
|
||||
private String scheduleFrom;
|
||||
|
||||
private String swaggerUrl;
|
||||
private String projectId;
|
||||
|
||||
private String moduleId;
|
||||
|
||||
private String modulePath;
|
||||
|
||||
private String modeId;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SwaggerUrlProject implements Serializable {
|
||||
private String id;
|
||||
|
||||
private String projectId;
|
||||
|
||||
private String swaggerUrl;
|
||||
|
||||
private String moduleId;
|
||||
|
||||
private String modulePath;
|
||||
|
||||
private String modeId;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,620 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SwaggerUrlProjectExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public SwaggerUrlProjectExample() {
|
||||
oredCriteria = new ArrayList<Criteria>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<Criterion>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(String value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(String value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(String value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(String value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLike(String value) {
|
||||
addCriterion("id like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotLike(String value) {
|
||||
addCriterion("id not like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<String> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<String> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(String value1, String value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(String value1, String value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIsNull() {
|
||||
addCriterion("project_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIsNotNull() {
|
||||
addCriterion("project_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdEqualTo(String value) {
|
||||
addCriterion("project_id =", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotEqualTo(String value) {
|
||||
addCriterion("project_id <>", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdGreaterThan(String value) {
|
||||
addCriterion("project_id >", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("project_id >=", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLessThan(String value) {
|
||||
addCriterion("project_id <", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("project_id <=", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLike(String value) {
|
||||
addCriterion("project_id like", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotLike(String value) {
|
||||
addCriterion("project_id not like", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIn(List<String> values) {
|
||||
addCriterion("project_id in", values, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotIn(List<String> values) {
|
||||
addCriterion("project_id not in", values, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdBetween(String value1, String value2) {
|
||||
addCriterion("project_id between", value1, value2, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotBetween(String value1, String value2) {
|
||||
addCriterion("project_id not between", value1, value2, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSwaggerUrlIsNull() {
|
||||
addCriterion("swagger_url is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSwaggerUrlIsNotNull() {
|
||||
addCriterion("swagger_url is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSwaggerUrlEqualTo(String value) {
|
||||
addCriterion("swagger_url =", value, "swaggerUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSwaggerUrlNotEqualTo(String value) {
|
||||
addCriterion("swagger_url <>", value, "swaggerUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSwaggerUrlGreaterThan(String value) {
|
||||
addCriterion("swagger_url >", value, "swaggerUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSwaggerUrlGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("swagger_url >=", value, "swaggerUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSwaggerUrlLessThan(String value) {
|
||||
addCriterion("swagger_url <", value, "swaggerUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSwaggerUrlLessThanOrEqualTo(String value) {
|
||||
addCriterion("swagger_url <=", value, "swaggerUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSwaggerUrlLike(String value) {
|
||||
addCriterion("swagger_url like", value, "swaggerUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSwaggerUrlNotLike(String value) {
|
||||
addCriterion("swagger_url not like", value, "swaggerUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSwaggerUrlIn(List<String> values) {
|
||||
addCriterion("swagger_url in", values, "swaggerUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSwaggerUrlNotIn(List<String> values) {
|
||||
addCriterion("swagger_url not in", values, "swaggerUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSwaggerUrlBetween(String value1, String value2) {
|
||||
addCriterion("swagger_url between", value1, value2, "swaggerUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSwaggerUrlNotBetween(String value1, String value2) {
|
||||
addCriterion("swagger_url not between", value1, value2, "swaggerUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdIsNull() {
|
||||
addCriterion("module_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdIsNotNull() {
|
||||
addCriterion("module_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdEqualTo(String value) {
|
||||
addCriterion("module_id =", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdNotEqualTo(String value) {
|
||||
addCriterion("module_id <>", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdGreaterThan(String value) {
|
||||
addCriterion("module_id >", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("module_id >=", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdLessThan(String value) {
|
||||
addCriterion("module_id <", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("module_id <=", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdLike(String value) {
|
||||
addCriterion("module_id like", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdNotLike(String value) {
|
||||
addCriterion("module_id not like", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdIn(List<String> values) {
|
||||
addCriterion("module_id in", values, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdNotIn(List<String> values) {
|
||||
addCriterion("module_id not in", values, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdBetween(String value1, String value2) {
|
||||
addCriterion("module_id between", value1, value2, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModuleIdNotBetween(String value1, String value2) {
|
||||
addCriterion("module_id not between", value1, value2, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModulePathIsNull() {
|
||||
addCriterion("module_path is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModulePathIsNotNull() {
|
||||
addCriterion("module_path is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModulePathEqualTo(String value) {
|
||||
addCriterion("module_path =", value, "modulePath");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModulePathNotEqualTo(String value) {
|
||||
addCriterion("module_path <>", value, "modulePath");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModulePathGreaterThan(String value) {
|
||||
addCriterion("module_path >", value, "modulePath");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModulePathGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("module_path >=", value, "modulePath");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModulePathLessThan(String value) {
|
||||
addCriterion("module_path <", value, "modulePath");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModulePathLessThanOrEqualTo(String value) {
|
||||
addCriterion("module_path <=", value, "modulePath");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModulePathLike(String value) {
|
||||
addCriterion("module_path like", value, "modulePath");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModulePathNotLike(String value) {
|
||||
addCriterion("module_path not like", value, "modulePath");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModulePathIn(List<String> values) {
|
||||
addCriterion("module_path in", values, "modulePath");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModulePathNotIn(List<String> values) {
|
||||
addCriterion("module_path not in", values, "modulePath");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModulePathBetween(String value1, String value2) {
|
||||
addCriterion("module_path between", value1, value2, "modulePath");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModulePathNotBetween(String value1, String value2) {
|
||||
addCriterion("module_path not between", value1, value2, "modulePath");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModeIdIsNull() {
|
||||
addCriterion("mode_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModeIdIsNotNull() {
|
||||
addCriterion("mode_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModeIdEqualTo(String value) {
|
||||
addCriterion("mode_id =", value, "modeId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModeIdNotEqualTo(String value) {
|
||||
addCriterion("mode_id <>", value, "modeId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModeIdGreaterThan(String value) {
|
||||
addCriterion("mode_id >", value, "modeId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModeIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("mode_id >=", value, "modeId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModeIdLessThan(String value) {
|
||||
addCriterion("mode_id <", value, "modeId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModeIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("mode_id <=", value, "modeId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModeIdLike(String value) {
|
||||
addCriterion("mode_id like", value, "modeId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModeIdNotLike(String value) {
|
||||
addCriterion("mode_id not like", value, "modeId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModeIdIn(List<String> values) {
|
||||
addCriterion("mode_id in", values, "modeId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModeIdNotIn(List<String> values) {
|
||||
addCriterion("mode_id not in", values, "modeId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModeIdBetween(String value1, String value2) {
|
||||
addCriterion("mode_id between", value1, value2, "modeId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModeIdNotBetween(String value1, String value2) {
|
||||
addCriterion("mode_id not between", value1, value2, "modeId");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,9 +2,8 @@ package io.metersphere.base.mapper;
|
|||
|
||||
import io.metersphere.base.domain.AuthSource;
|
||||
import io.metersphere.base.domain.AuthSourceExample;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface AuthSourceMapper {
|
||||
long countByExample(AuthSourceExample example);
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package io.metersphere.base.mapper;
|
||||
|
||||
import io.metersphere.base.domain.SwaggerUrlProject;
|
||||
import io.metersphere.base.domain.SwaggerUrlProjectExample;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SwaggerUrlProjectMapper {
|
||||
long countByExample(SwaggerUrlProjectExample example);
|
||||
|
||||
int deleteByExample(SwaggerUrlProjectExample example);
|
||||
|
||||
int deleteByPrimaryKey(String id);
|
||||
|
||||
int insert(SwaggerUrlProject record);
|
||||
|
||||
int insertSelective(SwaggerUrlProject record);
|
||||
|
||||
List<SwaggerUrlProject> selectByExample(SwaggerUrlProjectExample example);
|
||||
|
||||
SwaggerUrlProject selectByPrimaryKey(String id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") SwaggerUrlProject record, @Param("example") SwaggerUrlProjectExample example);
|
||||
|
||||
int updateByExample(@Param("record") SwaggerUrlProject record, @Param("example") SwaggerUrlProjectExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(SwaggerUrlProject record);
|
||||
|
||||
int updateByPrimaryKey(SwaggerUrlProject record);
|
||||
}
|
|
@ -0,0 +1,231 @@
|
|||
<?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.SwaggerUrlProjectMapper">
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.SwaggerUrlProject">
|
||||
<id column="id" jdbcType="VARCHAR" property="id"/>
|
||||
<result column="project_id" jdbcType="VARCHAR" property="projectId"/>
|
||||
<result column="swagger_url" jdbcType="VARCHAR" property="swaggerUrl"/>
|
||||
<result column="module_id" jdbcType="VARCHAR" property="moduleId"/>
|
||||
<result column="module_path" jdbcType="VARCHAR" property="modulePath"/>
|
||||
<result column="mode_id" jdbcType="VARCHAR" property="modeId"/>
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="("
|
||||
separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="("
|
||||
separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, project_id, swagger_url, module_id, module_path, mode_id
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.base.domain.SwaggerUrlProjectExample"
|
||||
resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List"/>
|
||||
from swagger_url_project
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause"/>
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from swagger_url_project
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
delete
|
||||
from swagger_url_project
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.SwaggerUrlProjectExample">
|
||||
delete from swagger_url_project
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause"/>
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.base.domain.SwaggerUrlProject">
|
||||
insert into swagger_url_project (id, project_id, swagger_url,
|
||||
module_id, module_path, mode_id)
|
||||
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{swaggerUrl,jdbcType=VARCHAR},
|
||||
#{moduleId,jdbcType=VARCHAR}, #{modulePath,jdbcType=VARCHAR}, #{modeId,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.SwaggerUrlProject">
|
||||
insert into swagger_url_project
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="projectId != null">
|
||||
project_id,
|
||||
</if>
|
||||
<if test="swaggerUrl != null">
|
||||
swagger_url,
|
||||
</if>
|
||||
<if test="moduleId != null">
|
||||
module_id,
|
||||
</if>
|
||||
<if test="modulePath != null">
|
||||
module_path,
|
||||
</if>
|
||||
<if test="modeId != null">
|
||||
mode_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="projectId != null">
|
||||
#{projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="swaggerUrl != null">
|
||||
#{swaggerUrl,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="moduleId != null">
|
||||
#{moduleId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="modulePath != null">
|
||||
#{modulePath,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="modeId != null">
|
||||
#{modeId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.metersphere.base.domain.SwaggerUrlProjectExample"
|
||||
resultType="java.lang.Long">
|
||||
select count(*) from swagger_url_project
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause"/>
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update swagger_url_project
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.projectId != null">
|
||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.swaggerUrl != null">
|
||||
swagger_url = #{record.swaggerUrl,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.moduleId != null">
|
||||
module_id = #{record.moduleId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.modulePath != null">
|
||||
module_path = #{record.modulePath,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.modeId != null">
|
||||
mode_id = #{record.modeId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause"/>
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update swagger_url_project
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
swagger_url = #{record.swaggerUrl,jdbcType=VARCHAR},
|
||||
module_id = #{record.moduleId,jdbcType=VARCHAR},
|
||||
module_path = #{record.modulePath,jdbcType=VARCHAR},
|
||||
mode_id = #{record.modeId,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause"/>
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.SwaggerUrlProject">
|
||||
update swagger_url_project
|
||||
<set>
|
||||
<if test="projectId != null">
|
||||
project_id = #{projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="swaggerUrl != null">
|
||||
swagger_url = #{swaggerUrl,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="moduleId != null">
|
||||
module_id = #{moduleId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="modulePath != null">
|
||||
module_path = #{modulePath,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="modeId != null">
|
||||
mode_id = #{modeId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.SwaggerUrlProject">
|
||||
update swagger_url_project
|
||||
set project_id = #{projectId,jdbcType=VARCHAR},
|
||||
swagger_url = #{swaggerUrl,jdbcType=VARCHAR},
|
||||
module_id = #{moduleId,jdbcType=VARCHAR},
|
||||
module_path = #{modulePath,jdbcType=VARCHAR},
|
||||
mode_id = #{modeId,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
|
@ -4,12 +4,14 @@ import io.metersphere.api.dto.datacount.ApiDataCountResult;
|
|||
import io.metersphere.api.dto.definition.ApiComputeResult;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionRequest;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionResult;
|
||||
import io.metersphere.api.dto.definition.ApiSwaggerUrlDTO;
|
||||
import io.metersphere.base.domain.ApiDefinition;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtApiDefinitionMapper {
|
||||
List<ApiSwaggerUrlDTO> selectScheduleList(@Param("projectId") String projectId);
|
||||
|
||||
List<ApiDefinitionResult> list(@Param("request") ApiDefinitionRequest request);
|
||||
|
||||
|
|
|
@ -421,4 +421,19 @@
|
|||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectScheduleList" resultType="io.metersphere.api.dto.definition.ApiSwaggerUrlDTO">
|
||||
SELECT apiScene.id AS scenarioId,
|
||||
apiScene.`name` AS `name`,
|
||||
sch.id AS taskID,
|
||||
sch.`value` AS rule,
|
||||
sch.`enable` AS `taskStatus`,
|
||||
u.`name` AS creator,
|
||||
sch.update_time AS updateTime,
|
||||
'scenario' AS taskType
|
||||
FROM api_scenario apiScene
|
||||
INNER JOIN `schedule` sch ON apiScene.id = sch.resource_id
|
||||
INNER JOIN `user` u ON u.id = sch.user_id
|
||||
WHERE sch.`enable` = true
|
||||
AND apiScene.project_id = #{0,jdbcType=VARCHAR}
|
||||
</select>
|
||||
</mapper>
|
|
@ -150,9 +150,35 @@
|
|||
</foreach>
|
||||
</if>
|
||||
<if test="request.filters != null and request.filters.size() > 0">
|
||||
and api_scenario.status in
|
||||
<foreach collection="request.filters" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
||||
<if test="values != null and values.size() > 0">
|
||||
<choose>
|
||||
<when test="key=='status'">
|
||||
and api_scenario.status in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key=='user_id'">
|
||||
and api_scenario.user_id in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key=='level'">
|
||||
and api_scenario.level in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key=='last_result'">
|
||||
and api_scenario.last_result in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.executeStatus == 'unExecute'">
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import io.metersphere.api.dto.datacount.response.TaskInfoResult;
|
||||
import io.metersphere.api.dto.definition.ApiSwaggerUrlDTO;
|
||||
import io.metersphere.controller.request.QueryScheduleRequest;
|
||||
import io.metersphere.dto.ScheduleDao;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
@ -15,4 +16,9 @@ public interface ExtScheduleMapper {
|
|||
long countTaskByProjectIdAndCreateTimeRange(@Param("projectId")String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime);
|
||||
|
||||
List<TaskInfoResult> findRunningTaskInfoByProjectID(String workspaceID);
|
||||
|
||||
void insert(@Param("apiSwaggerUrlDTO") ApiSwaggerUrlDTO apiSwaggerUrlDTO);
|
||||
|
||||
ApiSwaggerUrlDTO select(String id);
|
||||
|
||||
}
|
|
@ -1,6 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.base.mapper.ext.ExtScheduleMapper">
|
||||
<insert id="insert" parameterType="io.metersphere.api.dto.definition.ApiSwaggerUrlDTO">
|
||||
insert into swagger_url_project (id, `project_id`, `swagger_url`,
|
||||
`schedule_id`)
|
||||
values (#{apiSwaggerUrlDTO.id,jdbcType=VARCHAR}, #{apiSwaggerUrlDTO.projectId,jdbcType=VARCHAR}, #{apiSwaggerUrlDTO.swaggerUrl,jdbcType=VARCHAR},
|
||||
#{apiSwaggerUrlDTO.scheduleId,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<select id="list" resultType="io.metersphere.dto.ScheduleDao">
|
||||
select schedule.* from schedule
|
||||
<where>
|
||||
|
@ -37,31 +43,53 @@
|
|||
</select>
|
||||
|
||||
<select id="countTaskByProjectId" resultType="java.lang.Long">
|
||||
SELECT COUNT(id) AS countNumber FROM `schedule` WHERE resource_id IN (
|
||||
SELECT COUNT(id) AS countNumber
|
||||
FROM `schedule`
|
||||
WHERE resource_id IN (
|
||||
SELECT id FROM api_scenario WHERE project_id = #{0,jdbcType=VARCHAR} AND status != 'Trash'
|
||||
)
|
||||
)
|
||||
</select>
|
||||
<select id="countTaskByProjectIdAndCreateTimeRange" resultType="java.lang.Long">
|
||||
SELECT COUNT(id) AS countNumber FROM `schedule`
|
||||
SELECT COUNT(id) AS countNumber
|
||||
FROM `schedule`
|
||||
WHERE resource_id IN (
|
||||
SELECT scene.id FROM api_scenario scene
|
||||
WHERE scene.project_id = #{projectId,jdbcType=VARCHAR} AND scene.status != 'Trash'
|
||||
SELECT scene.id
|
||||
FROM api_scenario scene
|
||||
WHERE scene.project_id = #{projectId,jdbcType=VARCHAR}
|
||||
AND scene.status != 'Trash'
|
||||
)
|
||||
AND create_time BETWEEN #{startTime} and #{endTime}
|
||||
AND create_time BETWEEN #{startTime} and #{endTime}
|
||||
</select>
|
||||
<select id="findRunningTaskInfoByProjectID" resultType="io.metersphere.api.dto.datacount.response.TaskInfoResult">
|
||||
SELECT apiScene.id AS scenarioId,apiScene.`name` AS `name` ,sch.id AS taskID,sch.`value` AS rule,sch.`enable` AS `taskStatus`,u.`name` AS creator,sch.update_time AS updateTime,
|
||||
'scenario' AS taskType
|
||||
SELECT apiScene.id AS scenarioId,
|
||||
apiScene.`name` AS `name`,
|
||||
sch.id AS taskID,
|
||||
sch.`value` AS rule,
|
||||
sch.`enable` AS `taskStatus`,
|
||||
u.`name` AS creator,
|
||||
sch.update_time AS updateTime,
|
||||
'scenario' AS taskType
|
||||
FROM api_scenario apiScene
|
||||
INNER JOIN `schedule` sch ON apiScene.id = sch.resource_id
|
||||
INNER JOIN `user` u ON u.id = sch.user_id
|
||||
WHERE sch.`enable` = true AND apiScene.project_id = #{0,jdbcType=VARCHAR}
|
||||
INNER JOIN `schedule` sch ON apiScene.id = sch.resource_id
|
||||
INNER JOIN `user` u ON u.id = sch.user_id
|
||||
WHERE sch.`enable` = true
|
||||
AND apiScene.project_id = #{0,jdbcType=VARCHAR}
|
||||
UNION
|
||||
SELECT testPlan.id AS scenarioId,testPlan.`name` AS `name`,sch.id AS taskID,sch.`value` AS rule,sch.`enable` AS `taskStatus`,u.`name` AS creator,sch.update_time AS updateTime,
|
||||
'testPlan' AS taskType
|
||||
SELECT testPlan.id AS scenarioId,
|
||||
testPlan.`name` AS `name`,
|
||||
sch.id AS taskID,
|
||||
sch.`value` AS rule,
|
||||
sch.`enable` AS `taskStatus`,
|
||||
u.`name` AS creator,
|
||||
sch.update_time AS updateTime,
|
||||
'testPlan' AS taskType
|
||||
FROM test_plan testPlan
|
||||
INNER JOIN `schedule` sch ON testPlan.id = sch.resource_id
|
||||
INNER JOIN `user` u ON u.id = sch.user_id
|
||||
WHERE sch.`enable` = true AND testPlan.project_id = #{0,jdbcType=VARCHAR}
|
||||
INNER JOIN `schedule` sch ON testPlan.id = sch.resource_id
|
||||
INNER JOIN `user` u ON u.id = sch.user_id
|
||||
WHERE sch.`enable` = true
|
||||
AND testPlan.project_id = #{0,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<select id="select" resultType="io.metersphere.api.dto.definition.ApiSwaggerUrlDTO">
|
||||
select * from swagger_url_project where id=#{id}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,11 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import io.metersphere.api.dto.swaggerurl.SwaggerTaskResult;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtSwaggerUrlScheduleMapper {
|
||||
//接口列表定时导入
|
||||
List<SwaggerTaskResult> getSwaggerTaskList(@Param("projectId") String projectId);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="io.metersphere.base.mapper.ext.ExtSwaggerUrlScheduleMapper">
|
||||
<select id="getSwaggerTaskList" resultType="io.metersphere.api.dto.swaggerurl.SwaggerTaskResult"
|
||||
parameterType="java.lang.String">
|
||||
SELECT sup.id as SwaggerUrlId,
|
||||
sup.swagger_url as swaggerUrl,
|
||||
sup.module_path as modulePath,
|
||||
sch.value as rule,
|
||||
sch.enable as taskStatus,
|
||||
sch.id as taskId
|
||||
FROM swagger_url_project sup
|
||||
INNER JOIN schedule sch ON sup.id = sch.resource_id
|
||||
WHERE sup.project_id = #{projectId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import io.metersphere.base.domain.TestPlan;
|
||||
import io.metersphere.track.dto.TestPlanDTO;
|
||||
import io.metersphere.track.dto.TestPlanDTOWithMetric;
|
||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||
|
@ -32,4 +33,6 @@ public interface ExtTestPlanMapper {
|
|||
String findScheduleCreateUserById(String testPlanId);
|
||||
|
||||
List<String> findIdByPerformanceReportId(String reportId);
|
||||
|
||||
List<TestPlan> listRecent(@Param("userId") String userId, @Param("projectId") String currentProjectId);
|
||||
}
|
||||
|
|
|
@ -240,5 +240,16 @@
|
|||
WHERE reportData.performance_info like CONCAT('%', #{0},'%')
|
||||
AND report.is_performance_executing = true;
|
||||
</select>
|
||||
<select id="listRecent" resultType="io.metersphere.base.domain.TestPlan">
|
||||
select distinct test_plan.*
|
||||
from test_plan
|
||||
<where>
|
||||
<if test="projectId != null">
|
||||
and test_plan.project_id = #{projectId}
|
||||
</if>
|
||||
and (test_plan.creator = #{userId} or test_plan.principal = #{userId})
|
||||
</where>
|
||||
order by test_plan.update_time desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -1,5 +1,5 @@
|
|||
package io.metersphere.commons.constants;
|
||||
|
||||
public enum ApiRunMode {
|
||||
RUN, DEBUG, DEFINITION,SCENARIO, API_PLAN, SCENARIO_PLAN,API,SCHEDULE_API_PLAN,SCHEDULE_SCENARIO_PLAN,SCHEDULE_PERFORMANCE_TEST
|
||||
RUN, DEBUG, DEFINITION, SCENARIO, API_PLAN, JENKINS, SCENARIO_PLAN, API, SCHEDULE_API_PLAN, SCHEDULE_SCENARIO_PLAN, SCHEDULE_PERFORMANCE_TEST
|
||||
}
|
||||
|
|
|
@ -290,12 +290,11 @@ public class ScheduleManager {
|
|||
addOrUpdateCronJob(jobKey, triggerKey, jobClass, cron, null);
|
||||
}
|
||||
|
||||
public JobDataMap getDefaultJobDataMap(String resourceId, String expression, String userId,String swaggerUrl) {
|
||||
public JobDataMap getDefaultJobDataMap(String resourceId, String expression, String userId) {
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.put("resourceId", resourceId);
|
||||
jobDataMap.put("expression", expression);
|
||||
jobDataMap.put("userId", userId);
|
||||
jobDataMap.put("swaggerUrl",swaggerUrl);
|
||||
return jobDataMap;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package io.metersphere.job.sechedule;
|
||||
|
||||
import io.metersphere.api.dto.ApiTestImportRequest;
|
||||
import io.metersphere.api.dto.definition.ApiSwaggerUrlDTO;
|
||||
import io.metersphere.api.service.ApiDefinitionService;
|
||||
import io.metersphere.base.domain.SwaggerUrlProject;
|
||||
import io.metersphere.commons.constants.ScheduleGroup;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.service.ScheduleService;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobKey;
|
||||
|
@ -20,12 +23,15 @@ public class SwaggerUrlImportJob extends MsScheduleJob {
|
|||
void businessExecute(JobExecutionContext context) {
|
||||
JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
|
||||
String resourceId = jobDataMap.getString("resourceId");
|
||||
String swaggerUrl = jobDataMap.getString("swaggerUrl");
|
||||
SwaggerUrlProject swaggerUrlProject=apiDefinitionService.getSwaggerInfo(resourceId);
|
||||
ApiTestImportRequest request = new ApiTestImportRequest();
|
||||
request.setProjectId(resourceId);
|
||||
request.setSwaggerUrl(swaggerUrl);
|
||||
request.setProjectId(swaggerUrlProject.getProjectId());
|
||||
request.setSwaggerUrl(swaggerUrlProject.getSwaggerUrl());
|
||||
request.setModuleId(swaggerUrlProject.getModuleId());
|
||||
request.setPlatform("Swagger2");
|
||||
request.setSaved(true);
|
||||
request.setUserId(jobDataMap.getString("userId"));
|
||||
request.setType("schedule");
|
||||
apiDefinitionService.apiTestImport(null, request);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,10 @@ package io.metersphere.service;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.metersphere.api.dto.datacount.response.TaskInfoResult;
|
||||
import io.metersphere.base.domain.Schedule;
|
||||
import io.metersphere.base.domain.ScheduleExample;
|
||||
import io.metersphere.base.domain.User;
|
||||
import io.metersphere.base.domain.UserExample;
|
||||
import io.metersphere.api.dto.definition.ApiSwaggerUrlDTO;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.ScheduleMapper;
|
||||
import io.metersphere.base.mapper.SwaggerUrlProjectMapper;
|
||||
import io.metersphere.base.mapper.UserMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtScheduleMapper;
|
||||
import io.metersphere.commons.constants.ScheduleGroup;
|
||||
|
@ -49,6 +48,8 @@ public class ScheduleService {
|
|||
private ExtScheduleMapper extScheduleMapper;
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
@Resource
|
||||
private SwaggerUrlProjectMapper swaggerUrlProjectMapper;
|
||||
|
||||
public void addSchedule(Schedule schedule) {
|
||||
schedule.setId(UUID.randomUUID().toString());
|
||||
|
@ -57,6 +58,12 @@ public class ScheduleService {
|
|||
schedule.setUpdateTime(System.currentTimeMillis());
|
||||
scheduleMapper.insert(schedule);
|
||||
}
|
||||
public void addSwaggerUrlSchedule(SwaggerUrlProject swaggerUrlProject) {
|
||||
swaggerUrlProjectMapper.insert(swaggerUrlProject);
|
||||
}
|
||||
public ApiSwaggerUrlDTO selectApiSwaggerUrlDTO(String id){
|
||||
return extScheduleMapper.select(id);
|
||||
}
|
||||
|
||||
public Schedule getSchedule(String ScheduleId) {
|
||||
return scheduleMapper.selectByPrimaryKey(ScheduleId);
|
||||
|
@ -111,7 +118,7 @@ public class ScheduleService {
|
|||
LogUtil.error("初始化任务:" + JSON.toJSONString(schedule));
|
||||
scheduleManager.addOrUpdateCronJob(new JobKey(schedule.getKey(), schedule.getGroup()),
|
||||
new TriggerKey(schedule.getKey(), schedule.getGroup()), Class.forName(schedule.getJob()), schedule.getValue(),
|
||||
scheduleManager.getDefaultJobDataMap(schedule.getResourceId(), schedule.getValue(), schedule.getUserId(),schedule.getSwaggerUrl()));
|
||||
scheduleManager.getDefaultJobDataMap(schedule.getResourceId(), schedule.getValue(), schedule.getUserId()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error("初始化任务失败", e);
|
||||
|
@ -140,7 +147,7 @@ public class ScheduleService {
|
|||
if (enable != null && enable && StringUtils.isNotBlank(cronExpression)) {
|
||||
try {
|
||||
scheduleManager.addOrUpdateCronJob(jobKey, triggerKey, clazz, cronExpression,
|
||||
scheduleManager.getDefaultJobDataMap(request.getResourceId(), cronExpression, SessionUtils.getUser().getId(),request.getSwaggerUrl()));
|
||||
scheduleManager.getDefaultJobDataMap(request.getResourceId(), cronExpression, SessionUtils.getUser().getId()));
|
||||
} catch (SchedulerException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
MSException.throwException("定时任务开启异常");
|
||||
|
|
|
@ -66,9 +66,8 @@ public class TestPlanController {
|
|||
|
||||
@GetMapping("recent/{count}")
|
||||
public List<TestPlan> recentTestPlans(@PathVariable int count) {
|
||||
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
|
||||
PageHelper.startPage(1, count, true);
|
||||
return testPlanService.recentTestPlans(currentWorkspaceId);
|
||||
return testPlanService.recentTestPlans();
|
||||
}
|
||||
|
||||
@PostMapping("/get/{testPlanId}")
|
||||
|
|
|
@ -14,6 +14,7 @@ public class TestCaseDTO extends TestCaseWithBLOBs {
|
|||
private String maintainerName;
|
||||
private String apiName;
|
||||
private String performName;
|
||||
private String lastResultId;
|
||||
|
||||
private List<String> caseTags = new ArrayList<>();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ public class LoadReportStatusEvent implements LoadTestFinishEvent {
|
|||
|
||||
@Override
|
||||
public void execute(LoadTestReport loadTestReport) {
|
||||
if (StringUtils.equals(ReportTriggerMode.CASE.name(), loadTestReport.getTriggerMode())) {
|
||||
if (StringUtils.equals(ReportTriggerMode.CASE.name(), loadTestReport.getTriggerMode())
|
||||
|| StringUtils.equals(ReportTriggerMode.TEST_PLAN_SCHEDULE.name(), loadTestReport.getTriggerMode())) {
|
||||
if (StringUtils.equalsAny(loadTestReport.getStatus(),
|
||||
PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) {
|
||||
updateLoadCaseStatus(loadTestReport);
|
||||
|
|
|
@ -139,4 +139,8 @@ public class TestPlanLoadCaseService {
|
|||
testPlanLoadCaseMapper.updateByPrimaryKeySelective(testPlanLoadCase);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getStatus(String planId) {
|
||||
return extTestPlanLoadCaseMapper.getStatusByTestPlanId(planId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,6 +104,8 @@ public class TestPlanService {
|
|||
private ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper;
|
||||
@Resource
|
||||
private ExtTestPlanLoadCaseMapper extTestPlanLoadCaseMapper;
|
||||
@Resource
|
||||
private ExtTestPlanScenarioCaseMapper extTestPlanScenarioCaseMapper;
|
||||
|
||||
public synchronized void addTestPlan(AddTestPlanRequest testPlan) {
|
||||
if (getTestPlanByName(testPlan.getName()).size() > 0) {
|
||||
|
@ -380,7 +382,17 @@ public class TestPlanService {
|
|||
}
|
||||
});
|
||||
|
||||
testPlan.setTotal(apiExecResults.size() + scenarioExecResults.size() + functionalExecResults.size());
|
||||
List<String> loadResults = testPlanLoadCaseService.getStatus(testPlan.getId());
|
||||
loadResults.forEach(item -> {
|
||||
if (StringUtils.isNotBlank(item)) {
|
||||
testPlan.setTested(testPlan.getTested() + 1);
|
||||
if (StringUtils.equals(item, "success")) {
|
||||
testPlan.setPassed(testPlan.getPassed() + 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
testPlan.setTotal(apiExecResults.size() + scenarioExecResults.size() + functionalExecResults.size() + loadResults.size());
|
||||
|
||||
testPlan.setPassRate(MathUtils.getPercentWithDecimal(testPlan.getTested() == 0 ? 0 : testPlan.getPassed() * 1.0 / testPlan.getTested()));
|
||||
testPlan.setTestRate(MathUtils.getPercentWithDecimal(testPlan.getTotal() == 0 ? 0 : testPlan.getTested() * 1.0 / testPlan.getTotal()));
|
||||
|
@ -455,26 +467,8 @@ public class TestPlanService {
|
|||
}
|
||||
}
|
||||
|
||||
public List<TestPlan> recentTestPlans(String currentWorkspaceId) {
|
||||
if (StringUtils.isBlank(currentWorkspaceId)) {
|
||||
return null;
|
||||
}
|
||||
if (StringUtils.isNotBlank(SessionUtils.getCurrentProjectId())) {
|
||||
TestPlanExample testPlanExample = new TestPlanExample();
|
||||
TestPlanExample.Criteria criteria = testPlanExample.createCriteria();
|
||||
criteria.andProjectIdEqualTo(SessionUtils.getCurrentProjectId());
|
||||
List<TestPlan> testPlans = testPlanMapper.selectByExample(testPlanExample);
|
||||
if (!CollectionUtils.isEmpty(testPlans)) {
|
||||
List<String> testPlanIds = testPlans.stream().map(TestPlan::getId).collect(Collectors.toList());
|
||||
TestPlanExample testPlanTestCaseExample = new TestPlanExample();
|
||||
testPlanTestCaseExample.createCriteria().andWorkspaceIdEqualTo(currentWorkspaceId)
|
||||
.andIdIn(testPlanIds)
|
||||
.andPrincipalEqualTo(SessionUtils.getUserId());
|
||||
testPlanTestCaseExample.setOrderByClause("update_time desc");
|
||||
return testPlanMapper.selectByExample(testPlanTestCaseExample);
|
||||
}
|
||||
}
|
||||
return new ArrayList<>();
|
||||
public List<TestPlan> recentTestPlans() {
|
||||
return extTestPlanMapper.listRecent(SessionUtils.getUserId(), SessionUtils.getCurrentProjectId());
|
||||
}
|
||||
|
||||
public List<TestPlan> listTestAllPlan(String currentWorkspaceId) {
|
||||
|
@ -602,6 +596,14 @@ public class TestPlanService {
|
|||
}
|
||||
}
|
||||
|
||||
// test-plan-scenario-case status
|
||||
List<String> scenarioStatusList = extTestPlanScenarioCaseMapper.getExecResultByPlanId(planId);
|
||||
for (String scenarioStatus : scenarioStatusList) {
|
||||
if (scenarioStatus == null) {
|
||||
return TestPlanStatus.Underway.name();
|
||||
}
|
||||
}
|
||||
|
||||
// test-plan-load-case status
|
||||
List<String> loadStatusList = extTestPlanLoadCaseMapper.getStatusByTestPlanId(planId);
|
||||
for (String loadStatus : loadStatusList) {
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
create table swagger_url_project
|
||||
(
|
||||
id varchar(255) not null,
|
||||
project_id varchar(255) null,
|
||||
swagger_url varchar(255) null,
|
||||
module_id varchar(255) null,
|
||||
module_path varchar(255) null,
|
||||
mode_id varchar(255) null,
|
||||
primary key (id)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
|
|
@ -65,6 +65,7 @@
|
|||
<!--要生成的数据库表 -->
|
||||
|
||||
<table tableName="auth_source"/>
|
||||
<table tableName="swagger_url_project"/>
|
||||
<!--<table tableName="test_plan_api_scenario"/>-->
|
||||
<!--<table tableName="test_plan"/>-->
|
||||
<!--<table tableName="api_scenario_report"/>-->
|
||||
|
|
|
@ -6,7 +6,10 @@
|
|||
:show-create="false"/>
|
||||
</template>
|
||||
|
||||
<el-table ref="scenarioTable" border :data="tableData" class="adjust-table ms-select-all-fixed" @select-all="select" @select="select"
|
||||
<el-table ref="scenarioTable" border :data="tableData" class="adjust-table ms-select-all-fixed"
|
||||
@sort-change="sort"
|
||||
@filter-change="filter"
|
||||
@select-all="select" @select="select"
|
||||
v-loading="loading">
|
||||
|
||||
<el-table-column type="selection" width="50"/>
|
||||
|
@ -24,36 +27,53 @@
|
|||
</el-table-column>
|
||||
|
||||
<el-table-column prop="num" label="ID"
|
||||
sortable="custom"
|
||||
show-overflow-tooltip/>
|
||||
<el-table-column prop="name" :label="$t('api_test.automation.scenario_name')"
|
||||
show-overflow-tooltip/>
|
||||
<el-table-column prop="level" :label="$t('api_test.automation.case_level')"
|
||||
show-overflow-tooltip>
|
||||
<el-table-column prop="name"
|
||||
sortable="custom"
|
||||
:label="$t('api_test.automation.scenario_name')"
|
||||
show-overflow-tooltip
|
||||
min-width="100px"/>
|
||||
<el-table-column prop="level"
|
||||
sortable="custom"
|
||||
column-key="level"
|
||||
:filters="levelFilters"
|
||||
:label="$t('api_test.automation.case_level')"
|
||||
show-overflow-tooltip min-width="120px">
|
||||
<template v-slot:default="scope">
|
||||
<priority-table-item :value="scope.row.level"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" :label="$t('test_track.plan.plan_status')"
|
||||
show-overflow-tooltip>
|
||||
sortable="custom"
|
||||
column-key="status"
|
||||
:filters="statusFilters"
|
||||
show-overflow-tooltip min-width="120px">
|
||||
<template v-slot:default="scope">
|
||||
<plan-status-table-item :value="scope.row.status"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="tags" :label="$t('api_test.automation.tag')" width="200px">
|
||||
<el-table-column prop="tags" :label="$t('api_test.automation.tag')">
|
||||
<template v-slot:default="scope">
|
||||
<div v-for="(itemName,index) in scope.row.tags" :key="index">
|
||||
<ms-tag type="success" effect="plain" :content="itemName"/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="userId" :label="$t('api_test.automation.creator')" show-overflow-tooltip/>
|
||||
<el-table-column prop="updateTime" :label="$t('api_test.automation.update_time')" width="180">
|
||||
<el-table-column prop="userId" :label="$t('api_test.automation.creator')"
|
||||
:filters="userFilters"
|
||||
column-key="user_id"
|
||||
sortable="custom"
|
||||
show-overflow-tooltip/>
|
||||
<el-table-column prop="updateTime" :label="$t('api_test.automation.update_time')" sortable="custom" width="180">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="stepTotal" :label="$t('api_test.automation.step')" show-overflow-tooltip/>
|
||||
<el-table-column prop="lastResult" :label="$t('api_test.automation.last_result')">
|
||||
<el-table-column prop="lastResult" :label="$t('api_test.automation.last_result')"
|
||||
:filters="resultFilters"
|
||||
sortable="custom" column-key="last_result" min-width="120px">
|
||||
<template v-slot:default="{row}">
|
||||
<el-link type="success" @click="showReport(row)" v-if="row.lastResult === 'Success'">
|
||||
{{ $t('api_test.automation.success') }}
|
||||
|
@ -112,439 +132,476 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import MsTableHeader from "@/business/components/common/components/MsTableHeader";
|
||||
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
|
||||
import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn";
|
||||
import MsTag from "../../../common/components/MsTag";
|
||||
import {getUUID, getCurrentProjectID} from "@/common/js/utils";
|
||||
import MsApiReportDetail from "../report/ApiReportDetail";
|
||||
import MsTableMoreBtn from "./TableMoreBtn";
|
||||
import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns";
|
||||
import MsTestPlanList from "./testplan/TestPlanList";
|
||||
// import MsTableSelectAll from "../../../common/components/table/MsTableSelectAll";
|
||||
import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover";
|
||||
import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components";
|
||||
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton";
|
||||
import PriorityTableItem from "../../../track/common/tableItems/planview/PriorityTableItem";
|
||||
import PlanStatusTableItem from "../../../track/common/tableItems/plan/PlanStatusTableItem";
|
||||
import BatchEdit from "../../../track/case/components/BatchEdit";
|
||||
import {WORKSPACE_ID} from "../../../../../common/js/constants";
|
||||
import EnvironmentSelect from "../../definition/components/environment/EnvironmentSelect";
|
||||
import BatchMove from "../../../track/case/components/BatchMove";
|
||||
import MsTableHeader from "@/business/components/common/components/MsTableHeader";
|
||||
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
|
||||
import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn";
|
||||
import MsTag from "../../../common/components/MsTag";
|
||||
import {_filter, _sort, getCurrentProjectID, getUUID} from "@/common/js/utils";
|
||||
import MsApiReportDetail from "../report/ApiReportDetail";
|
||||
import MsTableMoreBtn from "./TableMoreBtn";
|
||||
import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns";
|
||||
import MsTestPlanList from "./testplan/TestPlanList";
|
||||
import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover";
|
||||
import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components";
|
||||
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton";
|
||||
import PriorityTableItem from "../../../track/common/tableItems/planview/PriorityTableItem";
|
||||
import PlanStatusTableItem from "../../../track/common/tableItems/plan/PlanStatusTableItem";
|
||||
import BatchEdit from "../../../track/case/components/BatchEdit";
|
||||
import {WORKSPACE_ID} from "../../../../../common/js/constants";
|
||||
import EnvironmentSelect from "../../definition/components/environment/EnvironmentSelect";
|
||||
import BatchMove from "../../../track/case/components/BatchMove";
|
||||
|
||||
export default {
|
||||
name: "MsApiScenarioList",
|
||||
components: {
|
||||
BatchMove,
|
||||
EnvironmentSelect,
|
||||
BatchEdit,
|
||||
PlanStatusTableItem,
|
||||
PriorityTableItem,
|
||||
MsTableHeaderSelectPopover,
|
||||
MsTablePagination,
|
||||
MsTableMoreBtn,
|
||||
ShowMoreBtn,
|
||||
MsTableHeader,
|
||||
MsTag,
|
||||
MsApiReportDetail,
|
||||
MsScenarioExtendButtons,
|
||||
MsTestPlanList,
|
||||
MsTableOperatorButton
|
||||
export default {
|
||||
name: "MsApiScenarioList",
|
||||
components: {
|
||||
BatchMove,
|
||||
EnvironmentSelect,
|
||||
BatchEdit,
|
||||
PlanStatusTableItem,
|
||||
PriorityTableItem,
|
||||
MsTableHeaderSelectPopover,
|
||||
MsTablePagination,
|
||||
MsTableMoreBtn,
|
||||
ShowMoreBtn,
|
||||
MsTableHeader,
|
||||
MsTag,
|
||||
MsApiReportDetail,
|
||||
MsScenarioExtendButtons,
|
||||
MsTestPlanList,
|
||||
MsTableOperatorButton
|
||||
},
|
||||
props: {
|
||||
referenced: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
props: {
|
||||
referenced: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
selectNodeIds: Array,
|
||||
trashEnable: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
moduleTree: {
|
||||
type: Array,
|
||||
default() {
|
||||
return []
|
||||
},
|
||||
},
|
||||
moduleOptions: {
|
||||
type: Array,
|
||||
default() {
|
||||
return []
|
||||
},
|
||||
}
|
||||
selectNodeIds: Array,
|
||||
trashEnable: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
condition: {
|
||||
components: API_CASE_CONFIGS
|
||||
},
|
||||
currentScenario: {},
|
||||
schedule: {},
|
||||
selection: [],
|
||||
tableData: [],
|
||||
selectDataRange: 'all',
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
reportId: "",
|
||||
batchReportId: "",
|
||||
content: {},
|
||||
infoDb: false,
|
||||
runVisible: false,
|
||||
planVisible: false,
|
||||
projectId: "",
|
||||
runData: [],
|
||||
report: {},
|
||||
selectDataSize: 0,
|
||||
selectAll: false,
|
||||
buttons: [
|
||||
{
|
||||
name: this.$t('api_test.automation.batch_add_plan'), handleClick: this.handleBatchAddCase
|
||||
},
|
||||
{
|
||||
name: this.$t('api_test.automation.batch_execute'), handleClick: this.handleBatchExecute
|
||||
},
|
||||
{
|
||||
name: this.$t('test_track.case.batch_edit_case'), handleClick: this.handleBatchEdit
|
||||
},
|
||||
{
|
||||
name: this.$t('test_track.case.batch_move_case'), handleClick: this.handleBatchMove
|
||||
}
|
||||
],
|
||||
isSelectAllDate: false,
|
||||
unSelection: [],
|
||||
selectDataCounts: 0,
|
||||
typeArr: [
|
||||
{id: 'level', name: this.$t('test_track.case.priority')},
|
||||
{id: 'status', name: this.$t('test_track.plan.plan_status')},
|
||||
{id: 'principal', name: this.$t('api_test.definition.request.responsible'), optionMethod: this.getPrincipalOptions},
|
||||
{id: 'environmentId', name: this.$t('api_test.definition.request.run_env'), optionMethod: this.getEnvsOptions},
|
||||
],
|
||||
valueArr: {
|
||||
level: [
|
||||
{name: 'P0', id: 'P0'},
|
||||
{name: 'P1', id: 'P1'},
|
||||
{name: 'P2', id: 'P2'},
|
||||
{name: 'P3', id: 'P3'}
|
||||
],
|
||||
status: [
|
||||
{name: this.$t('test_track.plan.plan_status_prepare'), id: 'Prepare'},
|
||||
{name: this.$t('test_track.plan.plan_status_running'), id: 'Underway'},
|
||||
{name: this.$t('test_track.plan.plan_status_completed'), id: 'Completed'}
|
||||
],
|
||||
principal: [],
|
||||
environmentId: []
|
||||
},
|
||||
}
|
||||
moduleTree: {
|
||||
type: Array,
|
||||
default() {
|
||||
return []
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.projectId = getCurrentProjectID();
|
||||
this.search();
|
||||
},
|
||||
watch: {
|
||||
selectNodeIds() {
|
||||
this.search();
|
||||
},
|
||||
trashEnable() {
|
||||
if (this.trashEnable) {
|
||||
this.search();
|
||||
}
|
||||
},
|
||||
batchReportId() {
|
||||
this.loading = true;
|
||||
this.getReport();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isNotRunning() {
|
||||
return "Running" !== this.report.status;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
selectByParam() {
|
||||
this.changeSelectDataRangeAll();
|
||||
this.search();
|
||||
},
|
||||
search() {
|
||||
this.condition.filters = ["Prepare", "Underway", "Completed"];
|
||||
this.condition.moduleIds = this.selectNodeIds;
|
||||
if (this.trashEnable) {
|
||||
this.condition.filters = ["Trash"];
|
||||
this.condition.moduleIds = [];
|
||||
}
|
||||
|
||||
if (this.projectId != null) {
|
||||
this.condition.projectId = this.projectId;
|
||||
}
|
||||
|
||||
//检查是否只查询本周数据
|
||||
this.condition.selectThisWeedData = false;
|
||||
this.condition.executeStatus = null;
|
||||
this.isSelectThissWeekData();
|
||||
switch (this.selectDataRange) {
|
||||
case 'thisWeekCount':
|
||||
this.condition.selectThisWeedData = true;
|
||||
break;
|
||||
case 'unExecute':
|
||||
this.condition.executeStatus = 'unExecute';
|
||||
break;
|
||||
case 'executeFailed':
|
||||
this.condition.executeStatus = 'executeFailed';
|
||||
break;
|
||||
case 'executePass':
|
||||
this.condition.executeStatus = 'executePass';
|
||||
break;
|
||||
}
|
||||
this.selection = [];
|
||||
this.selectAll = false;
|
||||
this.unSelection = [];
|
||||
this.selectDataCounts = 0;
|
||||
let url = "/api/automation/list/" + this.currentPage + "/" + this.pageSize;
|
||||
if (this.condition.projectId) {
|
||||
this.loading = true;
|
||||
this.$post(url, this.condition, response => {
|
||||
let data = response.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
this.tableData.forEach(item => {
|
||||
if (item.tags && item.tags.length > 0) {
|
||||
item.tags = JSON.parse(item.tags);
|
||||
}
|
||||
});
|
||||
this.loading = false;
|
||||
this.unSelection = data.listObject.map(s => s.id);
|
||||
});
|
||||
}
|
||||
},
|
||||
handleCommand(cmd) {
|
||||
let table = this.$refs.scenarioTable;
|
||||
switch (cmd) {
|
||||
case "table":
|
||||
this.selectAll = false;
|
||||
table.toggleAllSelection();
|
||||
break;
|
||||
case "all":
|
||||
this.selectAll = true;
|
||||
break
|
||||
}
|
||||
},
|
||||
handleBatchAddCase() {
|
||||
this.planVisible = true;
|
||||
},
|
||||
handleBatchEdit() {
|
||||
this.$refs.batchEdit.open(this.selectDataCounts);
|
||||
},
|
||||
handleBatchMove() {
|
||||
this.$refs.testBatchMove.open(this.moduleTree, [], this.moduleOptions);
|
||||
},
|
||||
moveSave(param) {
|
||||
this.buildBatchParam(param);
|
||||
param.apiScenarioModuleId = param.nodeId;
|
||||
this.$post('/api/automation/batch/edit', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.$refs.testBatchMove.close();
|
||||
this.search();
|
||||
});
|
||||
},
|
||||
batchEdit(form) {
|
||||
let param = {};
|
||||
param[form.type] = form.value;
|
||||
this.buildBatchParam(param);
|
||||
this.$post('/api/automation/batch/edit', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.search();
|
||||
});
|
||||
},
|
||||
getPrincipalOptions(option) {
|
||||
let workspaceId = localStorage.getItem(WORKSPACE_ID);
|
||||
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
|
||||
option.push(...response.data);
|
||||
});
|
||||
},
|
||||
getEnvsOptions(option) {
|
||||
this.$get('/api/environment/list/' + this.projectId, response => {
|
||||
option.push(...response.data);
|
||||
option.forEach(environment => {
|
||||
if (!(environment.config instanceof Object)) {
|
||||
environment.config = JSON.parse(environment.config);
|
||||
}
|
||||
environment.name = environment.name + (environment.config.httpConfig.socket ?
|
||||
(': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '');
|
||||
});
|
||||
});
|
||||
},
|
||||
addTestPlan(plans) {
|
||||
let obj = {planIds: plans, scenarioIds: this.selection};
|
||||
|
||||
obj.projectId = getCurrentProjectID();
|
||||
obj.selectAllDate = this.isSelectAllDate;
|
||||
obj.unSelectIds = this.unSelection;
|
||||
obj = Object.assign(obj, this.condition);
|
||||
|
||||
this.planVisible = false;
|
||||
this.$post("/api/automation/scenario/plan", obj, response => {
|
||||
this.$success(this.$t("commons.save_success"));
|
||||
});
|
||||
},
|
||||
getReport() {
|
||||
if (this.batchReportId) {
|
||||
let url = "/api/scenario/report/get/" + this.batchReportId;
|
||||
this.$get(url, response => {
|
||||
this.report = response.data || {};
|
||||
if (response.data) {
|
||||
if (this.isNotRunning) {
|
||||
try {
|
||||
this.content = JSON.parse(this.report.content);
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
this.loading = false;
|
||||
this.$success("批量执行成功,请到报告页面查看详情!");
|
||||
} else {
|
||||
setTimeout(this.getReport, 2000)
|
||||
}
|
||||
} else {
|
||||
this.loading = false;
|
||||
this.$error(this.$t('api_report.not_exist'));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
buildBatchParam(param) {
|
||||
param.scenarioIds = this.selection;
|
||||
param.projectId = getCurrentProjectID();
|
||||
param.selectAllDate = this.isSelectAllDate;
|
||||
param.unSelectIds = this.unSelection;
|
||||
param = Object.assign(param, this.condition);
|
||||
},
|
||||
handleBatchExecute() {
|
||||
this.infoDb = false;
|
||||
let url = "/api/automation/run/batch";
|
||||
let run = {};
|
||||
run.id = getUUID();
|
||||
this.buildBatchParam(run);
|
||||
this.$post(url, run, response => {
|
||||
let data = response.data;
|
||||
this.runVisible = false;
|
||||
this.batchReportId = run.id;
|
||||
});
|
||||
},
|
||||
select(selection) {
|
||||
this.selection = selection.map(s => s.id);
|
||||
|
||||
//统计应当展示选择了多少行
|
||||
this.selectRowsCount(this.selection)
|
||||
|
||||
this.$emit('selection', selection);
|
||||
},
|
||||
isSelect(row) {
|
||||
return this.selection.includes(row.id)
|
||||
},
|
||||
edit(row) {
|
||||
let data = JSON.parse(JSON.stringify(row));
|
||||
this.$emit('edit', data);
|
||||
},
|
||||
reductionApi(row) {
|
||||
row.scenarioDefinition = null;
|
||||
row.tags = null;
|
||||
let rows = [row];
|
||||
this.$post("/api/automation/reduction", rows, response => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.search();
|
||||
})
|
||||
},
|
||||
execute(row) {
|
||||
this.infoDb = false;
|
||||
let url = "/api/automation/run";
|
||||
let run = {};
|
||||
let scenarioIds = [];
|
||||
scenarioIds.push(row.id);
|
||||
run.id = getUUID();
|
||||
run.projectId = getCurrentProjectID();
|
||||
run.scenarioIds = scenarioIds;
|
||||
this.$post(url, run, response => {
|
||||
let data = response.data;
|
||||
this.runVisible = true;
|
||||
this.reportId = run.id;
|
||||
});
|
||||
},
|
||||
copy(row) {
|
||||
let rowParam = JSON.parse(JSON.stringify(row));
|
||||
rowParam.copy = true;
|
||||
rowParam.name = 'copy_' + rowParam.name;
|
||||
this.$emit('edit', rowParam);
|
||||
},
|
||||
showReport(row) {
|
||||
this.runVisible = true;
|
||||
this.infoDb = true;
|
||||
this.reportId = row.reportId;
|
||||
},
|
||||
//是否选择了全部数据
|
||||
isSelectDataAll(dataType) {
|
||||
this.isSelectAllDate = dataType;
|
||||
this.selectRowsCount(this.selection);
|
||||
//如果已经全选,不需要再操作了
|
||||
if (this.selection.length != this.tableData.length) {
|
||||
this.$refs.scenarioTable.toggleAllSelection(true);
|
||||
}
|
||||
},
|
||||
//选择数据数量统计
|
||||
selectRowsCount(selection) {
|
||||
let selectedIDs = selection;
|
||||
let allIDs = this.tableData.map(s => s.id);
|
||||
this.unSelection = allIDs.filter(function (val) {
|
||||
return selectedIDs.indexOf(val) === -1
|
||||
});
|
||||
if (this.isSelectAllDate) {
|
||||
this.selectDataCounts = this.total - this.unSelection.length;
|
||||
} else {
|
||||
this.selectDataCounts = this.selection.length;
|
||||
}
|
||||
},
|
||||
//判断是否只显示本周的数据。 从首页跳转过来的请求会带有相关参数
|
||||
isSelectThissWeekData() {
|
||||
let dataRange = this.$route.params.dataSelectRange;
|
||||
this.selectDataRange = dataRange;
|
||||
},
|
||||
changeSelectDataRangeAll() {
|
||||
this.$emit("changeSelectDataRangeAll");
|
||||
},
|
||||
remove(row) {
|
||||
if (this.trashEnable) {
|
||||
this.$get('/api/automation/delete/' + row.id, () => {
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.search();
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + row.name + " ?", '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
let ids = [row.id];
|
||||
this.$post('/api/automation/removeToGc/', ids, () => {
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.search();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
moduleOptions: {
|
||||
type: Array,
|
||||
default() {
|
||||
return []
|
||||
},
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
condition: {
|
||||
components: API_CASE_CONFIGS
|
||||
},
|
||||
currentScenario: {},
|
||||
schedule: {},
|
||||
selection: [],
|
||||
tableData: [],
|
||||
selectDataRange: 'all',
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
reportId: "",
|
||||
batchReportId: "",
|
||||
content: {},
|
||||
infoDb: false,
|
||||
runVisible: false,
|
||||
planVisible: false,
|
||||
projectId: "",
|
||||
runData: [],
|
||||
report: {},
|
||||
selectDataSize: 0,
|
||||
selectAll: false,
|
||||
userFilters: [],
|
||||
buttons: [
|
||||
{
|
||||
name: this.$t('api_test.automation.batch_add_plan'), handleClick: this.handleBatchAddCase
|
||||
},
|
||||
{
|
||||
name: this.$t('api_test.automation.batch_execute'), handleClick: this.handleBatchExecute
|
||||
},
|
||||
{
|
||||
name: this.$t('test_track.case.batch_edit_case'), handleClick: this.handleBatchEdit
|
||||
},
|
||||
{
|
||||
name: this.$t('test_track.case.batch_move_case'), handleClick: this.handleBatchMove
|
||||
}
|
||||
],
|
||||
isSelectAllDate: false,
|
||||
unSelection: [],
|
||||
selectDataCounts: 0,
|
||||
typeArr: [
|
||||
{id: 'level', name: this.$t('test_track.case.priority')},
|
||||
{id: 'status', name: this.$t('test_track.plan.plan_status')},
|
||||
{id: 'principal', name: this.$t('api_test.definition.request.responsible'), optionMethod: this.getPrincipalOptions},
|
||||
{id: 'environmentId', name: this.$t('api_test.definition.request.run_env'), optionMethod: this.getEnvsOptions},
|
||||
],
|
||||
statusFilters: [
|
||||
{text: this.$t('test_track.plan.plan_status_prepare'), value: 'Prepare'},
|
||||
{text: this.$t('test_track.plan.plan_status_running'), value: 'Underway'},
|
||||
{text: this.$t('test_track.plan.plan_status_completed'), value: 'Completed'},
|
||||
{text: this.$t('test_track.plan.plan_status_trash'), value: 'Trash'},
|
||||
],
|
||||
levelFilters: [
|
||||
{text: 'P0', value: 'P0'},
|
||||
{text: 'P1', value: 'P1'},
|
||||
{text: 'P2', value: 'P2'},
|
||||
{text: 'P3', value: 'P3'}
|
||||
],
|
||||
resultFilters: [
|
||||
{text: 'Fail', value: 'Fail'},
|
||||
{text: 'Success', value: 'Success'}
|
||||
],
|
||||
valueArr: {
|
||||
level: [
|
||||
{name: 'P0', id: 'P0'},
|
||||
{name: 'P1', id: 'P1'},
|
||||
{name: 'P2', id: 'P2'},
|
||||
{name: 'P3', id: 'P3'}
|
||||
],
|
||||
status: [
|
||||
{name: this.$t('test_track.plan.plan_status_prepare'), id: 'Prepare'},
|
||||
{name: this.$t('test_track.plan.plan_status_running'), id: 'Underway'},
|
||||
{name: this.$t('test_track.plan.plan_status_completed'), id: 'Completed'}
|
||||
],
|
||||
principal: [],
|
||||
environmentId: []
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
|
||||
this.projectId = getCurrentProjectID();
|
||||
this.search();
|
||||
this.getPrincipalOptions([]);
|
||||
},
|
||||
watch: {
|
||||
selectNodeIds() {
|
||||
this.search();
|
||||
},
|
||||
trashEnable() {
|
||||
if (this.trashEnable) {
|
||||
this.condition.filters = {status: ["Trash"]};
|
||||
this.condition.moduleIds = [];
|
||||
} else {
|
||||
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
|
||||
}
|
||||
this.search();
|
||||
},
|
||||
batchReportId() {
|
||||
this.loading = true;
|
||||
this.getReport();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isNotRunning() {
|
||||
return "Running" !== this.report.status;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
selectByParam() {
|
||||
this.changeSelectDataRangeAll();
|
||||
this.search();
|
||||
},
|
||||
search() {
|
||||
this.condition.moduleIds = this.selectNodeIds;
|
||||
if (this.trashEnable) {
|
||||
this.condition.filters = {status: ["Trash"]};
|
||||
this.condition.moduleIds = [];
|
||||
}
|
||||
|
||||
if (this.projectId != null) {
|
||||
this.condition.projectId = this.projectId;
|
||||
}
|
||||
|
||||
//检查是否只查询本周数据
|
||||
this.condition.selectThisWeedData = false;
|
||||
this.condition.executeStatus = null;
|
||||
this.isSelectThissWeekData();
|
||||
switch (this.selectDataRange) {
|
||||
case 'thisWeekCount':
|
||||
this.condition.selectThisWeedData = true;
|
||||
break;
|
||||
case 'unExecute':
|
||||
this.condition.executeStatus = 'unExecute';
|
||||
break;
|
||||
case 'executeFailed':
|
||||
this.condition.executeStatus = 'executeFailed';
|
||||
break;
|
||||
case 'executePass':
|
||||
this.condition.executeStatus = 'executePass';
|
||||
break;
|
||||
}
|
||||
this.selection = [];
|
||||
this.selectAll = false;
|
||||
this.unSelection = [];
|
||||
this.selectDataCounts = 0;
|
||||
let url = "/api/automation/list/" + this.currentPage + "/" + this.pageSize;
|
||||
if (this.condition.projectId) {
|
||||
this.loading = true;
|
||||
this.$post(url, this.condition, response => {
|
||||
let data = response.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
this.tableData.forEach(item => {
|
||||
if (item.tags && item.tags.length > 0) {
|
||||
item.tags = JSON.parse(item.tags);
|
||||
}
|
||||
});
|
||||
this.loading = false;
|
||||
this.unSelection = data.listObject.map(s => s.id);
|
||||
});
|
||||
}
|
||||
},
|
||||
handleCommand(cmd) {
|
||||
let table = this.$refs.scenarioTable;
|
||||
switch (cmd) {
|
||||
case "table":
|
||||
this.selectAll = false;
|
||||
table.toggleAllSelection();
|
||||
break;
|
||||
case "all":
|
||||
this.selectAll = true;
|
||||
break
|
||||
}
|
||||
},
|
||||
handleBatchAddCase() {
|
||||
this.planVisible = true;
|
||||
},
|
||||
handleBatchEdit() {
|
||||
this.$refs.batchEdit.open(this.selectDataCounts);
|
||||
},
|
||||
handleBatchMove() {
|
||||
this.$refs.testBatchMove.open(this.moduleTree, [], this.moduleOptions);
|
||||
},
|
||||
moveSave(param) {
|
||||
this.buildBatchParam(param);
|
||||
param.apiScenarioModuleId = param.nodeId;
|
||||
this.$post('/api/automation/batch/edit', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.$refs.testBatchMove.close();
|
||||
this.search();
|
||||
});
|
||||
},
|
||||
batchEdit(form) {
|
||||
let param = {};
|
||||
param[form.type] = form.value;
|
||||
this.buildBatchParam(param);
|
||||
this.$post('/api/automation/batch/edit', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.search();
|
||||
});
|
||||
},
|
||||
getPrincipalOptions(option) {
|
||||
let workspaceId = localStorage.getItem(WORKSPACE_ID);
|
||||
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
|
||||
option.push(...response.data);
|
||||
this.userFilters = response.data.map(u => {
|
||||
return {text: u.name, value: u.id}
|
||||
});
|
||||
});
|
||||
},
|
||||
getEnvsOptions(option) {
|
||||
this.$get('/api/environment/list/' + this.projectId, response => {
|
||||
option.push(...response.data);
|
||||
option.forEach(environment => {
|
||||
if (!(environment.config instanceof Object)) {
|
||||
environment.config = JSON.parse(environment.config);
|
||||
}
|
||||
environment.name = environment.name + (environment.config.httpConfig.socket ?
|
||||
(': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '');
|
||||
});
|
||||
});
|
||||
},
|
||||
addTestPlan(plans) {
|
||||
let obj = {planIds: plans, scenarioIds: this.selection};
|
||||
|
||||
obj.projectId = getCurrentProjectID();
|
||||
obj.selectAllDate = this.isSelectAllDate;
|
||||
obj.unSelectIds = this.unSelection;
|
||||
obj = Object.assign(obj, this.condition);
|
||||
|
||||
this.planVisible = false;
|
||||
this.$post("/api/automation/scenario/plan", obj, response => {
|
||||
this.$success(this.$t("commons.save_success"));
|
||||
});
|
||||
},
|
||||
getReport() {
|
||||
if (this.batchReportId) {
|
||||
let url = "/api/scenario/report/get/" + this.batchReportId;
|
||||
this.$get(url, response => {
|
||||
this.report = response.data || {};
|
||||
if (response.data) {
|
||||
if (this.isNotRunning) {
|
||||
try {
|
||||
this.content = JSON.parse(this.report.content);
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
this.loading = false;
|
||||
this.$success("批量执行成功,请到报告页面查看详情!");
|
||||
} else {
|
||||
setTimeout(this.getReport, 2000)
|
||||
}
|
||||
} else {
|
||||
this.loading = false;
|
||||
this.$error(this.$t('api_report.not_exist'));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
buildBatchParam(param) {
|
||||
param.scenarioIds = this.selection;
|
||||
param.projectId = getCurrentProjectID();
|
||||
param.selectAllDate = this.isSelectAllDate;
|
||||
param.unSelectIds = this.unSelection;
|
||||
param = Object.assign(param, this.condition);
|
||||
},
|
||||
handleBatchExecute() {
|
||||
this.infoDb = false;
|
||||
let url = "/api/automation/run/batch";
|
||||
let run = {};
|
||||
run.id = getUUID();
|
||||
this.buildBatchParam(run);
|
||||
this.$post(url, run, response => {
|
||||
let data = response.data;
|
||||
this.runVisible = false;
|
||||
this.batchReportId = run.id;
|
||||
});
|
||||
},
|
||||
select(selection) {
|
||||
this.selection = selection.map(s => s.id);
|
||||
|
||||
//统计应当展示选择了多少行
|
||||
this.selectRowsCount(this.selection)
|
||||
|
||||
this.$emit('selection', selection);
|
||||
},
|
||||
isSelect(row) {
|
||||
return this.selection.includes(row.id)
|
||||
},
|
||||
edit(row) {
|
||||
let data = JSON.parse(JSON.stringify(row));
|
||||
this.$emit('edit', data);
|
||||
},
|
||||
reductionApi(row) {
|
||||
row.scenarioDefinition = null;
|
||||
row.tags = null;
|
||||
let rows = [row];
|
||||
this.$post("/api/automation/reduction", rows, response => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.search();
|
||||
})
|
||||
},
|
||||
execute(row) {
|
||||
this.infoDb = false;
|
||||
let url = "/api/automation/run";
|
||||
let run = {};
|
||||
let scenarioIds = [];
|
||||
scenarioIds.push(row.id);
|
||||
run.id = getUUID();
|
||||
run.projectId = getCurrentProjectID();
|
||||
run.scenarioIds = scenarioIds;
|
||||
this.$post(url, run, response => {
|
||||
let data = response.data;
|
||||
this.runVisible = true;
|
||||
this.reportId = run.id;
|
||||
});
|
||||
},
|
||||
copy(row) {
|
||||
let rowParam = JSON.parse(JSON.stringify(row));
|
||||
rowParam.copy = true;
|
||||
rowParam.name = 'copy_' + rowParam.name;
|
||||
this.$emit('edit', rowParam);
|
||||
},
|
||||
showReport(row) {
|
||||
this.runVisible = true;
|
||||
this.infoDb = true;
|
||||
this.reportId = row.reportId;
|
||||
},
|
||||
//是否选择了全部数据
|
||||
isSelectDataAll(dataType) {
|
||||
this.isSelectAllDate = dataType;
|
||||
this.selectRowsCount(this.selection);
|
||||
//如果已经全选,不需要再操作了
|
||||
if (this.selection.length != this.tableData.length) {
|
||||
this.$refs.scenarioTable.toggleAllSelection(true);
|
||||
}
|
||||
},
|
||||
//选择数据数量统计
|
||||
selectRowsCount(selection) {
|
||||
let selectedIDs = selection;
|
||||
let allIDs = this.tableData.map(s => s.id);
|
||||
this.unSelection = allIDs.filter(function (val) {
|
||||
return selectedIDs.indexOf(val) === -1
|
||||
});
|
||||
if (this.isSelectAllDate) {
|
||||
this.selectDataCounts = this.total - this.unSelection.length;
|
||||
} else {
|
||||
this.selectDataCounts = this.selection.length;
|
||||
}
|
||||
},
|
||||
//判断是否只显示本周的数据。 从首页跳转过来的请求会带有相关参数
|
||||
isSelectThissWeekData() {
|
||||
let dataRange = this.$route.params.dataSelectRange;
|
||||
this.selectDataRange = dataRange;
|
||||
},
|
||||
changeSelectDataRangeAll() {
|
||||
this.$emit("changeSelectDataRangeAll");
|
||||
},
|
||||
remove(row) {
|
||||
if (this.trashEnable) {
|
||||
this.$get('/api/automation/delete/' + row.id, () => {
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.search();
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + row.name + " ?", '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
let ids = [row.id];
|
||||
this.$post('/api/automation/removeToGc/', ids, () => {
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.search();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
sort(column) {
|
||||
// 每次只对一个字段排序
|
||||
if (this.condition.orders) {
|
||||
this.condition.orders = [];
|
||||
}
|
||||
_sort(column, this.condition);
|
||||
this.search();
|
||||
},
|
||||
filter(filters) {
|
||||
_filter(filters, this.condition);
|
||||
this.search();
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/deep/ .el-drawer__header {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
/deep/ .el-drawer__header {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
/deep/ .run-button {
|
||||
background-color: #409EFF;
|
||||
border-color: #409EFF;
|
||||
}
|
||||
|
||||
/deep/ .run-button {
|
||||
background-color: #409EFF;
|
||||
border-color: #409EFF;
|
||||
}
|
||||
/deep/ .el-table__fixed-body-wrapper {
|
||||
z-index: auto !important;
|
||||
}
|
||||
|
|
|
@ -873,6 +873,7 @@
|
|||
}
|
||||
this.enableCookieShare = obj.enableCookieShare;
|
||||
this.scenarioDefinition = obj.hashTree;
|
||||
console.log(this.scenarioDefinition)
|
||||
}
|
||||
}
|
||||
if (this.currentScenario.copy) {
|
||||
|
|
|
@ -25,10 +25,16 @@
|
|||
|
||||
<div class="header-right" @click.stop>
|
||||
<slot name="message"></slot>
|
||||
<el-switch v-model="data.enable" class="enable-switch"/>
|
||||
<el-tooltip :content="$t('test_resource_pool.enable_disable')" placement="top">
|
||||
<el-switch v-model="data.enable" class="enable-switch"/>
|
||||
</el-tooltip>
|
||||
<slot name="button"></slot>
|
||||
<el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow"/>
|
||||
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove"/>
|
||||
<el-tooltip content="Copy" placement="top">
|
||||
<el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow"/>
|
||||
</el-tooltip>
|
||||
<el-tooltip :content="$t('commons.remove')" placement="top">
|
||||
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove"/>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
</template>
|
||||
|
||||
<template v-slot:button>
|
||||
<el-button @click="run" :tip="$t('api_test.run')" icon="el-icon-video-play" style="background-color: #409EFF;color: white;" size="mini" circle/>
|
||||
<el-tooltip :content="$t('api_test.run')" placement="top">
|
||||
<el-button @click="run" icon="el-icon-video-play" style="background-color: #409EFF;color: white;" size="mini" circle/>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
|
||||
<div v-if="request.protocol === 'HTTP'">
|
||||
|
@ -36,13 +38,13 @@
|
|||
</el-input>
|
||||
</div>
|
||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||
<ms-api-request-form :referenced="true" :headers="request.headers " :request="request" v-if="request.protocol==='HTTP' || request.type==='HTTPSamplerProxy'"/>
|
||||
<ms-api-request-form :isShowEnable="true" :referenced="true" :headers="request.headers " :request="request" v-if="request.protocol==='HTTP' || request.type==='HTTPSamplerProxy'"/>
|
||||
<ms-tcp-basis-parameters :request="request" v-if="request.protocol==='TCP'|| request.type==='TCPSampler'"/>
|
||||
<ms-sql-basis-parameters :request="request" v-if="request.protocol==='SQL'|| request.type==='JDBCSampler'" :showScript="false"/>
|
||||
<ms-dubbo-basis-parameters :request="request" v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'" :showScript="false"/>
|
||||
|
||||
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
|
||||
<api-response-component :result="request.requestResult"/>
|
||||
<api-response-component :currentProtocol="request.protocol" :result="request.requestResult"/>
|
||||
|
||||
<!-- 保存操作 -->
|
||||
<el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(item)" v-if="!request.referenced">
|
||||
|
@ -86,7 +88,7 @@
|
|||
reqOptions: REQ_METHOD,
|
||||
reportId: "",
|
||||
runData: [],
|
||||
isShowInput: false
|
||||
isShowInput: false,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<el-collapse-transition>
|
||||
<div v-if="isActive">
|
||||
<el-divider></el-divider>
|
||||
<ms-request-result-tail :show-metric="false" :response="response"/>
|
||||
<ms-request-result-tail :currentProtocol="currentProtocol" :show-metric="false" :response="response"/>
|
||||
</div>
|
||||
</el-collapse-transition>
|
||||
</el-card>
|
||||
|
@ -24,7 +24,7 @@
|
|||
export default {
|
||||
name: "ApiResponseComponent",
|
||||
components: {ElCollapseTransition, MsRequestResultTail, ApiBaseComponent, MsRequestMetric},
|
||||
props: {apiItem: {}, result: {}},
|
||||
props: {apiItem: {}, result: {}, currentProtocol: String},
|
||||
data() {
|
||||
return {
|
||||
isActive: false,
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
title: this.$t('api_test.automation.customize_script'),
|
||||
title: "",
|
||||
titleColor: "",
|
||||
backgroundColor: "",
|
||||
}
|
||||
|
|
|
@ -1,53 +1,50 @@
|
|||
<template>
|
||||
<div>
|
||||
<div v-loading="loading">
|
||||
<span class="kv-description" v-if="description">
|
||||
{{ description }}
|
||||
</span>
|
||||
<ms-draggable element="ul" @update="endChange"
|
||||
v-model="keyValues" v-bind="{draggable:'.item'}">
|
||||
<div class="kv-row item" v-for="(item, index) in keyValues" :key="index">
|
||||
<el-row type="flex" :gutter="20" justify="space-between" align="middle">
|
||||
<el-button icon="el-icon-sort" circle size="mini"/>
|
||||
<div class="kv-row item" v-for="(item, index) in items" :key="index">
|
||||
<el-row type="flex" :gutter="20" justify="space-between" align="middle">
|
||||
<el-col class="kv-checkbox" v-if="isShowEnable">
|
||||
<input type="checkbox" v-if="!isDisable(index)" v-model="item.enable"
|
||||
:disabled="isReadOnly"/>
|
||||
|
||||
<el-col class="kv-checkbox" v-if="isShowEnable">
|
||||
<input type="checkbox" v-if="!isDisable(index)" v-model="item.enable"
|
||||
:disabled="isReadOnly"/>
|
||||
</el-col>
|
||||
</el-col>
|
||||
<span style="margin-left: 10px" v-else></span>
|
||||
|
||||
<el-col class="item">
|
||||
<el-input v-if="!suggestions" :disabled="isReadOnly" v-model="item.name" size="small" maxlength="200"
|
||||
@change="change"
|
||||
:placeholder="keyText" show-word-limit/>
|
||||
<el-autocomplete :disabled="isReadOnly" :maxlength="200" v-if="suggestions" v-model="item.name" size="small"
|
||||
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText"
|
||||
show-word-limit/>
|
||||
<i class="el-icon-top" style="cursor:pointer" @click="moveTop(index)"/>
|
||||
<i class="el-icon-bottom" style="cursor:pointer;" @click="moveBottom(index)"/>
|
||||
|
||||
</el-col>
|
||||
<el-col class="item">
|
||||
<el-input v-if="!suggestions" :disabled="isReadOnly" v-model="item.name" size="small" maxlength="200"
|
||||
@change="change"
|
||||
:placeholder="keyText" show-word-limit/>
|
||||
<el-autocomplete :disabled="isReadOnly" :maxlength="200" v-if="suggestions" v-model="item.name" size="small"
|
||||
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText"
|
||||
show-word-limit/>
|
||||
|
||||
<el-col class="item">
|
||||
<el-input :disabled="isReadOnly" v-model="item.value" size="small" @change="change"
|
||||
:placeholder="valueText" show-word-limit/>
|
||||
</el-col>
|
||||
<el-col class="item kv-delete">
|
||||
<el-button size="mini" class="el-icon-delete-solid" circle @click="remove(index)"
|
||||
:disabled="isDisable(index) || isReadOnly"/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</ms-draggable>
|
||||
</el-col>
|
||||
|
||||
<el-col class="item">
|
||||
<el-input :disabled="isReadOnly" v-model="item.value" size="small" @change="change"
|
||||
:placeholder="valueText" show-word-limit/>
|
||||
</el-col>
|
||||
<el-col class="item kv-delete">
|
||||
<el-button size="mini" class="el-icon-delete-solid" circle @click="remove(index)"
|
||||
:disabled="isDisable(index) || isReadOnly"/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {KeyValue} from "../model/ApiTestModel";
|
||||
import MsDraggable from 'vuedraggable'
|
||||
import Vue from 'vue';
|
||||
|
||||
|
||||
export default {
|
||||
name: "MsApiKeyValue",
|
||||
components: {
|
||||
MsDraggable
|
||||
},
|
||||
|
||||
props: {
|
||||
keyPlaceholder: String,
|
||||
valuePlaceholder: String,
|
||||
|
@ -66,6 +63,7 @@
|
|||
data() {
|
||||
return {
|
||||
keyValues: [],
|
||||
loading: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -78,6 +76,31 @@
|
|||
},
|
||||
|
||||
methods: {
|
||||
moveBottom(index) {
|
||||
if (this.items.length < 2 || index === this.items.length - 2) {
|
||||
return;
|
||||
}
|
||||
let thisRow = this.items[index];
|
||||
let nextRow = this.items[index + 1];
|
||||
Vue.set(this.items, index + 1, thisRow);
|
||||
Vue.set(this.items, index, nextRow)
|
||||
},
|
||||
moveTop(index) {
|
||||
if (index === 0) {
|
||||
return;
|
||||
}
|
||||
let thisRow = this.items[index];
|
||||
let lastRow = this.items[index - 1];
|
||||
Vue.set(this.items, index - 1, thisRow);
|
||||
Vue.set(this.items, index, lastRow)
|
||||
|
||||
},
|
||||
reload() {
|
||||
this.loading = true
|
||||
this.$nextTick(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
remove: function (index) {
|
||||
// 移除整行输入控件及内容
|
||||
this.items.splice(index, 1);
|
||||
|
@ -115,27 +138,11 @@
|
|||
return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
|
||||
};
|
||||
},
|
||||
endChange(env) {
|
||||
if (env.newIndex == env.oldIndex) {
|
||||
return;
|
||||
}
|
||||
let newItem = this.keyValues[env.newIndex];
|
||||
let oldItem = this.keyValues[env.oldIndex];
|
||||
this.$set(this.keyValues, env.oldIndex, oldItem);
|
||||
this.$set(this.keyValues, env.newIndex, newItem)
|
||||
this.items.forEach(item => {
|
||||
this.items.splice(0);
|
||||
})
|
||||
this.keyValues.forEach(item => {
|
||||
this.items.push(item);
|
||||
})
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.items.length === 0 || this.items[this.items.length - 1].name) {
|
||||
this.items.push(new KeyValue({enable: true}));
|
||||
}
|
||||
this.keyValues = this.items;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -161,4 +168,8 @@
|
|||
.el-autocomplete {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
i:hover {
|
||||
color: #783887;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -3,85 +3,83 @@
|
|||
<span class="kv-description" v-if="description">
|
||||
{{ description }}
|
||||
</span>
|
||||
<ms-draggable element="ul" @update="endChange"
|
||||
v-model="keyValues" v-bind="{draggable:'.item'}">
|
||||
|
||||
<div class="item kv-row" v-for="(item, index) in keyValues" :key="index">
|
||||
<el-row type="flex" :gutter="20" justify="space-between" align="middle">
|
||||
<el-button icon="el-icon-sort" circle size="mini"/>
|
||||
<div class="item kv-row" v-for="(item, index) in parameters" :key="index">
|
||||
<el-row type="flex" :gutter="20" justify="space-between" align="middle">
|
||||
<el-col class="kv-checkbox" v-if="isShowEnable">
|
||||
<input type="checkbox" v-if="!isDisable(index)" v-model="item.enable"
|
||||
:disabled="isReadOnly"/>
|
||||
</el-col>
|
||||
<span style="margin-left: 10px" v-else></span>
|
||||
<i class="el-icon-top" style="cursor:pointer" @click="moveTop(index)"/>
|
||||
<i class="el-icon-bottom" style="cursor:pointer;" @click="moveBottom(index)"/>
|
||||
|
||||
<el-col class="kv-checkbox" v-if="isShowEnable">
|
||||
<input type="checkbox" v-if="!isDisable(index)" v-model="item.enable"
|
||||
:disabled="isReadOnly"/>
|
||||
</el-col>
|
||||
<el-col class="item">
|
||||
<el-input v-if="!suggestions" :disabled="isReadOnly" v-model="item.name" size="small" maxlength="200"
|
||||
@change="change" :placeholder="keyText" show-word-limit>
|
||||
<template v-slot:prepend>
|
||||
<el-select v-if="type === 'body'" :disabled="isReadOnly" class="kv-type" v-model="item.type"
|
||||
@change="typeChange(item)">
|
||||
<el-option value="text"/>
|
||||
<el-option value="file"/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-input>
|
||||
|
||||
<el-col class="item">
|
||||
<el-input v-if="!suggestions" :disabled="isReadOnly" v-model="item.name" size="small" maxlength="200"
|
||||
@change="change" :placeholder="keyText" show-word-limit>
|
||||
<template v-slot:prepend>
|
||||
<el-select v-if="type === 'body'" :disabled="isReadOnly" class="kv-type" v-model="item.type"
|
||||
@change="typeChange(item)">
|
||||
<el-option value="text"/>
|
||||
<el-option value="file"/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-autocomplete :disabled="isReadOnly" v-if="suggestions" v-model="item.name" size="small"
|
||||
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText" show-word-limit/>
|
||||
|
||||
<el-autocomplete :disabled="isReadOnly" v-if="suggestions" v-model="item.name" size="small"
|
||||
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText" show-word-limit/>
|
||||
</el-col>
|
||||
|
||||
</el-col>
|
||||
<el-col class="item kv-select">
|
||||
<el-select v-model="item.required" size="small">
|
||||
<el-option v-for="req in requireds" :key="req.id" :label="req.name" :value="req.id"/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
|
||||
<el-col class="item kv-select">
|
||||
<el-select v-model="item.required" size="small">
|
||||
<el-option v-for="req in requireds" :key="req.id" :label="req.name" :value="req.id"/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col class="item" v-if="item.type !== 'file'">
|
||||
<el-autocomplete
|
||||
:disabled="isReadOnly"
|
||||
size="small"
|
||||
class="input-with-autocomplete"
|
||||
v-model="item.value"
|
||||
:fetch-suggestions="funcSearch"
|
||||
:placeholder="valueText"
|
||||
value-key="name"
|
||||
highlight-first-item
|
||||
@select="change">
|
||||
<i slot="suffix" class="el-input__icon el-icon-edit pointer" @click="advanced(item)"></i>
|
||||
</el-autocomplete>
|
||||
</el-col>
|
||||
|
||||
<el-col class="item" v-if="item.type !== 'file'">
|
||||
<el-autocomplete
|
||||
:disabled="isReadOnly"
|
||||
size="small"
|
||||
class="input-with-autocomplete"
|
||||
v-model="item.value"
|
||||
:fetch-suggestions="funcSearch"
|
||||
:placeholder="valueText"
|
||||
value-key="name"
|
||||
highlight-first-item
|
||||
@select="change">
|
||||
<i slot="suffix" class="el-input__icon el-icon-edit pointer" @click="advanced(item)"></i>
|
||||
</el-autocomplete>
|
||||
</el-col>
|
||||
<el-col class="item">
|
||||
<el-input v-model="item.description" size="small" maxlength="200"
|
||||
:placeholder="$t('commons.description')" show-word-limit>
|
||||
</el-input>
|
||||
|
||||
<el-col class="item">
|
||||
<el-input v-model="item.description" size="small" maxlength="200"
|
||||
:placeholder="$t('commons.description')" show-word-limit>
|
||||
</el-input>
|
||||
<el-autocomplete :disabled="isReadOnly" v-if="suggestions" v-model="item.name" size="small"
|
||||
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText" show-word-limit/>
|
||||
|
||||
<el-autocomplete :disabled="isReadOnly" v-if="suggestions" v-model="item.name" size="small"
|
||||
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText" show-word-limit/>
|
||||
</el-col>
|
||||
|
||||
</el-col>
|
||||
<el-col v-if="item.type === 'file'" class="item">
|
||||
<ms-api-body-file-upload :parameter="item"/>
|
||||
</el-col>
|
||||
|
||||
<el-col v-if="item.type === 'file'" class="item">
|
||||
<ms-api-body-file-upload :parameter="item"/>
|
||||
</el-col>
|
||||
<el-col v-if="type === 'body'" class="item kv-select">
|
||||
<el-input :disabled="isReadOnly" v-model="item.contentType" size="small"
|
||||
@change="change" :placeholder="$t('api_test.request.content_type')" show-word-limit>
|
||||
</el-input>
|
||||
</el-col>
|
||||
|
||||
<el-col v-if="type === 'body'" class="item kv-select">
|
||||
<el-input :disabled="isReadOnly" v-model="item.contentType" size="small"
|
||||
@change="change" :placeholder="$t('api_test.request.content_type')" show-word-limit>
|
||||
</el-input>
|
||||
</el-col>
|
||||
|
||||
<el-col class="item kv-delete">
|
||||
<el-button size="mini" class="el-icon-delete-solid" circle @click="remove(index)"
|
||||
:disabled="isDisable(index) || isReadOnly"/>
|
||||
</el-col>
|
||||
<el-col class="item kv-delete">
|
||||
<el-button size="mini" class="el-icon-delete-solid" circle @click="remove(index)"
|
||||
:disabled="isDisable(index) || isReadOnly"/>
|
||||
</el-col>
|
||||
|
||||
|
||||
</el-row>
|
||||
</div>
|
||||
</ms-draggable>
|
||||
</el-row>
|
||||
</div>
|
||||
<ms-api-variable-advance ref="variableAdvance" :environment="environment" :scenario="scenario"
|
||||
:parameters="parameters"
|
||||
:current-item="currentItem"/>
|
||||
|
@ -94,11 +92,11 @@
|
|||
import MsApiVariableAdvance from "./ApiVariableAdvance";
|
||||
import MsApiBodyFileUpload from "./body/ApiBodyFileUpload";
|
||||
import {REQUIRED} from "../model/JsonData";
|
||||
import MsDraggable from 'vuedraggable'
|
||||
import Vue from 'vue';
|
||||
|
||||
export default {
|
||||
name: "MsApiVariable",
|
||||
components: {MsApiBodyFileUpload, MsApiVariableAdvance, MsDraggable},
|
||||
components: {MsApiBodyFileUpload, MsApiVariableAdvance},
|
||||
props: {
|
||||
keyPlaceholder: String,
|
||||
valuePlaceholder: String,
|
||||
|
@ -125,7 +123,6 @@
|
|||
return {
|
||||
currentItem: null,
|
||||
requireds: REQUIRED,
|
||||
keyValues: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -137,6 +134,25 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
moveBottom(index) {
|
||||
if (this.parameters.length < 2 || index === this.parameters.length - 2) {
|
||||
return;
|
||||
}
|
||||
let thisRow = this.parameters[index];
|
||||
let nextRow = this.parameters[index + 1];
|
||||
Vue.set(this.parameters, index + 1, thisRow);
|
||||
Vue.set(this.parameters, index, nextRow)
|
||||
},
|
||||
moveTop(index) {
|
||||
if (index === 0) {
|
||||
return;
|
||||
}
|
||||
let thisRow = this.parameters[index];
|
||||
let lastRow = this.parameters[index - 1];
|
||||
Vue.set(this.parameters, index - 1, thisRow);
|
||||
Vue.set(this.parameters, index, lastRow)
|
||||
|
||||
},
|
||||
remove: function (index) {
|
||||
// 移除整行输入控件及内容
|
||||
this.parameters.splice(index, 1);
|
||||
|
@ -204,21 +220,6 @@
|
|||
item.contentType = 'text/plain';
|
||||
}
|
||||
},
|
||||
endChange(env) {
|
||||
if (env.newIndex == env.oldIndex) {
|
||||
return;
|
||||
}
|
||||
let newItem = this.keyValues[env.newIndex];
|
||||
let oldItem = this.keyValues[env.oldIndex];
|
||||
this.$set(this.keyValues, env.oldIndex, oldItem);
|
||||
this.$set(this.keyValues, env.newIndex, newItem)
|
||||
this.parameters.forEach(item => {
|
||||
this.parameters.splice(0);
|
||||
})
|
||||
this.keyValues.forEach(item => {
|
||||
this.parameters.push(item);
|
||||
})
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.parameters.length === 0 || this.parameters[this.parameters.length - 1].name) {
|
||||
|
@ -230,7 +231,6 @@
|
|||
contentType: 'text/plain'
|
||||
}));
|
||||
}
|
||||
this.keyValues = this.parameters;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
|
||||
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
|
||||
|
||||
<ms-api-request-form :showScript="true" :is-read-only="isReadOnly" :headers="apiCase.request.headers " :request="apiCase.request" v-if="api.protocol==='HTTP'"/>
|
||||
<ms-api-request-form :isShowEnable="true" :showScript="true" :is-read-only="isReadOnly" :headers="apiCase.request.headers " :request="apiCase.request" v-if="api.protocol==='HTTP'"/>
|
||||
<ms-tcp-basis-parameters :showScript="true" :request="apiCase.request" v-if="api.protocol==='TCP'"/>
|
||||
<ms-sql-basis-parameters :showScript="true" :request="apiCase.request" v-if="api.protocol==='SQL'"/>
|
||||
<ms-dubbo-basis-parameters :showScript="true" :request="apiCase.request" v-if="api.protocol==='DUBBO'"/>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||
<!-- HTTP 请求参数 -->
|
||||
<ms-api-request-form :headers="request.headers" :request="request" :response="responseData"/>
|
||||
<ms-api-request-form :isShowEnable="true" :headers="request.headers" :request="request" :response="responseData"/>
|
||||
</el-form>
|
||||
<!-- HTTP 请求返回数据 -->
|
||||
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
|
||||
<el-form :model="formData" :rules="rules" label-width="100px" v-loading="result.loading" ref="form">
|
||||
<el-row>
|
||||
<el-col :span="9">
|
||||
<el-form-item :label="'Swagger URL'" prop="swaggerUrl" v-if="isSwagger2 && swaggerUrlEable" class="swagger-url">
|
||||
<el-input size="small" v-model="formData.swaggerUrl" clearable show-word-limit/>
|
||||
</el-form-item>
|
||||
|
||||
<el-col :span="11">
|
||||
<el-form-item :label="$t('commons.import_module')"
|
||||
v-if="selectedPlatformValue != 'Swagger2' || (selectedPlatformValue == 'Swagger2' && !swaggerUrlEable)">
|
||||
<el-select size="small" v-model="formData.moduleId" class="project-select" clearable>
|
||||
|
@ -33,10 +37,27 @@
|
|||
<el-option v-for="item in modeOptions" :key="item.id" :label="item.name" :value="item.id"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="isSwagger2">
|
||||
<el-switch
|
||||
v-model="swaggerUrlEable"
|
||||
:active-text="$t('api_test.api_import.swagger_url_import')">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item v-show="isSwagger2 && swaggerUrlEable">
|
||||
<el-switch
|
||||
v-model="swaggerSynchronization"
|
||||
@click.native="scheduleEdit"
|
||||
:active-text="$t('api_test.api_import.timing_synchronization')">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="10" style="margin-left: 20px">
|
||||
<el-col :span="1"
|
||||
v-if="selectedPlatformValue != 'Swagger2' || (selectedPlatformValue == 'Swagger2' && !swaggerUrlEable)">
|
||||
<el-divider direction="vertical"/>
|
||||
</el-col>
|
||||
<el-col :span="12"
|
||||
v-if="selectedPlatformValue != 'Swagger2' || (selectedPlatformValue == 'Swagger2' && !swaggerUrlEable)">
|
||||
<el-upload
|
||||
v-if="selectedPlatformValue != 'Swagger2' || (selectedPlatformValue == 'Swagger2' && !swaggerUrlEable)"
|
||||
class="api-upload"
|
||||
drag
|
||||
action=""
|
||||
|
@ -52,28 +73,7 @@
|
|||
<div class="el-upload__tip" slot="tip">{{ $t('api_test.api_import.file_size_limit') }}</div>
|
||||
</el-upload>
|
||||
</el-col>
|
||||
|
||||
<el-form-item :label="'Swagger URL'" prop="wgerUrl" v-if="isSwagger2 && swaggerUrlEable" class="swagger-url">
|
||||
<el-input size="small" v-model="formData.swaggerUrl" clearable show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="isSwagger2" class="swagger-enable" :class="{'swagger-url-disable': !swaggerUrlEable}">
|
||||
<el-switch
|
||||
v-model="swaggerUrlEable"
|
||||
:active-text="$t('api_test.api_import.swagger_url_import')">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="isSwagger2 && swaggerUrlEable">
|
||||
<el-switch
|
||||
v-model="swaggerSynchronization"
|
||||
@click.native="scheduleEdit"
|
||||
:active-text="$t('api_test.api_import.timing_synchronization')">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
<schedule-import ref="scheduleEdit"></schedule-import>
|
||||
</el-row>
|
||||
|
||||
|
||||
</el-form>
|
||||
|
||||
<div class="format-tip">
|
||||
|
@ -84,7 +84,7 @@
|
|||
<span>{{ $t('api_test.api_import.export_tip') }}:{{ selectedPlatform.exportTip }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<schedule-import ref="scheduleEdit"></schedule-import>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
|
@ -180,11 +180,13 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
scheduleEdit() {
|
||||
if (this.swaggerSynchronization) {
|
||||
this.$refs.scheduleEdit.open(this.buildParam());
|
||||
if (!this.formData.swaggerUrl) {
|
||||
this.$warning(this.$t('commons.please_upload'));
|
||||
this.swaggerSynchronization = !this.swaggerSynchronization
|
||||
} else {
|
||||
this.result = this.$post("/api/definition/schedule/update", this.schedule, response => {
|
||||
});
|
||||
if (this.swaggerSynchronization) {
|
||||
this.$refs.scheduleEdit.open(this.buildParam());
|
||||
}
|
||||
}
|
||||
},
|
||||
open(module) {
|
||||
|
@ -238,9 +240,15 @@ export default {
|
|||
Object.assign(param, this.formData);
|
||||
param.platform = this.selectedPlatformValue;
|
||||
param.saved = this.saved;
|
||||
console.log(this.formData.moduleId)
|
||||
if (this.currentModule) {
|
||||
param.moduleId = this.currentModule.id;
|
||||
param.modulePath = this.currentModule.path;
|
||||
param.moduleId = this.formData.moduleId
|
||||
this.moduleOptions.filter(item => {
|
||||
if (item.id === this.formData.moduleId) {
|
||||
param.modulePath = item.path
|
||||
}
|
||||
})
|
||||
param.modeId = this.formData.modeId
|
||||
}
|
||||
param.projectId = getCurrentProjectID();
|
||||
if (!this.swaggerUrlEable) {
|
||||
|
@ -326,4 +334,8 @@ export default {
|
|||
margin-left: 80px;
|
||||
}
|
||||
|
||||
.el-divider {
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
ref="crontab"/>
|
||||
</el-dialog>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('api_test.home_page.running_task_list.title')" name="second">
|
||||
<swagger-task-list></swagger-task-list>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -35,10 +38,17 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {checkoutTestManagerOrTestUser, getCurrentUser, listenGoBack, removeGoBackListener} from "@/common/js/utils";
|
||||
import {
|
||||
checkoutTestManagerOrTestUser,
|
||||
getCurrentProjectID,
|
||||
getCurrentUser,
|
||||
listenGoBack,
|
||||
removeGoBackListener
|
||||
} from "@/common/js/utils";
|
||||
import Crontab from "@/business/components/common/cron/Crontab";
|
||||
import CrontabResult from "@/business/components/common/cron/CrontabResult";
|
||||
import {cronValidate} from "@/common/js/cron";
|
||||
import SwaggerTaskList from "@/business/components/api/definition/components/import/SwaggerTaskList";
|
||||
|
||||
function defaultCustomValidate() {
|
||||
return {pass: true};
|
||||
|
@ -46,7 +56,7 @@ function defaultCustomValidate() {
|
|||
|
||||
export default {
|
||||
name: "ImportScheduleEdit",
|
||||
components: {CrontabResult, Crontab},
|
||||
components: {SwaggerTaskList, CrontabResult, Crontab},
|
||||
|
||||
props: {
|
||||
customValidate: {
|
||||
|
@ -89,8 +99,12 @@ export default {
|
|||
cronValue: ""
|
||||
},
|
||||
activeName: 'first',
|
||||
swaggerUrl:String,
|
||||
projectId:String,
|
||||
swaggerUrl: String,
|
||||
projectId: String,
|
||||
moduleId: String,
|
||||
paramSwaggerUrlId: String,
|
||||
modulePath: String,
|
||||
modeId: String,
|
||||
rules: {
|
||||
cronValue: [{required: true, validator: validateCron, trigger: 'blur'}],
|
||||
}
|
||||
|
@ -101,20 +115,30 @@ export default {
|
|||
return getCurrentUser();
|
||||
},
|
||||
open(param) {
|
||||
let paramTestId = "";
|
||||
paramTestId=param.projectId
|
||||
this.findSchedule(paramTestId);
|
||||
this.project=param.projectId;
|
||||
this.swaggerUrl=param.swaggerUrl;
|
||||
this.dialogVisible = true;
|
||||
this.form.cronValue = this.schedule.value;
|
||||
listenGoBack(this.close);
|
||||
this.$post("/api/definition/getResourceId", param, response => {
|
||||
this.paramSwaggerUrlId = response.data
|
||||
if (this.paramSwaggerUrlId === "" || this.paramSwaggerUrlId === null || this.paramSwaggerUrlId === undefined) {
|
||||
console.log(this.paramSwaggerUrlId)
|
||||
} else {
|
||||
this.findSchedule(this.paramSwaggerUrlId);
|
||||
|
||||
}
|
||||
this.project = param.projectId;
|
||||
this.swaggerUrl = param.swaggerUrl;
|
||||
this.dialogVisible = true;
|
||||
this.form.cronValue = this.schedule.value;
|
||||
this.moduleId = param.moduleId;
|
||||
this.modulePath = param.modulePath;
|
||||
this.modeId = param.modeId;
|
||||
listenGoBack(this.close);
|
||||
})
|
||||
|
||||
this.activeName = 'first';
|
||||
},
|
||||
findSchedule(paramTestId) {
|
||||
let scheduleResourceID = paramTestId;
|
||||
let taskType="SWAGGER_IMPORT";
|
||||
this.result = this.$get("/schedule/findOne/" + scheduleResourceID + "/" +taskType, response => {
|
||||
},
|
||||
findSchedule(paramSwaggerUrlId) {
|
||||
let scheduleResourceID = paramSwaggerUrlId;
|
||||
let taskType = "SWAGGER_IMPORT";
|
||||
this.result = this.$get("/schedule/findOne/" + scheduleResourceID + "/" + taskType, response => {
|
||||
if (response.data != null) {
|
||||
this.schedule = response.data;
|
||||
} else {
|
||||
|
@ -150,9 +174,17 @@ export default {
|
|||
this.checkScheduleEdit();
|
||||
let param = {};
|
||||
param = this.schedule;
|
||||
param.resourceId =this.project;
|
||||
param.swaggerUrl=this.swaggerUrl;
|
||||
let url = '/api/definition/schedule/create';
|
||||
param.resourceId = this.swaggerUrl;
|
||||
param.projectId = getCurrentProjectID();
|
||||
param.moduleId = this.moduleId;
|
||||
param.modulePath = this.modulePath;
|
||||
param.modeId = this.modeId;
|
||||
let url = '';
|
||||
if (this.paramSwaggerUrlId) {
|
||||
url = '/api/definition/schedule/update';
|
||||
} else {
|
||||
url = '/api/definition/schedule/create';
|
||||
}
|
||||
this.$post(url, param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
});
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
<template>
|
||||
<el-table border :data="tableData" class="adjust-table table-content" height="300px">
|
||||
<el-table-column prop="index" :label="$t('api_test.home_page.running_task_list.table_coloum.index')"
|
||||
width="50"
|
||||
show-overflow-tooltip/>
|
||||
<el-table-column prop="SwaggerUrlId">
|
||||
</el-table-column>
|
||||
<el-table-column prop="swaggerUrl" :label="$t('swaggerUrl')" width="100" show-overflow-tooltip>
|
||||
</el-table-column>
|
||||
<el-table-column prop="modulePath" :label="$t('导入模块')"
|
||||
width="100" show-overflow-tooltip/>
|
||||
<el-table-column prop="rule" label="同步规则" width="120"
|
||||
show-overflow-tooltip/>
|
||||
<el-table-column width="100" :label="$t('api_test.home_page.running_task_list.table_coloum.task_status')">
|
||||
<template v-slot:default="scope">
|
||||
<div>
|
||||
<el-switch
|
||||
v-model="scope.row.taskStatus"
|
||||
class="captcha-img"
|
||||
@click.native="closeTaskConfirm(scope.row)"
|
||||
></el-switch>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="170" :label="$t('api_test.home_page.running_task_list.table_coloum.next_execution_time')">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.nextExecutionTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="100" label="操作">
|
||||
<template v-slot:default="scope">
|
||||
<el-button
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
@click.native.prevent="deleteRowTask(scope.row)"
|
||||
></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getCurrentProjectID} from "../../../../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "SwaggerTaskList",
|
||||
data() {
|
||||
return {
|
||||
tableData: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
search() {
|
||||
let projectId = getCurrentProjectID();
|
||||
this.result = this.$get("/api/definition/scheduleTask/" + projectId, response => {
|
||||
this.tableData = response.data;
|
||||
})
|
||||
},
|
||||
closeTaskConfirm(row) {
|
||||
let flag = row.taskStatus;
|
||||
row.taskStatus = !flag;
|
||||
if (row.taskStatus) {
|
||||
this.$confirm(this.$t('api_test.home_page.running_task_list.confirm.close_title'), this.$t('commons.prompt'), {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
cancelButtonText: this.$t('commons.cancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
row.taskStatus = !row.taskStatus
|
||||
this.updateTask(row);
|
||||
}).catch(() => {
|
||||
});
|
||||
} else {
|
||||
row.taskStatus = !row.taskStatus
|
||||
this.updateTask(row);
|
||||
}
|
||||
|
||||
},
|
||||
updateTask(taskRow) {
|
||||
this.result = this.$post('/api/definition/schedule/updateByPrimyKey', taskRow, response => {
|
||||
this.search();
|
||||
});
|
||||
},
|
||||
deleteRowTask(row) {
|
||||
this.result = this.$post('/api/definition/schedule/deleteByPrimyKey', row, response => {
|
||||
this.search();
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
mounted() {
|
||||
this.search()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -3,7 +3,7 @@
|
|||
<ms-tag v-if="value === 'Prepare'" type="info" effect="plain" :content="$t('test_track.plan.plan_status_prepare')"/>
|
||||
<ms-tag v-if="value === 'Underway'" type="warning" effect="plain" :content="$t('test_track.plan.plan_status_running')"/>
|
||||
<ms-tag v-if="value === 'Completed'" type="success" effect="plain" :content="$t('test_track.plan.plan_status_completed')"/>
|
||||
<ms-tag v-if="value === 'Trash'" type="danger" effect="plain" content="废弃"/>
|
||||
<ms-tag v-if="value === 'Trash'" type="danger" effect="plain" :content="$t('test_track.plan.plan_status_trash')"/>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||
<!-- HTTP 请求参数 -->
|
||||
<ms-api-request-form :headers="api.request.headers" :request="api.request"/>
|
||||
<ms-api-request-form :isShowEnable="true" :headers="api.request.headers" :request="api.request"/>
|
||||
|
||||
</el-form>
|
||||
<!--返回结果-->
|
||||
|
|
|
@ -320,6 +320,7 @@ export default {
|
|||
result: ''
|
||||
}],
|
||||
remark: '',
|
||||
tags: [],
|
||||
},
|
||||
moduleOptions: [],
|
||||
maintainerOptions: [],
|
||||
|
@ -353,7 +354,7 @@ export default {
|
|||
testCase: {},
|
||||
testCases: [],
|
||||
index: 0,
|
||||
showInputTag: false,
|
||||
showInputTag: true,
|
||||
};
|
||||
},
|
||||
props: {
|
||||
|
@ -419,6 +420,7 @@ export default {
|
|||
this.form.type = 'functional';
|
||||
this.form.method = 'manual';
|
||||
this.form.maintainer = user.id;
|
||||
this.form.tags = [];
|
||||
this.getSelectOptions();
|
||||
this.reload();
|
||||
}
|
||||
|
|
|
@ -3,12 +3,14 @@
|
|||
<ms-tag v-if="value == 'Prepare'" type="info" :content="$t('test_track.plan.plan_status_prepare')"/>
|
||||
<ms-tag v-if="value == 'Underway'" type="primary" :content="$t('test_track.plan.plan_status_running')"/>
|
||||
<ms-tag v-if="value == 'Completed'" type="success" :content="$t('test_track.plan.plan_status_completed')"/>
|
||||
<ms-tag v-if="value === 'Trash'" type="danger" effect="plain" :content="$t('test_track.plan.plan_status_trash')"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MsTag from "../../../../common/components/MsTag";
|
||||
export default {
|
||||
import MsTag from "../../../../common/components/MsTag";
|
||||
|
||||
export default {
|
||||
name: "PlanStatusTableItem",
|
||||
components: {MsTag},
|
||||
props: {
|
||||
|
|
Loading…
Reference in New Issue