Merge branch 'master' of https://github.com/metersphere/metersphere
This commit is contained in:
commit
35887dff24
|
@ -1,5 +1,5 @@
|
|||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 30
|
||||
daysUntilStale: 60
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
# Issues with these labels will never be considered stale
|
||||
|
|
|
@ -2,19 +2,27 @@ package io.metersphere.api.controller;
|
|||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.api.dto.ApiDocumentInfoDTO;
|
||||
import io.metersphere.api.dto.ApiDocumentRequest;
|
||||
import io.metersphere.api.dto.ApiDocumentSimpleInfoDTO;
|
||||
import io.metersphere.api.dto.document.ApiDocumentInfoDTO;
|
||||
import io.metersphere.api.dto.document.ApiDocumentRequest;
|
||||
import io.metersphere.api.dto.document.ApiDocumentShareRequest;
|
||||
import io.metersphere.api.dto.document.ApiDocumentSimpleInfoDTO;
|
||||
import io.metersphere.api.dto.document.ApiDocumentShareDTO;
|
||||
import io.metersphere.api.service.APITestService;
|
||||
import io.metersphere.api.service.ApiDefinitionService;
|
||||
import io.metersphere.api.service.ApiDocumentService;
|
||||
import io.metersphere.base.domain.ApiDefinition;
|
||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiDocumentShare;
|
||||
import io.metersphere.base.domain.ApiDocumentShareExample;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.python.antlr.ast.Str;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -32,17 +40,56 @@ public class ApiDocumentController {
|
|||
ApiDocumentService apiDocumentService;
|
||||
@Resource
|
||||
ApiDefinitionService apiDefinitionService;
|
||||
@Resource
|
||||
APITestService apiTestService;
|
||||
|
||||
@PostMapping("/selectApiSimpleInfo")
|
||||
public List<ApiDocumentSimpleInfoDTO> list(@RequestBody ApiDocumentRequest request) {
|
||||
List<ApiDocumentSimpleInfoDTO> returnList = apiDocumentService.findApiDocumentSimpleInfoByRequest(request);
|
||||
public List<ApiDocumentInfoDTO> list(@RequestBody ApiDocumentRequest request) {
|
||||
List<ApiDocumentInfoDTO> returnList = apiDocumentService.findApiDocumentSimpleInfoByRequest(request);
|
||||
return returnList;
|
||||
}
|
||||
|
||||
@GetMapping("/selectApiInfoById/{id}")
|
||||
public ApiDocumentInfoDTO selectApiInfoById(@PathVariable String id) {
|
||||
ApiDefinitionWithBLOBs apiModel = apiDefinitionService.getBLOBs(id);
|
||||
ApiDocumentInfoDTO returnDTO = apiDocumentService.conversionModelToDTO(apiModel);
|
||||
ApiDocumentInfoDTO returnDTO = new ApiDocumentInfoDTO();
|
||||
try{
|
||||
returnDTO = apiDocumentService.conversionModelToDTO(apiModel);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
returnDTO.setSelectedFlag(true);
|
||||
return returnDTO;
|
||||
}
|
||||
|
||||
@PostMapping("/generateApiDocumentShareInfo")
|
||||
public ApiDocumentShareDTO generateApiDocumentShareInfo(@RequestBody ApiDocumentShareRequest request) {
|
||||
ApiDocumentShare apiShare = apiDocumentService.generateApiDocumentShare(request);
|
||||
ApiDocumentShareDTO returnDTO = apiDocumentService.conversionApiDocumentShareToDTO(apiShare);
|
||||
return returnDTO;
|
||||
}
|
||||
|
||||
@GetMapping("/updateJmxByFile")
|
||||
public String updateJmxByFile(){
|
||||
StringBuilder jmxBuilder = new StringBuilder();
|
||||
try {
|
||||
String filePath = "/Users/admin/Downloads/成功吧 (20).jmx";
|
||||
File file = new File(filePath);
|
||||
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
|
||||
|
||||
String strLine = null;
|
||||
while(null != (strLine = bufferedReader.readLine())){
|
||||
if(StringUtils.isNotEmpty(strLine)){
|
||||
jmxBuilder.append(strLine);
|
||||
}
|
||||
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
String jmx = apiTestService.updateJmxString(jmxBuilder.toString(),null,false);
|
||||
return jmx;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import lombok.Getter;
|
|||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
|
@ -34,4 +35,6 @@ public class RunDefinitionRequest {
|
|||
private Response response;
|
||||
|
||||
private List<String> bodyUploadIds;
|
||||
|
||||
private Map<String, String> environmentMap;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import io.metersphere.api.service.ApiTestEnvironmentService;
|
|||
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -26,8 +27,10 @@ import org.apache.jmeter.save.SaveService;
|
|||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
|
@ -52,6 +55,9 @@ public class MsScenario extends MsTestElement {
|
|||
@JSONField(ordinal = 26)
|
||||
private List<KeyValue> headers;
|
||||
|
||||
@JSONField(ordinal = 27)
|
||||
private Map<String, String> environmentMap;
|
||||
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
|
||||
public MsScenario() {
|
||||
|
@ -101,13 +107,25 @@ public class MsScenario extends MsTestElement {
|
|||
}
|
||||
// 设置共享cookie
|
||||
config.setEnableCookieShare(enableCookieShare);
|
||||
if (StringUtils.isNotEmpty(environmentId)) {
|
||||
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
|
||||
ApiTestEnvironmentWithBLOBs environment = environmentService.get(environmentId);
|
||||
if (environment != null && environment.getConfig() != null) {
|
||||
config.setConfig(JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class));
|
||||
Map<String,EnvironmentConfig> envConfig = new HashMap<>(16);
|
||||
// 兼容历史数据
|
||||
if (environmentMap == null || environmentMap.isEmpty()) {
|
||||
environmentMap = new HashMap<>(16);
|
||||
if (StringUtils.isNotBlank(environmentId)) {
|
||||
environmentMap.put(SessionUtils.getCurrentProjectId(), environmentId);
|
||||
}
|
||||
}
|
||||
if (environmentMap != null && !environmentMap.isEmpty()) {
|
||||
environmentMap.keySet().forEach(projectId -> {
|
||||
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
|
||||
ApiTestEnvironmentWithBLOBs environment = environmentService.get(environmentMap.get(projectId));
|
||||
if (environment != null && environment.getConfig() != null) {
|
||||
EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
envConfig.put(projectId, env);
|
||||
}
|
||||
});
|
||||
config.setConfig(envConfig);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(this.getVariables())) {
|
||||
config.setVariables(this.variables);
|
||||
}
|
||||
|
@ -171,9 +189,9 @@ public class MsScenario extends MsTestElement {
|
|||
}
|
||||
});
|
||||
}
|
||||
if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null
|
||||
&& CollectionUtils.isNotEmpty(config.getConfig().getCommonConfig().getVariables())) {
|
||||
config.getConfig().getCommonConfig().getVariables().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
||||
if (config != null && config.getConfig() != null && config.getConfig().get(this.getProjectId()).getCommonConfig() != null
|
||||
&& CollectionUtils.isNotEmpty(config.getConfig().get(this.getProjectId()).getCommonConfig().getVariables())) {
|
||||
config.getConfig().get(this.getProjectId()).getCommonConfig().getVariables().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
||||
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
|
||||
);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.apache.jorphan.collections.ListedHashTree;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type")
|
||||
|
@ -101,6 +102,8 @@ public abstract class MsTestElement {
|
|||
private LinkedList<MsTestElement> hashTree;
|
||||
@JSONField(ordinal = 11)
|
||||
private boolean customizeReq;
|
||||
@JSONField(ordinal = 12)
|
||||
private String projectId;
|
||||
|
||||
private MsTestElement parent;
|
||||
|
||||
|
@ -164,14 +167,14 @@ public abstract class MsTestElement {
|
|||
}
|
||||
|
||||
public Arguments addArguments(ParameterConfig config) {
|
||||
if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null
|
||||
&& CollectionUtils.isNotEmpty(config.getConfig().getCommonConfig().getVariables())) {
|
||||
if (config != null && config.getConfig() != null && config.getConfig().get(this.getProjectId()).getCommonConfig() != null
|
||||
&& CollectionUtils.isNotEmpty(config.getConfig().get(this.getProjectId()).getCommonConfig().getVariables())) {
|
||||
Arguments arguments = new Arguments();
|
||||
arguments.setEnabled(true);
|
||||
arguments.setName(StringUtils.isNoneBlank(this.getName()) ? this.getName() : "Arguments");
|
||||
arguments.setProperty(TestElement.TEST_CLASS, Arguments.class.getName());
|
||||
arguments.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("ArgumentsPanel"));
|
||||
config.getConfig().getCommonConfig().getVariables().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
||||
config.getConfig().get(this.getProjectId()).getCommonConfig().getVariables().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
||||
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
|
||||
);
|
||||
return arguments;
|
||||
|
|
|
@ -5,13 +5,14 @@ import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
|||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class ParameterConfig {
|
||||
/**
|
||||
* 环境配置
|
||||
*/
|
||||
private EnvironmentConfig config;
|
||||
private Map<String,EnvironmentConfig> config;
|
||||
/**
|
||||
* 公共场景参数
|
||||
*/
|
||||
|
|
|
@ -116,7 +116,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
if (config != null && config.getConfig() != null) {
|
||||
config.setConfig(config.getConfig());
|
||||
} else {
|
||||
config.setConfig(getEnvironmentConfig(useEnvironment));
|
||||
// config.setConfig(getEnvironmentConfig(useEnvironment));
|
||||
}
|
||||
|
||||
// 添加环境中的公共变量
|
||||
|
@ -126,7 +126,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
}
|
||||
try {
|
||||
if (config != null && config.getConfig() != null) {
|
||||
String url = config.getConfig().getHttpConfig().getProtocol() + "://" + config.getConfig().getHttpConfig().getSocket();
|
||||
String url = config.getConfig().get(this.getProjectId()).getHttpConfig().getProtocol() + "://" + config.getConfig().get(this.getProjectId()).getHttpConfig().getSocket();
|
||||
// 补充如果是完整URL 则用自身URL
|
||||
boolean isUrl = false;
|
||||
if (StringUtils.isNotEmpty(this.getUrl()) && isURL(this.getUrl())) {
|
||||
|
@ -139,9 +139,9 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
sampler.setPort(urlObject.getPort());
|
||||
sampler.setProtocol(urlObject.getProtocol());
|
||||
} else {
|
||||
sampler.setDomain(config.getConfig().getHttpConfig().getDomain());
|
||||
sampler.setPort(config.getConfig().getHttpConfig().getPort());
|
||||
sampler.setProtocol(config.getConfig().getHttpConfig().getProtocol());
|
||||
sampler.setDomain(config.getConfig().get(this.getProjectId()).getHttpConfig().getDomain());
|
||||
sampler.setPort(config.getConfig().get(this.getProjectId()).getHttpConfig().getPort());
|
||||
sampler.setProtocol(config.getConfig().get(this.getProjectId()).getHttpConfig().getProtocol());
|
||||
}
|
||||
String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath();
|
||||
if (StringUtils.isNotBlank(this.getPath()) && !isUrl) {
|
||||
|
@ -214,16 +214,16 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
}
|
||||
|
||||
// 通用请求Headers
|
||||
if (config != null && config.getConfig() != null && config.getConfig().getHttpConfig() != null
|
||||
&& CollectionUtils.isNotEmpty(config.getConfig().getHttpConfig().getHeaders())) {
|
||||
setHeader(httpSamplerTree, config.getConfig().getHttpConfig().getHeaders());
|
||||
if (config != null && config.getConfig() != null && config.getConfig().get(this.getProjectId()).getHttpConfig() != null
|
||||
&& CollectionUtils.isNotEmpty(config.getConfig().get(this.getProjectId()).getHttpConfig().getHeaders())) {
|
||||
setHeader(httpSamplerTree, config.getConfig().get(this.getProjectId()).getHttpConfig().getHeaders());
|
||||
}
|
||||
|
||||
//判断是否要开启DNS
|
||||
if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null
|
||||
&& config.getConfig().getCommonConfig().isEnableHost()) {
|
||||
MsDNSCacheManager.addEnvironmentVariables(httpSamplerTree, this.getName(), config.getConfig());
|
||||
MsDNSCacheManager.addEnvironmentDNS(httpSamplerTree, this.getName(), config.getConfig());
|
||||
if (config != null && config.getConfig() != null && config.getConfig().get(this.getProjectId()).getCommonConfig() != null
|
||||
&& config.getConfig().get(this.getProjectId()).getCommonConfig().isEnableHost()) {
|
||||
MsDNSCacheManager.addEnvironmentVariables(httpSamplerTree, this.getName(), config.getConfig().get(this.getProjectId()));
|
||||
MsDNSCacheManager.addEnvironmentDNS(httpSamplerTree, this.getName(), config.getConfig().get(this.getProjectId()));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
for (MsTestElement el : hashTree) {
|
||||
|
|
|
@ -69,14 +69,16 @@ public class MsTCPSampler extends MsTestElement {
|
|||
private MsJSR223PreProcessor tcpPreProcessor;
|
||||
@JSONField(ordinal = 38)
|
||||
private String protocol = "TCP";
|
||||
@JSONField(ordinal = 39)
|
||||
private String projectId;
|
||||
|
||||
@Override
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||
if (this.getReferenced() != null && MsTestElementConstants.REF.name().equals(this.getReferenced())) {
|
||||
this.getRefElement(this);
|
||||
}
|
||||
config.setConfig(getEnvironmentConfig(useEnvironment));
|
||||
parseEnvironment(config.getConfig());
|
||||
// config.setConfig(getEnvironmentConfig(useEnvironment));
|
||||
parseEnvironment(config.getConfig().get(this.projectId));
|
||||
|
||||
// 添加环境中的公共变量
|
||||
Arguments arguments = this.addArguments(config);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.api.dto;
|
||||
package io.metersphere.api.dto.document;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -13,6 +13,7 @@ import lombok.Setter;
|
|||
public class ApiDocumentInfoDTO {
|
||||
private String id;
|
||||
private String method;
|
||||
private boolean selectedFlag;
|
||||
private String uri;
|
||||
private String name;
|
||||
private String status;
|
||||
|
@ -32,5 +33,6 @@ public class ApiDocumentInfoDTO {
|
|||
private String responseBodyStrutureData;
|
||||
|
||||
private String responseCode;
|
||||
private boolean sharePopoverVisible = false;
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.api.dto;
|
||||
package io.metersphere.api.dto.document;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -19,4 +19,5 @@ public class ApiDocumentRequest {
|
|||
private String name;
|
||||
private String type;
|
||||
private String orderCondition;
|
||||
private List<String> apiIdList;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package io.metersphere.api.dto.document;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author song.tianyang
|
||||
* @Date 2021/2/23 5:10 下午
|
||||
* @Description
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiDocumentShareDTO {
|
||||
private String id;
|
||||
private String shareUrl;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package io.metersphere.api.dto.document;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author song.tianyang
|
||||
* @Date 2021/2/23 5:04 下午
|
||||
* @Description
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiDocumentShareRequest {
|
||||
private String shareType;
|
||||
private List<String> shareApiIdList;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package io.metersphere.api.dto.document;
|
||||
|
||||
public enum ApiDocumentShareType {
|
||||
Single,Batch
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.api.dto;
|
||||
package io.metersphere.api.dto.document;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
|
@ -561,10 +561,14 @@ public class ApiAutomationService {
|
|||
public String debugRun(RunDefinitionRequest request, List<MultipartFile> bodyFiles) {
|
||||
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
|
||||
FileUtils.createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
EnvironmentConfig envConfig = null;
|
||||
if (request.getEnvironmentId() != null) {
|
||||
ApiTestEnvironmentWithBLOBs environment = environmentService.get(request.getEnvironmentId());
|
||||
envConfig = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
Map<String,EnvironmentConfig> envConfig = new HashMap<>();
|
||||
Map<String, String> map = request.getEnvironmentMap();
|
||||
if (map != null) {
|
||||
map.keySet().forEach(id -> {
|
||||
ApiTestEnvironmentWithBLOBs environment = environmentService.get(map.get(id));
|
||||
EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
envConfig.put(id, env);
|
||||
});
|
||||
}
|
||||
ParameterConfig config = new ParameterConfig();
|
||||
config.setConfig(envConfig);
|
||||
|
|
|
@ -1,21 +1,31 @@
|
|||
package io.metersphere.api.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.api.dto.ApiDocumentInfoDTO;
|
||||
import io.metersphere.api.dto.ApiDocumentRequest;
|
||||
import io.metersphere.api.dto.ApiDocumentSimpleInfoDTO;
|
||||
import io.metersphere.api.dto.document.ApiDocumentInfoDTO;
|
||||
import io.metersphere.api.dto.document.ApiDocumentRequest;
|
||||
import io.metersphere.api.dto.document.ApiDocumentShareRequest;
|
||||
import io.metersphere.api.dto.document.ApiDocumentSimpleInfoDTO;
|
||||
import io.metersphere.api.dto.document.ApiDocumentShareType;
|
||||
import io.metersphere.api.dto.document.ApiDocumentShareDTO;
|
||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiDocumentShare;
|
||||
import io.metersphere.base.domain.ApiDocumentShareExample;
|
||||
import io.metersphere.base.mapper.ApiDocumentShareMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiDocumentMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiDocumentShareMapper;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.service.SystemParameterService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author song.tianyang
|
||||
|
@ -28,9 +38,50 @@ public class ApiDocumentService {
|
|||
|
||||
@Resource
|
||||
ExtApiDocumentMapper extApiDocumentMapper;
|
||||
@Resource
|
||||
ApiDocumentShareMapper apiDocumentShareMapper;
|
||||
@Resource
|
||||
ExtApiDocumentShareMapper extApiDocumentShareMapper;
|
||||
@Resource
|
||||
SystemParameterService systemParameterService;
|
||||
|
||||
public List<ApiDocumentSimpleInfoDTO> findApiDocumentSimpleInfoByRequest(ApiDocumentRequest request) {
|
||||
return extApiDocumentMapper.findApiDocumentSimpleInfoByRequest(request);
|
||||
public List<ApiDocumentInfoDTO> findApiDocumentSimpleInfoByRequest(ApiDocumentRequest request) {
|
||||
if (this.isParamLegitimacy(request)) {
|
||||
if (request.getProjectId() == null) {
|
||||
List<String> shareIdList = this.selectShareIdByApiDocumentShareId(request.getShareId());
|
||||
request.setApiIdList(shareIdList);
|
||||
return extApiDocumentMapper.findApiDocumentSimpleInfoByRequest(request);
|
||||
}else {
|
||||
return extApiDocumentMapper.findApiDocumentSimpleInfoByRequest(request);
|
||||
}
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> selectShareIdByApiDocumentShareId(String shareId) {
|
||||
List<String> shareApiIdList = new ArrayList<>();
|
||||
ApiDocumentShare share = apiDocumentShareMapper.selectByPrimaryKey(shareId);
|
||||
if(share!=null){
|
||||
try{
|
||||
JSONArray jsonArray = JSONArray.parseArray(share.getShareApiId());
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
String apiId = jsonArray.getString(i);
|
||||
shareApiIdList.add(apiId);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return shareApiIdList;
|
||||
}
|
||||
|
||||
//参数是否合法
|
||||
private boolean isParamLegitimacy(ApiDocumentRequest request) {
|
||||
if (StringUtils.isAllEmpty(request.getProjectId(), request.getShareId())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ApiDocumentInfoDTO conversionModelToDTO(ApiDefinitionWithBLOBs apiModel) {
|
||||
|
@ -43,208 +94,276 @@ public class ApiDocumentService {
|
|||
apiInfoDTO.setUri(apiModel.getPath());
|
||||
apiInfoDTO.setStatus(apiModel.getStatus());
|
||||
|
||||
JSONObject requestJsonObj = JSONObject.parseObject(apiModel.getRequest());
|
||||
//head赋值
|
||||
if (requestJsonObj.containsKey("headers")) {
|
||||
JSONArray requestHeadDataArr = new JSONArray();
|
||||
//head赋值
|
||||
JSONArray headArr = requestJsonObj.getJSONArray("headers");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
requestHeadDataArr.add(headObj);
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setRequestHead(requestHeadDataArr.toJSONString());
|
||||
}
|
||||
//url参数赋值
|
||||
JSONArray urlParamArr = new JSONArray();
|
||||
if (requestJsonObj.containsKey("arguments")) {
|
||||
//urlParam -- query赋值
|
||||
JSONArray headArr = requestJsonObj.getJSONArray("arguments");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
urlParamArr.add(headObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (requestJsonObj.containsKey("rest")) {
|
||||
//urlParam -- rest赋值
|
||||
JSONArray headArr = requestJsonObj.getJSONArray("rest");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
urlParamArr.add(headObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setUrlParams(urlParamArr.toJSONString());
|
||||
//请求体参数类型
|
||||
if (requestJsonObj.containsKey("body")) {
|
||||
JSONObject bodyObj = requestJsonObj.getJSONObject("body");
|
||||
if (bodyObj.containsKey("type")) {
|
||||
String type = bodyObj.getString("type");
|
||||
if(StringUtils.equals(type,"WWW_FORM")){
|
||||
apiInfoDTO.setRequestBodyParamType("x-www-from-urlencoded");
|
||||
}else if(StringUtils.equals(type,"Form Data")) {
|
||||
apiInfoDTO.setRequestBodyParamType("form-data");
|
||||
}else {
|
||||
apiInfoDTO.setRequestBodyParamType(type);
|
||||
}
|
||||
|
||||
if (StringUtils.equals(type, "JSON")) {
|
||||
//判断是否是JsonSchema
|
||||
boolean isJsonSchema = false;
|
||||
if(bodyObj.containsKey("format")){
|
||||
String foramtValue = String.valueOf(bodyObj.get("format"));
|
||||
if(StringUtils.equals("JSON-SCHEMA",foramtValue)){
|
||||
isJsonSchema = true;
|
||||
}
|
||||
if (apiModel.getRequest() != null) {
|
||||
JSONObject requestJsonObj = JSONObject.parseObject(apiModel.getRequest());
|
||||
//head赋值
|
||||
if (requestJsonObj.containsKey("headers")) {
|
||||
JSONArray requestHeadDataArr = new JSONArray();
|
||||
//head赋值
|
||||
JSONArray headArr = requestJsonObj.getJSONArray("headers");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
requestHeadDataArr.add(headObj);
|
||||
}
|
||||
if(isJsonSchema){
|
||||
apiInfoDTO.setRequestBodyParamType("JSON-SCHEMA");
|
||||
apiInfoDTO.setJsonSchemaBody(bodyObj);
|
||||
}else {
|
||||
}
|
||||
apiInfoDTO.setRequestHead(requestHeadDataArr.toJSONString());
|
||||
}
|
||||
//url参数赋值
|
||||
JSONArray urlParamArr = new JSONArray();
|
||||
if (requestJsonObj.containsKey("arguments")) {
|
||||
//urlParam -- query赋值
|
||||
JSONArray headArr = requestJsonObj.getJSONArray("arguments");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
urlParamArr.add(headObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (requestJsonObj.containsKey("rest")) {
|
||||
//urlParam -- rest赋值
|
||||
JSONArray headArr = requestJsonObj.getJSONArray("rest");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
urlParamArr.add(headObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setUrlParams(urlParamArr.toJSONString());
|
||||
//请求体参数类型
|
||||
if (requestJsonObj.containsKey("body")) {
|
||||
JSONObject bodyObj = requestJsonObj.getJSONObject("body");
|
||||
if (bodyObj.containsKey("type")) {
|
||||
String type = bodyObj.getString("type");
|
||||
if (StringUtils.equals(type, "WWW_FORM")) {
|
||||
apiInfoDTO.setRequestBodyParamType("x-www-from-urlencoded");
|
||||
} else if (StringUtils.equals(type, "Form Data")) {
|
||||
apiInfoDTO.setRequestBodyParamType("form-data");
|
||||
} else {
|
||||
apiInfoDTO.setRequestBodyParamType(type);
|
||||
}
|
||||
|
||||
if (StringUtils.equals(type, "JSON")) {
|
||||
//判断是否是JsonSchema
|
||||
boolean isJsonSchema = false;
|
||||
if (bodyObj.containsKey("format")) {
|
||||
String foramtValue = String.valueOf(bodyObj.get("format"));
|
||||
if (StringUtils.equals("JSON-SCHEMA", foramtValue)) {
|
||||
isJsonSchema = true;
|
||||
}
|
||||
}
|
||||
if (isJsonSchema) {
|
||||
apiInfoDTO.setRequestBodyParamType("JSON-SCHEMA");
|
||||
apiInfoDTO.setJsonSchemaBody(bodyObj);
|
||||
} else {
|
||||
if (bodyObj.containsKey("raw")) {
|
||||
String raw = bodyObj.getString("raw");
|
||||
apiInfoDTO.setRequestBodyStrutureData(raw);
|
||||
previewObj = JSONObject.parseObject(raw);
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.equalsAny(type, "XML", "Raw")) {
|
||||
if (bodyObj.containsKey("raw")) {
|
||||
String raw = bodyObj.getString("raw");
|
||||
apiInfoDTO.setRequestBodyStrutureData(raw);
|
||||
previewObj = JSONObject.parseObject(raw);
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.equalsAny(type, "XML", "Raw")) {
|
||||
if (bodyObj.containsKey("raw")) {
|
||||
String raw = bodyObj.getString("raw");
|
||||
apiInfoDTO.setRequestBodyStrutureData(raw);
|
||||
previewObj = JSONObject.parseObject(raw);
|
||||
}
|
||||
} else if (StringUtils.equalsAny(type, "Form Data", "WWW_FORM")) {
|
||||
if (bodyObj.containsKey("kvs")) {
|
||||
JSONArray bodyParamArr = new JSONArray();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("kvs");
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("name")&&kv.containsKey("value")) {
|
||||
bodyParamArr.add(kv);
|
||||
previewObj.put(String.valueOf(kv.get("name")),String.valueOf(kv.get("value")));
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setRequestBodyFormData(bodyParamArr.toJSONString());
|
||||
}
|
||||
} else if (StringUtils.equals(type, "BINARY")) {
|
||||
if (bodyObj.containsKey("binary")) {
|
||||
List<Map<String, String>> bodyParamList = new ArrayList<>();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("binary");
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("description") && kv.containsKey("files")) {
|
||||
Map<String, String> bodyMap = new HashMap<>();
|
||||
String name = kv.getString("description");
|
||||
JSONArray fileArr = kv.getJSONArray("files");
|
||||
String value = "";
|
||||
for (int j = 0; j < fileArr.size(); j++) {
|
||||
JSONObject fileObj = fileArr.getJSONObject(j);
|
||||
if (fileObj.containsKey("name")) {
|
||||
value += fileObj.getString("name") + " ;";
|
||||
}
|
||||
} else if (StringUtils.equalsAny(type, "Form Data", "WWW_FORM")) {
|
||||
if (bodyObj.containsKey("kvs")) {
|
||||
JSONArray bodyParamArr = new JSONArray();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("kvs");
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("name") && kv.containsKey("value")) {
|
||||
bodyParamArr.add(kv);
|
||||
previewObj.put(String.valueOf(kv.get("name")), String.valueOf(kv.get("value")));
|
||||
}
|
||||
bodyMap.put("name", name);
|
||||
bodyMap.put("value", value);
|
||||
bodyMap.put("contentType", "File");
|
||||
bodyParamList.add(bodyMap);
|
||||
|
||||
previewObj.put(String.valueOf(name),String.valueOf(value));
|
||||
}
|
||||
apiInfoDTO.setRequestBodyFormData(bodyParamArr.toJSONString());
|
||||
}
|
||||
} else if (StringUtils.equals(type, "BINARY")) {
|
||||
if (bodyObj.containsKey("binary")) {
|
||||
List<Map<String, String>> bodyParamList = new ArrayList<>();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("binary");
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("description") && kv.containsKey("files")) {
|
||||
Map<String, String> bodyMap = new HashMap<>();
|
||||
String name = kv.getString("description");
|
||||
JSONArray fileArr = kv.getJSONArray("files");
|
||||
String value = "";
|
||||
for (int j = 0; j < fileArr.size(); j++) {
|
||||
JSONObject fileObj = fileArr.getJSONObject(j);
|
||||
if (fileObj.containsKey("name")) {
|
||||
value += fileObj.getString("name") + " ;";
|
||||
}
|
||||
}
|
||||
bodyMap.put("name", name);
|
||||
bodyMap.put("value", value);
|
||||
bodyMap.put("contentType", "File");
|
||||
bodyParamList.add(bodyMap);
|
||||
|
||||
previewObj.put(String.valueOf(name), String.valueOf(value));
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setRequestBodyFormData(JSONArray.toJSONString(bodyParamList));
|
||||
}
|
||||
apiInfoDTO.setRequestBodyFormData(JSONArray.toJSONString(bodyParamList));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
JSONObject responseJsonObj = JSONObject.parseObject(apiModel.getResponse());
|
||||
|
||||
//赋值响应头
|
||||
if (responseJsonObj.containsKey("headers")) {
|
||||
JSONArray responseHeadDataArr = new JSONArray();
|
||||
JSONArray headArr = responseJsonObj.getJSONArray("headers");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
responseHeadDataArr.add(headObj);
|
||||
if (apiModel.getResponse() != null) {
|
||||
JSONObject responseJsonObj = JSONObject.parseObject(apiModel.getResponse());
|
||||
if (responseJsonObj.containsKey("headers")) {
|
||||
JSONArray responseHeadDataArr = new JSONArray();
|
||||
JSONArray headArr = responseJsonObj.getJSONArray("headers");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
responseHeadDataArr.add(headObj);
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setResponseHead(responseHeadDataArr.toJSONString());
|
||||
}
|
||||
apiInfoDTO.setResponseHead(responseHeadDataArr.toJSONString());
|
||||
}
|
||||
// 赋值响应体
|
||||
if (responseJsonObj.containsKey("body")) {
|
||||
JSONObject bodyObj = responseJsonObj.getJSONObject("body");
|
||||
if (bodyObj.containsKey("type")) {
|
||||
String type = bodyObj.getString("type");
|
||||
if(StringUtils.equals(type,"WWW_FORM")){
|
||||
apiInfoDTO.setResponseBodyParamType("x-www-from-urlencoded");
|
||||
}else if(StringUtils.equals(type,"Form Data")) {
|
||||
apiInfoDTO.setResponseBodyParamType("form-data");
|
||||
}else {
|
||||
apiInfoDTO.setResponseBodyParamType(type);
|
||||
}
|
||||
if (StringUtils.equalsAny(type, "JSON", "XML", "Raw")) {
|
||||
if (bodyObj.containsKey("raw")) {
|
||||
String raw = bodyObj.getString("raw");
|
||||
apiInfoDTO.setResponseBodyStrutureData(raw);
|
||||
// 赋值响应体
|
||||
if (responseJsonObj.containsKey("body")) {
|
||||
JSONObject bodyObj = responseJsonObj.getJSONObject("body");
|
||||
if (bodyObj.containsKey("type")) {
|
||||
String type = bodyObj.getString("type");
|
||||
if (StringUtils.equals(type, "WWW_FORM")) {
|
||||
apiInfoDTO.setResponseBodyParamType("x-www-from-urlencoded");
|
||||
} else if (StringUtils.equals(type, "Form Data")) {
|
||||
apiInfoDTO.setResponseBodyParamType("form-data");
|
||||
} else {
|
||||
apiInfoDTO.setResponseBodyParamType(type);
|
||||
}
|
||||
} else if (StringUtils.equalsAny(type, "Form Data", "WWW_FORM")) {
|
||||
if (bodyObj.containsKey("kvs")) {
|
||||
JSONArray bodyParamArr = new JSONArray();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("kvs");
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("name")) {
|
||||
bodyParamArr.add(kv);
|
||||
}
|
||||
if (StringUtils.equalsAny(type, "JSON", "XML", "Raw")) {
|
||||
if (bodyObj.containsKey("raw")) {
|
||||
String raw = bodyObj.getString("raw");
|
||||
apiInfoDTO.setResponseBodyStrutureData(raw);
|
||||
}
|
||||
apiInfoDTO.setResponseBodyFormData(bodyParamArr.toJSONString());
|
||||
}
|
||||
} else if (StringUtils.equals(type, "BINARY")) {
|
||||
if (bodyObj.containsKey("binary")) {
|
||||
List<Map<String, String>> bodyParamList = new ArrayList<>();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("kvs");
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("description") && kv.containsKey("files")) {
|
||||
Map<String, String> bodyMap = new HashMap<>();
|
||||
|
||||
String name = kv.getString("description");
|
||||
JSONArray fileArr = kv.getJSONArray("files");
|
||||
String value = "";
|
||||
for (int j = 0; j < fileArr.size(); j++) {
|
||||
JSONObject fileObj = fileArr.getJSONObject(j);
|
||||
if (fileObj.containsKey("name")) {
|
||||
value += fileObj.getString("name") + " ;";
|
||||
}
|
||||
} else if (StringUtils.equalsAny(type, "Form Data", "WWW_FORM")) {
|
||||
if (bodyObj.containsKey("kvs")) {
|
||||
JSONArray bodyParamArr = new JSONArray();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("kvs");
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("name")) {
|
||||
bodyParamArr.add(kv);
|
||||
}
|
||||
bodyMap.put("name", name);
|
||||
bodyMap.put("value", value);
|
||||
bodyParamList.add(bodyMap);
|
||||
}
|
||||
apiInfoDTO.setResponseBodyFormData(bodyParamArr.toJSONString());
|
||||
}
|
||||
} else if (StringUtils.equals(type, "BINARY")) {
|
||||
if (bodyObj.containsKey("binary")) {
|
||||
List<Map<String, String>> bodyParamList = new ArrayList<>();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("kvs");
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("description") && kv.containsKey("files")) {
|
||||
Map<String, String> bodyMap = new HashMap<>();
|
||||
|
||||
String name = kv.getString("description");
|
||||
JSONArray fileArr = kv.getJSONArray("files");
|
||||
String value = "";
|
||||
for (int j = 0; j < fileArr.size(); j++) {
|
||||
JSONObject fileObj = fileArr.getJSONObject(j);
|
||||
if (fileObj.containsKey("name")) {
|
||||
value += fileObj.getString("name") + " ;";
|
||||
}
|
||||
}
|
||||
bodyMap.put("name", name);
|
||||
bodyMap.put("value", value);
|
||||
bodyParamList.add(bodyMap);
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setResponseBodyFormData(JSONArray.toJSONString(bodyParamList));
|
||||
}
|
||||
apiInfoDTO.setResponseBodyFormData(JSONArray.toJSONString(bodyParamList));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 赋值响应码
|
||||
if (responseJsonObj.containsKey("statusCode")) {
|
||||
JSONArray responseStatusDataArr = new JSONArray();
|
||||
JSONArray statusArr = responseJsonObj.getJSONArray("statusCode");
|
||||
for (int index = 0; index < statusArr.size(); index++) {
|
||||
JSONObject statusObj = statusArr.getJSONObject(index);
|
||||
if (statusObj.containsKey("name") && statusObj.containsKey("value")) {
|
||||
responseStatusDataArr.add(statusObj);
|
||||
// 赋值响应码
|
||||
if (responseJsonObj.containsKey("statusCode")) {
|
||||
JSONArray responseStatusDataArr = new JSONArray();
|
||||
JSONArray statusArr = responseJsonObj.getJSONArray("statusCode");
|
||||
for (int index = 0; index < statusArr.size(); index++) {
|
||||
JSONObject statusObj = statusArr.getJSONObject(index);
|
||||
if (statusObj.containsKey("name") && statusObj.containsKey("value")) {
|
||||
responseStatusDataArr.add(statusObj);
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setResponseCode(responseStatusDataArr.toJSONString());
|
||||
}
|
||||
apiInfoDTO.setResponseCode(responseStatusDataArr.toJSONString());
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setRequestPreviewData(previewObj);
|
||||
return apiInfoDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 api接口文档分享信息
|
||||
* 根据要分享的api_id和分享方式来进行完全匹配搜索。
|
||||
* 搜索的到就返回那条数据,搜索不到就新增一条信息
|
||||
* @param request 入参
|
||||
* @return ApiDocumentShare数据对象
|
||||
*/
|
||||
public ApiDocumentShare generateApiDocumentShare(ApiDocumentShareRequest request) {
|
||||
ApiDocumentShare apiDocumentShare = null;
|
||||
if (request.getShareApiIdList() != null && !request.getShareApiIdList().isEmpty()
|
||||
&&StringUtils.equalsAny(request.getShareType(), ApiDocumentShareType.Single.name(),ApiDocumentShareType.Batch.name())) {
|
||||
//将ID进行排序
|
||||
List<ApiDocumentShare> apiDocumentShareList = this.findByShareTypeAndShareApiIdWithBLOBs(request.getShareType(),request.getShareApiIdList());
|
||||
if(apiDocumentShareList.isEmpty()){
|
||||
String shareApiIdJsonArrayString = this.genShareIdJsonString(request.getShareApiIdList());
|
||||
long createTime = System.currentTimeMillis();
|
||||
|
||||
apiDocumentShare = new ApiDocumentShare();
|
||||
apiDocumentShare.setId(UUID.randomUUID().toString());
|
||||
apiDocumentShare.setShareApiId(shareApiIdJsonArrayString);
|
||||
apiDocumentShare.setCreateUserId(SessionUtils.getUserId());
|
||||
apiDocumentShare.setCreateTime(createTime);
|
||||
apiDocumentShare.setUpdateTime(createTime);
|
||||
apiDocumentShare.setShareType(request.getShareType());
|
||||
apiDocumentShareMapper.insert(apiDocumentShare);
|
||||
}else {
|
||||
return apiDocumentShareList.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(apiDocumentShare==null){
|
||||
apiDocumentShare = new ApiDocumentShare();
|
||||
}
|
||||
return apiDocumentShare;
|
||||
}
|
||||
|
||||
private List<ApiDocumentShare> findByShareTypeAndShareApiIdWithBLOBs(String shareType, List<String> shareApiIdList) {
|
||||
String shareApiIdString = this.genShareIdJsonString(shareApiIdList);
|
||||
return extApiDocumentShareMapper.selectByShareTypeAndShareApiIdWithBLOBs(shareType,shareApiIdString);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据treeSet排序生成apiId的Jsonarray字符串
|
||||
* @param shareApiIdList 要分享的ID集合
|
||||
* @return 要分享的ID JSON格式字符串
|
||||
*/
|
||||
private String genShareIdJsonString(Collection<String> shareApiIdList) {
|
||||
TreeSet<String> treeSet = new TreeSet<>(shareApiIdList);
|
||||
return JSONArray.toJSONString(treeSet);
|
||||
}
|
||||
|
||||
public ApiDocumentShareDTO conversionApiDocumentShareToDTO(ApiDocumentShare apiShare) {
|
||||
ApiDocumentShareDTO returnDTO = new ApiDocumentShareDTO();
|
||||
if(!StringUtils.isEmpty(apiShare.getShareApiId())){
|
||||
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
||||
String url = "/#/apiDocumentInfo?documentId=" + apiShare.getId();
|
||||
returnDTO.setId(apiShare.getId());
|
||||
returnDTO.setShareUrl(url);
|
||||
}
|
||||
return returnDTO;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -513,9 +513,9 @@ public class ApiTestCaseService {
|
|||
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
|
||||
ApiTestEnvironmentWithBLOBs environment = environmentService.get(request.getEnvironmentId());
|
||||
ParameterConfig parameterConfig = new ParameterConfig();
|
||||
if (environment != null && environment.getConfig() != null) {
|
||||
parameterConfig.setConfig(JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class));
|
||||
}
|
||||
// if (environment != null && environment.getConfig() != null) {
|
||||
// parameterConfig.setConfig(JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class));
|
||||
// }
|
||||
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), parameterConfig);
|
||||
return jmeterHashTree;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ApiDocumentShare implements Serializable {
|
||||
private String id;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private String createUserId;
|
||||
|
||||
private Long updateTime;
|
||||
|
||||
private String shareType;
|
||||
|
||||
private String shareApiId;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,530 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ApiDocumentShareExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public ApiDocumentShareExample() {
|
||||
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 andCreateTimeIsNull() {
|
||||
addCriterion("create_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNotNull() {
|
||||
addCriterion("create_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeEqualTo(Long value) {
|
||||
addCriterion("create_time =", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotEqualTo(Long value) {
|
||||
addCriterion("create_time <>", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThan(Long value) {
|
||||
addCriterion("create_time >", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("create_time >=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThan(Long value) {
|
||||
addCriterion("create_time <", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
|
||||
addCriterion("create_time <=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIn(List<Long> values) {
|
||||
addCriterion("create_time in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotIn(List<Long> values) {
|
||||
addCriterion("create_time not in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeBetween(Long value1, Long value2) {
|
||||
addCriterion("create_time between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
|
||||
addCriterion("create_time not between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIdIsNull() {
|
||||
addCriterion("create_user_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIdIsNotNull() {
|
||||
addCriterion("create_user_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIdEqualTo(String value) {
|
||||
addCriterion("create_user_id =", value, "createUserId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIdNotEqualTo(String value) {
|
||||
addCriterion("create_user_id <>", value, "createUserId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIdGreaterThan(String value) {
|
||||
addCriterion("create_user_id >", value, "createUserId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("create_user_id >=", value, "createUserId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIdLessThan(String value) {
|
||||
addCriterion("create_user_id <", value, "createUserId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("create_user_id <=", value, "createUserId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIdLike(String value) {
|
||||
addCriterion("create_user_id like", value, "createUserId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIdNotLike(String value) {
|
||||
addCriterion("create_user_id not like", value, "createUserId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIdIn(List<String> values) {
|
||||
addCriterion("create_user_id in", values, "createUserId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIdNotIn(List<String> values) {
|
||||
addCriterion("create_user_id not in", values, "createUserId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIdBetween(String value1, String value2) {
|
||||
addCriterion("create_user_id between", value1, value2, "createUserId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIdNotBetween(String value1, String value2) {
|
||||
addCriterion("create_user_id not between", value1, value2, "createUserId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIsNull() {
|
||||
addCriterion("update_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIsNotNull() {
|
||||
addCriterion("update_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeEqualTo(Long value) {
|
||||
addCriterion("update_time =", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotEqualTo(Long value) {
|
||||
addCriterion("update_time <>", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeGreaterThan(Long value) {
|
||||
addCriterion("update_time >", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("update_time >=", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeLessThan(Long value) {
|
||||
addCriterion("update_time <", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeLessThanOrEqualTo(Long value) {
|
||||
addCriterion("update_time <=", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIn(List<Long> values) {
|
||||
addCriterion("update_time in", values, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotIn(List<Long> values) {
|
||||
addCriterion("update_time not in", values, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeBetween(Long value1, Long value2) {
|
||||
addCriterion("update_time between", value1, value2, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotBetween(Long value1, Long value2) {
|
||||
addCriterion("update_time not between", value1, value2, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andShareTypeIsNull() {
|
||||
addCriterion("share_type is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andShareTypeIsNotNull() {
|
||||
addCriterion("share_type is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andShareTypeEqualTo(String value) {
|
||||
addCriterion("share_type =", value, "shareType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andShareTypeNotEqualTo(String value) {
|
||||
addCriterion("share_type <>", value, "shareType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andShareTypeGreaterThan(String value) {
|
||||
addCriterion("share_type >", value, "shareType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andShareTypeGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("share_type >=", value, "shareType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andShareTypeLessThan(String value) {
|
||||
addCriterion("share_type <", value, "shareType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andShareTypeLessThanOrEqualTo(String value) {
|
||||
addCriterion("share_type <=", value, "shareType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andShareTypeLike(String value) {
|
||||
addCriterion("share_type like", value, "shareType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andShareTypeNotLike(String value) {
|
||||
addCriterion("share_type not like", value, "shareType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andShareTypeIn(List<String> values) {
|
||||
addCriterion("share_type in", values, "shareType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andShareTypeNotIn(List<String> values) {
|
||||
addCriterion("share_type not in", values, "shareType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andShareTypeBetween(String value1, String value2) {
|
||||
addCriterion("share_type between", value1, value2, "shareType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andShareTypeNotBetween(String value1, String value2) {
|
||||
addCriterion("share_type not between", value1, value2, "shareType");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,5 +22,9 @@ public class TestResourcePool implements Serializable {
|
|||
|
||||
private String image;
|
||||
|
||||
private String heap;
|
||||
|
||||
private String gcAlgo;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -643,6 +643,146 @@ public class TestResourcePoolExample {
|
|||
addCriterion("image not between", value1, value2, "image");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andHeapIsNull() {
|
||||
addCriterion("`heap` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andHeapIsNotNull() {
|
||||
addCriterion("`heap` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andHeapEqualTo(String value) {
|
||||
addCriterion("`heap` =", value, "heap");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andHeapNotEqualTo(String value) {
|
||||
addCriterion("`heap` <>", value, "heap");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andHeapGreaterThan(String value) {
|
||||
addCriterion("`heap` >", value, "heap");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andHeapGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("`heap` >=", value, "heap");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andHeapLessThan(String value) {
|
||||
addCriterion("`heap` <", value, "heap");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andHeapLessThanOrEqualTo(String value) {
|
||||
addCriterion("`heap` <=", value, "heap");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andHeapLike(String value) {
|
||||
addCriterion("`heap` like", value, "heap");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andHeapNotLike(String value) {
|
||||
addCriterion("`heap` not like", value, "heap");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andHeapIn(List<String> values) {
|
||||
addCriterion("`heap` in", values, "heap");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andHeapNotIn(List<String> values) {
|
||||
addCriterion("`heap` not in", values, "heap");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andHeapBetween(String value1, String value2) {
|
||||
addCriterion("`heap` between", value1, value2, "heap");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andHeapNotBetween(String value1, String value2) {
|
||||
addCriterion("`heap` not between", value1, value2, "heap");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGcAlgoIsNull() {
|
||||
addCriterion("gc_algo is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGcAlgoIsNotNull() {
|
||||
addCriterion("gc_algo is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGcAlgoEqualTo(String value) {
|
||||
addCriterion("gc_algo =", value, "gcAlgo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGcAlgoNotEqualTo(String value) {
|
||||
addCriterion("gc_algo <>", value, "gcAlgo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGcAlgoGreaterThan(String value) {
|
||||
addCriterion("gc_algo >", value, "gcAlgo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGcAlgoGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("gc_algo >=", value, "gcAlgo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGcAlgoLessThan(String value) {
|
||||
addCriterion("gc_algo <", value, "gcAlgo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGcAlgoLessThanOrEqualTo(String value) {
|
||||
addCriterion("gc_algo <=", value, "gcAlgo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGcAlgoLike(String value) {
|
||||
addCriterion("gc_algo like", value, "gcAlgo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGcAlgoNotLike(String value) {
|
||||
addCriterion("gc_algo not like", value, "gcAlgo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGcAlgoIn(List<String> values) {
|
||||
addCriterion("gc_algo in", values, "gcAlgo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGcAlgoNotIn(List<String> values) {
|
||||
addCriterion("gc_algo not in", values, "gcAlgo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGcAlgoBetween(String value1, String value2) {
|
||||
addCriterion("gc_algo between", value1, value2, "gcAlgo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGcAlgoNotBetween(String value1, String value2) {
|
||||
addCriterion("gc_algo not between", value1, value2, "gcAlgo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package io.metersphere.base.mapper;
|
||||
|
||||
import io.metersphere.base.domain.ApiDocumentShare;
|
||||
import io.metersphere.base.domain.ApiDocumentShareExample;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface ApiDocumentShareMapper {
|
||||
long countByExample(ApiDocumentShareExample example);
|
||||
|
||||
int deleteByExample(ApiDocumentShareExample example);
|
||||
|
||||
int deleteByPrimaryKey(String id);
|
||||
|
||||
int insert(ApiDocumentShare record);
|
||||
|
||||
int insertSelective(ApiDocumentShare record);
|
||||
|
||||
List<ApiDocumentShare> selectByExampleWithBLOBs(ApiDocumentShareExample example);
|
||||
|
||||
List<ApiDocumentShare> selectByExample(ApiDocumentShareExample example);
|
||||
|
||||
ApiDocumentShare selectByPrimaryKey(String id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") ApiDocumentShare record, @Param("example") ApiDocumentShareExample example);
|
||||
|
||||
int updateByExampleWithBLOBs(@Param("record") ApiDocumentShare record, @Param("example") ApiDocumentShareExample example);
|
||||
|
||||
int updateByExample(@Param("record") ApiDocumentShare record, @Param("example") ApiDocumentShareExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(ApiDocumentShare record);
|
||||
|
||||
int updateByPrimaryKeyWithBLOBs(ApiDocumentShare record);
|
||||
|
||||
int updateByPrimaryKey(ApiDocumentShare record);
|
||||
}
|
|
@ -0,0 +1,270 @@
|
|||
<?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.ApiDocumentShareMapper">
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.ApiDocumentShare">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
<result column="share_type" jdbcType="VARCHAR" property="shareType" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiDocumentShare">
|
||||
<result column="share_api_id" jdbcType="LONGVARCHAR" property="shareApiId" />
|
||||
</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, create_time, create_user_id, update_time, share_type
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
share_api_id
|
||||
</sql>
|
||||
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.ApiDocumentShareExample" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
from api_document_share
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByExample" parameterType="io.metersphere.base.domain.ApiDocumentShareExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from api_document_share
|
||||
<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="ResultMapWithBLOBs">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
from api_document_share
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
delete from api_document_share
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.ApiDocumentShareExample">
|
||||
delete from api_document_share
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.base.domain.ApiDocumentShare">
|
||||
insert into api_document_share (id, create_time, create_user_id,
|
||||
update_time, share_type, share_api_id
|
||||
)
|
||||
values (#{id,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{createUserId,jdbcType=VARCHAR},
|
||||
#{updateTime,jdbcType=BIGINT}, #{shareType,jdbcType=VARCHAR}, #{shareApiId,jdbcType=LONGVARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiDocumentShare">
|
||||
insert into api_document_share
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="createUserId != null">
|
||||
create_user_id,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="shareType != null">
|
||||
share_type,
|
||||
</if>
|
||||
<if test="shareApiId != null">
|
||||
share_api_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="createUserId != null">
|
||||
#{createUserId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="shareType != null">
|
||||
#{shareType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="shareApiId != null">
|
||||
#{shareApiId,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.metersphere.base.domain.ApiDocumentShareExample" resultType="java.lang.Long">
|
||||
select count(*) from api_document_share
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update api_document_share
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.createUserId != null">
|
||||
create_user_id = #{record.createUserId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.shareType != null">
|
||||
share_type = #{record.shareType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.shareApiId != null">
|
||||
share_api_id = #{record.shareApiId,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExampleWithBLOBs" parameterType="map">
|
||||
update api_document_share
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
create_user_id = #{record.createUserId,jdbcType=VARCHAR},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
share_type = #{record.shareType,jdbcType=VARCHAR},
|
||||
share_api_id = #{record.shareApiId,jdbcType=LONGVARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update api_document_share
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
create_user_id = #{record.createUserId,jdbcType=VARCHAR},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
share_type = #{record.shareType,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.ApiDocumentShare">
|
||||
update api_document_share
|
||||
<set>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="createUserId != null">
|
||||
create_user_id = #{createUserId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="shareType != null">
|
||||
share_type = #{shareType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="shareApiId != null">
|
||||
share_api_id = #{shareApiId,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.ApiDocumentShare">
|
||||
update api_document_share
|
||||
set create_time = #{createTime,jdbcType=BIGINT},
|
||||
create_user_id = #{createUserId,jdbcType=VARCHAR},
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
share_type = #{shareType,jdbcType=VARCHAR},
|
||||
share_api_id = #{shareApiId,jdbcType=LONGVARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.ApiDocumentShare">
|
||||
update api_document_share
|
||||
set create_time = #{createTime,jdbcType=BIGINT},
|
||||
create_user_id = #{createUserId,jdbcType=VARCHAR},
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
share_type = #{shareType,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
|
@ -10,6 +10,8 @@
|
|||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
<result column="image" jdbcType="VARCHAR" property="image" />
|
||||
<result column="heap" jdbcType="VARCHAR" property="heap" />
|
||||
<result column="gc_algo" jdbcType="VARCHAR" property="gcAlgo" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
|
@ -70,7 +72,8 @@
|
|||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, `name`, `type`, description, `status`, create_time, update_time, image
|
||||
id, `name`, `type`, description, `status`, create_time, update_time, image, `heap`,
|
||||
gc_algo
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestResourcePoolExample" resultMap="BaseResultMap">
|
||||
select
|
||||
|
@ -105,10 +108,12 @@
|
|||
<insert id="insert" parameterType="io.metersphere.base.domain.TestResourcePool">
|
||||
insert into test_resource_pool (id, `name`, `type`,
|
||||
description, `status`, create_time,
|
||||
update_time, image)
|
||||
update_time, image, `heap`,
|
||||
gc_algo)
|
||||
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
|
||||
#{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
|
||||
#{updateTime,jdbcType=BIGINT}, #{image,jdbcType=VARCHAR})
|
||||
#{updateTime,jdbcType=BIGINT}, #{image,jdbcType=VARCHAR}, #{heap,jdbcType=VARCHAR},
|
||||
#{gcAlgo,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestResourcePool">
|
||||
insert into test_resource_pool
|
||||
|
@ -137,6 +142,12 @@
|
|||
<if test="image != null">
|
||||
image,
|
||||
</if>
|
||||
<if test="heap != null">
|
||||
`heap`,
|
||||
</if>
|
||||
<if test="gcAlgo != null">
|
||||
gc_algo,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
|
@ -163,6 +174,12 @@
|
|||
<if test="image != null">
|
||||
#{image,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="heap != null">
|
||||
#{heap,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="gcAlgo != null">
|
||||
#{gcAlgo,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.metersphere.base.domain.TestResourcePoolExample" resultType="java.lang.Long">
|
||||
|
@ -198,6 +215,12 @@
|
|||
<if test="record.image != null">
|
||||
image = #{record.image,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.heap != null">
|
||||
`heap` = #{record.heap,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.gcAlgo != null">
|
||||
gc_algo = #{record.gcAlgo,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
|
@ -212,7 +235,9 @@
|
|||
`status` = #{record.status,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
image = #{record.image,jdbcType=VARCHAR}
|
||||
image = #{record.image,jdbcType=VARCHAR},
|
||||
`heap` = #{record.heap,jdbcType=VARCHAR},
|
||||
gc_algo = #{record.gcAlgo,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
|
@ -241,6 +266,12 @@
|
|||
<if test="image != null">
|
||||
image = #{image,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="heap != null">
|
||||
`heap` = #{heap,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="gcAlgo != null">
|
||||
gc_algo = #{gcAlgo,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
|
@ -252,7 +283,9 @@
|
|||
`status` = #{status,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
image = #{image,jdbcType=VARCHAR}
|
||||
image = #{image,jdbcType=VARCHAR},
|
||||
`heap` = #{heap,jdbcType=VARCHAR},
|
||||
gc_algo = #{gcAlgo,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
|
@ -1,11 +1,12 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import io.metersphere.api.dto.ApiDocumentRequest;
|
||||
import io.metersphere.api.dto.ApiDocumentSimpleInfoDTO;
|
||||
import io.metersphere.api.dto.document.ApiDocumentInfoDTO;
|
||||
import io.metersphere.api.dto.document.ApiDocumentRequest;
|
||||
import io.metersphere.api.dto.document.ApiDocumentSimpleInfoDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtApiDocumentMapper {
|
||||
List<ApiDocumentSimpleInfoDTO> findApiDocumentSimpleInfoByRequest(@Param("request") ApiDocumentRequest request);
|
||||
List<ApiDocumentInfoDTO> findApiDocumentSimpleInfoByRequest(@Param("request") ApiDocumentRequest request);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?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.ExtApiDocumentMapper">
|
||||
<select id="findApiDocumentSimpleInfoByRequest" resultType="io.metersphere.api.dto.ApiDocumentSimpleInfoDTO">
|
||||
<select id="findApiDocumentSimpleInfoByRequest" resultType="io.metersphere.api.dto.document.ApiDocumentInfoDTO">
|
||||
SELECT api.id,api.name FROM Api_definition api
|
||||
<where>
|
||||
<if test="request.projectId != null">
|
||||
|
@ -13,13 +13,18 @@
|
|||
<if test="request.type != null and request.type != '' and request.type != 'ALL' ">
|
||||
AND api.method = #{request.type}
|
||||
</if>
|
||||
|
||||
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
|
||||
AND api.module_id in
|
||||
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
|
||||
#{nodeId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.apiIdList != null and request.apiIdList.size() > 0">
|
||||
AND api.id in
|
||||
<foreach collection="request.apiIdList" item="apiId" separator="," open="(" close=")">
|
||||
#{apiId}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
<if test="request.orderCondition == 'createTimeDesc'">
|
||||
ORDER BY api.create_time DESC
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import io.metersphere.base.domain.ApiDocumentShare;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtApiDocumentShareMapper {
|
||||
List<ApiDocumentShare> selectByShareTypeAndShareApiIdWithBLOBs(@Param("shareType") String shareType, @Param("shareApiId") String shareApiIdString);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?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.ExtApiDocumentShareMapper">
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.ApiDocumentShare">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
<result column="share_type" jdbcType="VARCHAR" property="shareType" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiDocumentShare">
|
||||
<result column="share_api_id" jdbcType="LONGVARCHAR" property="shareApiId" />
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByShareTypeAndShareApiIdWithBLOBs" resultMap="ResultMapWithBLOBs">
|
||||
SELECT id,share_type,share_api_id FROM api_document_share
|
||||
<where>
|
||||
share_type = #{shareType} AND share_api_id = #{shareApiId}
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
|
@ -38,6 +38,9 @@ public class ShiroUtils {
|
|||
|
||||
filterChainDefinitionMap.put("/403", "anon");
|
||||
filterChainDefinitionMap.put("/anonymous/**", "anon");
|
||||
|
||||
//api-对外文档页面提供的查询接口
|
||||
filterChainDefinitionMap.put("/api/document/**", "anon");
|
||||
}
|
||||
|
||||
public static Cookie getSessionIdCookie(){
|
||||
|
|
|
@ -24,6 +24,8 @@ import java.util.UUID;
|
|||
|
||||
public abstract class AbstractEngine implements Engine {
|
||||
protected String JMETER_IMAGE;
|
||||
protected String HEAP;
|
||||
protected String GC_ALGO;
|
||||
private Long startTime;
|
||||
private String reportId;
|
||||
protected LoadTestWithBLOBs loadTest;
|
||||
|
@ -38,6 +40,8 @@ public abstract class AbstractEngine implements Engine {
|
|||
testResourcePoolService = CommonBeanFactory.getBean(TestResourcePoolService.class);
|
||||
testResourceService = CommonBeanFactory.getBean(TestResourceService.class);
|
||||
JMETER_IMAGE = CommonBeanFactory.getBean(JmeterProperties.class).getImage();
|
||||
HEAP = CommonBeanFactory.getBean(JmeterProperties.class).getHeap();
|
||||
GC_ALGO = CommonBeanFactory.getBean(JmeterProperties.class).getGcAlgo();
|
||||
this.startTime = System.currentTimeMillis();
|
||||
this.reportId = UUID.randomUUID().toString();
|
||||
}
|
||||
|
@ -71,6 +75,16 @@ public abstract class AbstractEngine implements Engine {
|
|||
if (StringUtils.isNotEmpty(image)) {
|
||||
JMETER_IMAGE = image;
|
||||
}
|
||||
// heap
|
||||
String heap = resourcePool.getHeap();
|
||||
if (StringUtils.isNotEmpty(heap)) {
|
||||
HEAP = heap;
|
||||
}
|
||||
// gc_algo
|
||||
String gcAlgo = resourcePool.getGcAlgo();
|
||||
if (StringUtils.isNotEmpty(gcAlgo)) {
|
||||
GC_ALGO = gcAlgo;
|
||||
}
|
||||
this.resourceList = testResourceService.getResourcesByPoolId(resourcePool.getId());
|
||||
if (CollectionUtils.isEmpty(this.resourceList)) {
|
||||
MSException.throwException("Test Resource is empty");
|
||||
|
|
|
@ -7,7 +7,6 @@ import io.metersphere.commons.constants.ResourceStatusEnum;
|
|||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.UrlTestUtils;
|
||||
import io.metersphere.config.JmeterProperties;
|
||||
import io.metersphere.config.KafkaProperties;
|
||||
import io.metersphere.controller.ResultHolder;
|
||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||
|
@ -73,7 +72,6 @@ public class DockerTestEngine extends AbstractEngine {
|
|||
|
||||
BaseSystemConfigDTO baseInfo = CommonBeanFactory.getBean(SystemParameterService.class).getBaseInfo();
|
||||
KafkaProperties kafkaProperties = CommonBeanFactory.getBean(KafkaProperties.class);
|
||||
JmeterProperties jmeterProperties = CommonBeanFactory.getBean(JmeterProperties.class);
|
||||
String metersphereUrl = "http://localhost:8081"; // 占位符
|
||||
if (baseInfo != null) {
|
||||
metersphereUrl = baseInfo.getUrl();
|
||||
|
@ -96,8 +94,8 @@ public class DockerTestEngine extends AbstractEngine {
|
|||
env.put("LOG_TOPIC", kafkaProperties.getLog().getTopic());
|
||||
env.put("RESOURCE_ID", resource.getId());
|
||||
env.put("THREAD_NUM", "0");// 传入0表示不用修改线程数
|
||||
env.put("HEAP", jmeterProperties.getHeap());
|
||||
env.put("GC_ALGO", jmeterProperties.getGcAlgo());
|
||||
env.put("HEAP", HEAP);
|
||||
env.put("GC_ALGO", GC_ALGO);
|
||||
|
||||
|
||||
StartTestRequest startTestRequest = new StartTestRequest();
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package io.metersphere.performance.engine.producer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -11,22 +9,16 @@ import javax.annotation.Resource;
|
|||
|
||||
@Service
|
||||
public class LoadTestProducer {
|
||||
private static final String SEPARATOR = " ";
|
||||
|
||||
@Value("${kafka.topic}")
|
||||
@Value("${kafka.log.topic}")
|
||||
private String topic;
|
||||
@Resource
|
||||
private KafkaTemplate<String, Object> kafkaTemplate;
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
public void sendMessage(String reportId) {
|
||||
Metric metric = new Metric();
|
||||
metric.setReportId(reportId);
|
||||
metric.setThreadName("tearDown Thread Group"); // 发送停止消息
|
||||
try {
|
||||
this.kafkaTemplate.send(topic, objectMapper.writeValueAsString(metric));
|
||||
} catch (JsonProcessingException e) {
|
||||
LogUtil.error("发送停止消息失败", e);
|
||||
}
|
||||
String[] contents = new String[]{reportId, "none", "0", "Notifying test listeners of end of test"};
|
||||
String log = StringUtils.join(contents, SEPARATOR);
|
||||
this.kafkaTemplate.send(topic, log);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
package io.metersphere.performance.engine.producer;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Metric {
|
||||
@JsonProperty("test.id")
|
||||
private String testId;
|
||||
@JsonProperty("test.name")
|
||||
private String testName;
|
||||
@JsonProperty("test.startTime")
|
||||
private Long clusterStartTime;
|
||||
@JsonProperty("test.reportId")
|
||||
private String reportId;
|
||||
@JsonProperty("ContentType")
|
||||
private String contentType;
|
||||
@JsonProperty("IdleTime")
|
||||
private Integer idleTime;
|
||||
@JsonProperty("ElapsedTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZZ")
|
||||
private Date elapsedTime;
|
||||
@JsonProperty("ErrorCount")
|
||||
private Integer errorCount;
|
||||
@JsonProperty("Timestamp")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZZ")
|
||||
private Date timestamp;
|
||||
@JsonProperty("URL")
|
||||
private String url;
|
||||
@JsonProperty("SampleStartTime")
|
||||
private String sampleStartTime;
|
||||
@JsonProperty("Success")
|
||||
private Boolean success;
|
||||
@JsonProperty("Bytes")
|
||||
private Integer bytes;
|
||||
@JsonProperty("SentBytes")
|
||||
private Integer sentBytes;
|
||||
@JsonProperty("AllThreads")
|
||||
private Integer allThreads;
|
||||
@JsonProperty("TestElement.name")
|
||||
private String testElementName;
|
||||
@JsonProperty("DataType")
|
||||
private String dataType;
|
||||
@JsonProperty("ResponseTime")
|
||||
private Integer responseTime;
|
||||
@JsonProperty("SampleCount")
|
||||
private Integer sampleCount;
|
||||
@JsonProperty("FailureMessage")
|
||||
private String failureMessage;
|
||||
@JsonProperty("ConnectTime")
|
||||
private Integer connectTime;
|
||||
@JsonProperty("ResponseCode")
|
||||
private String responseCode;
|
||||
@JsonProperty("TestStartTime")
|
||||
private Long testStartTime;
|
||||
@JsonProperty("AssertionResults")
|
||||
private List<Object> assertionResults;
|
||||
@JsonProperty("Latency")
|
||||
private Integer latency;
|
||||
@JsonProperty("InjectorHostname")
|
||||
private String injectorHostname;
|
||||
@JsonProperty("GrpThreads")
|
||||
private Integer grpThreads;
|
||||
@JsonProperty("SampleEndTime")
|
||||
private String sampleEndTime;
|
||||
@JsonProperty("BodySize")
|
||||
private Long bodySize;
|
||||
@JsonProperty("ThreadName")
|
||||
private String threadName;
|
||||
@JsonProperty("SampleLabel")
|
||||
private String sampleLabel;
|
||||
|
||||
}
|
|
@ -457,6 +457,8 @@ public class TestCaseService {
|
|||
}
|
||||
|
||||
private List<TestCaseExcelData> generateTestCaseExcel(TestCaseBatchRequest request) {
|
||||
ServiceUtils.getSelectAllIds(request, request.getCondition(),
|
||||
(query) -> extTestCaseMapper.selectIds(query));
|
||||
List<OrderRequest> orderList = ServiceUtils.getDefaultOrder(request.getOrders());
|
||||
OrderRequest order = new OrderRequest();
|
||||
order.setName("sort");
|
||||
|
|
|
@ -169,7 +169,7 @@ public class TestPlanService {
|
|||
testPlan.setActualEndTime(null);
|
||||
} // 已完成->进行中,结束时间置空
|
||||
} else if (!res.getStatus().equals(TestPlanStatus.Prepare.name()) &&
|
||||
testPlan.getStatus().equals(TestPlanStatus.Prepare.name())) {
|
||||
TestPlanStatus.Prepare.name().equals(testPlan.getStatus())) {
|
||||
testPlan.setActualStartTime(null);
|
||||
testPlan.setActualEndTime(null);
|
||||
} // 非未开始->未开始,时间都置空
|
||||
|
@ -183,7 +183,7 @@ public class TestPlanService {
|
|||
List<String> userIds = new ArrayList<>();
|
||||
userIds.add(testPlan.getPrincipal());
|
||||
AddTestPlanRequest testPlans = new AddTestPlanRequest();
|
||||
int i = testPlanMapper.updateByPrimaryKey(testPlan); // 更新
|
||||
int i = testPlanMapper.updateByPrimaryKeySelective(testPlan); // 更新
|
||||
if (!StringUtils.isBlank(testPlan.getStatus())) {
|
||||
BeanUtils.copyBean(testPlans, getTestPlan(testPlan.getId()));
|
||||
String context = getTestPlanContext(testPlans, NoticeConstants.Event.UPDATE);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 4283ddbe7d60aa83ec94ee770fc93485a0c3e85f
|
||||
Subproject commit e6af25ffb8cabdfc2de5ae07cb04492cc78345f3
|
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE test_resource_pool
|
||||
ADD heap VARCHAR(200) NULL;
|
||||
ALTER TABLE test_resource_pool
|
||||
ADD gc_algo VARCHAR(200) NULL;
|
|
@ -0,0 +1,11 @@
|
|||
CREATE TABLE `metersphere_dev`.`api_document_share` (
|
||||
`id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'Api Document Share Info ID',
|
||||
`create_time` BIGINT ( 13 ) NOT NULL COMMENT 'Create timestamp',
|
||||
`create_user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
|
||||
`update_time` BIGINT ( 13 ) NOT NULL COMMENT 'last visit timestamp',
|
||||
`share_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'single or batch',
|
||||
`share_api_id` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'APiDefinition.id (JSONArray format. Order by TreeSet)',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `share_type`(`share_type`) USING BTREE,
|
||||
INDEX `share_api_id`(`share_api_id`(125)) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
|
|
@ -36,6 +36,7 @@
|
|||
"sha.js": "^2.4.11",
|
||||
"vue": "^2.6.10",
|
||||
"vue-calendar-heatmap": "^0.8.4",
|
||||
"vue-clipboard2": "^0.3.1",
|
||||
"vue-echarts": "^4.1.0",
|
||||
"vue-float-action-button": "^0.6.6",
|
||||
"vue-i18n": "^8.15.3",
|
||||
|
|
|
@ -0,0 +1,148 @@
|
|||
<template>
|
||||
<el-dialog
|
||||
title="环境选择"
|
||||
:visible.sync="dialogVisible"
|
||||
width="30%"
|
||||
:destroy-on-close="true"
|
||||
:before-close="handleClose">
|
||||
|
||||
<div v-for="pe in data" :key="pe.id">
|
||||
<div>
|
||||
{{ getProjectName(pe.id) }}
|
||||
<el-select v-model="pe['selectEnv']" placeholder="请选择环境" style="margin-left:10px; margin-top: 10px;"
|
||||
size="small">
|
||||
<el-option v-for="(environment, index) in pe.envs" :key="index"
|
||||
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
|
||||
:value="environment.id"/>
|
||||
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id)">
|
||||
{{ $t('api_test.environment.environment_config') }}
|
||||
</el-button>
|
||||
<template v-slot:empty>
|
||||
<div class="empty-environment">
|
||||
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id)">
|
||||
{{ $t('api_test.environment.environment_config') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false" size="small">取 消</el-button>
|
||||
<el-button type="primary" @click="handleConfirm" size="small">确 定</el-button>
|
||||
</span>
|
||||
<api-environment-config ref="environmentConfig" @close="environmentConfigClose"/>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel";
|
||||
import ApiEnvironmentConfig from "@/business/components/api/definition/components/environment/ApiEnvironmentConfig";
|
||||
export default {
|
||||
name: "ApiScenarioEnv",
|
||||
components: {ApiEnvironmentConfig},
|
||||
props: {
|
||||
projectIds: Set,
|
||||
envMap: Map
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
projects: [],
|
||||
data: [],
|
||||
environmentId: '',
|
||||
environments: []
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getWsProjects();
|
||||
},
|
||||
methods: {
|
||||
handleClose() {
|
||||
this.dialogVisible = false;
|
||||
},
|
||||
init() {
|
||||
this.projectIds.forEach(id => {
|
||||
this.result = this.$get('/api/environment/list/' + id, res => {
|
||||
let envs = res.data;
|
||||
envs.forEach(environment => {
|
||||
parseEnvironment(environment);
|
||||
});
|
||||
let item = {};
|
||||
item.id = id;
|
||||
item.envs = envs;
|
||||
item.selectEnv = this.envMap.get(id);
|
||||
this.data.push(item)
|
||||
})
|
||||
})
|
||||
},
|
||||
open() {
|
||||
this.data = [];
|
||||
this.dialogVisible = true;
|
||||
if (this.projectIds.size > 0) {
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
getWsProjects() {
|
||||
this.$get("/project/listAll", res => {
|
||||
this.projects = res.data;
|
||||
})
|
||||
},
|
||||
getProjectName(id) {
|
||||
const project = this.projects.find(p => p.id === id);
|
||||
return project ? project.name : "";
|
||||
},
|
||||
openEnvironmentConfig(projectId) {
|
||||
if (!projectId) {
|
||||
this.$error(this.$t('api_test.select_project'));
|
||||
return;
|
||||
}
|
||||
this.$refs.environmentConfig.open(projectId);
|
||||
},
|
||||
handleConfirm() {
|
||||
let map = new Map();
|
||||
let sign = true;
|
||||
this.data.forEach(dt => {
|
||||
if (!dt.selectEnv) {
|
||||
sign = false;
|
||||
return;
|
||||
}
|
||||
map.set(dt.id, dt.selectEnv);
|
||||
})
|
||||
if (!sign) {
|
||||
this.$warning("请为每个项目选择一个运行环境!");
|
||||
return;
|
||||
}
|
||||
this.$emit('setProjectEnvMap', map);
|
||||
this.dialogVisible = false;
|
||||
},
|
||||
checkEnv() {
|
||||
let sign = true;
|
||||
if (this.data.length > 0) {
|
||||
this.data.forEach(dt => {
|
||||
if (!dt.selectEnv) {
|
||||
sign = false;
|
||||
return;
|
||||
}
|
||||
})
|
||||
} else {
|
||||
sign = false;
|
||||
}
|
||||
|
||||
if (!sign) {
|
||||
this.$warning("请为每个项目选择一个运行环境!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
environmentConfigClose(id) {
|
||||
// todo
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -360,7 +360,7 @@
|
|||
this.changeSelectDataRangeAll();
|
||||
this.search();
|
||||
},
|
||||
search() {
|
||||
search(projectId) {
|
||||
this.selectRows = new Set();
|
||||
getLabel(this, API_SCENARIO_LIST);
|
||||
this.condition.moduleIds = this.selectNodeIds;
|
||||
|
@ -369,7 +369,10 @@
|
|||
this.condition.moduleIds = [];
|
||||
}
|
||||
|
||||
if (this.projectId != null) {
|
||||
// todo
|
||||
if (projectId != null && typeof projectId === 'string') {
|
||||
this.condition.projectId = projectId;
|
||||
} else if (this.projectId != null) {
|
||||
this.condition.projectId = this.projectId;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
name: 'MsDebugRun',
|
||||
components: {},
|
||||
props: {
|
||||
environment: String,
|
||||
environment: Map,
|
||||
debug: Boolean,
|
||||
reportId: String,
|
||||
runData: Object,
|
||||
|
@ -112,9 +112,12 @@
|
|||
threadGroup.hashTree = [];
|
||||
threadGroup.name = this.reportId;
|
||||
threadGroup.enableCookieShare = this.runData.enableCookieShare;
|
||||
let map = this.environment;
|
||||
this.runData.projectId = getCurrentProjectID();
|
||||
threadGroup.hashTree.push(this.runData);
|
||||
testPlan.hashTree.push(threadGroup);
|
||||
let reqObj = {id: this.reportId, reportId: this.reportId, scenarioName: this.runData.name, scenarioId: this.runData.id, environmentId: this.environment, testElement: testPlan, projectId: getCurrentProjectID()};
|
||||
let reqObj = {id: this.reportId, reportId: this.reportId, scenarioName: this.runData.name,
|
||||
scenarioId: this.runData.id, testElement: testPlan, projectId: getCurrentProjectID(), environmentMap: this.strMapToObj(map)};
|
||||
let bodyFiles = this.getBodyUploadFiles(reqObj);
|
||||
let url = "/api/automation/run/debug";
|
||||
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
|
||||
|
@ -122,6 +125,13 @@
|
|||
this.$emit('runRefresh', {});
|
||||
}, erro => {
|
||||
});
|
||||
},
|
||||
strMapToObj(strMap){
|
||||
let obj= Object.create(null);
|
||||
for (let[k,v] of strMap) {
|
||||
obj[k] = v;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,24 +111,26 @@
|
|||
<el-col :span="3" class="ms-col-one ms-font">
|
||||
<el-checkbox v-model="enableCookieShare">共享cookie</el-checkbox>
|
||||
</el-col>
|
||||
<el-col :span="7" class="ms-font">
|
||||
<el-select v-model="currentEnvironmentId" size="small" class="ms-htt-width"
|
||||
:placeholder="$t('api_test.definition.request.run_env')"
|
||||
clearable>
|
||||
<el-option v-for="(environment, index) in environments" :key="index"
|
||||
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
|
||||
:value="environment.id"/>
|
||||
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig">
|
||||
{{ $t('api_test.environment.environment_config') }}
|
||||
</el-button>
|
||||
<template v-slot:empty>
|
||||
<div class="empty-environment">
|
||||
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig">
|
||||
{{ $t('api_test.environment.environment_config') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-select>
|
||||
<el-col :span="7" class="ms-col-one ms-font">
|
||||
<el-link type="primary" @click="handleEnv">环境配置</el-link>
|
||||
<!-- <el-select v-model="currentEnvironmentId" size="small" class="ms-htt-width"-->
|
||||
<!-- :placeholder="$t('api_test.definition.request.run_env')"-->
|
||||
<!-- clearable>-->
|
||||
<!-- <el-option v-for="(environment, index) in environments" :key="index"-->
|
||||
<!-- :label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"-->
|
||||
<!-- :value="environment.id"/>-->
|
||||
<!-- <el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig">-->
|
||||
<!-- {{ $t('api_test.environment.environment_config') }}-->
|
||||
<!-- </el-button>-->
|
||||
<!-- <template v-slot:empty>-->
|
||||
<!-- <div class="empty-environment">-->
|
||||
<!-- <el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig">-->
|
||||
<!-- {{ $t('api_test.environment.environment_config') }}-->
|
||||
<!-- </el-button>-->
|
||||
<!-- </div>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-select>-->
|
||||
|
||||
</el-col>
|
||||
<el-col :span="2">
|
||||
<el-button :disabled="scenarioDefinition.length < 1" size="small" type="primary" @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
|
||||
|
@ -184,11 +186,13 @@
|
|||
<!--场景导入 -->
|
||||
<scenario-relevance @save="addScenario" ref="scenarioRelevance"/>
|
||||
|
||||
<api-scenario-env :project-ids="projectIds" :env-map="projectEnvMap" ref="apiScenarioEnv" @setProjectEnvMap="setProjectEnvMap"/>
|
||||
|
||||
<!-- 环境 -->
|
||||
<api-environment-config ref="environmentConfig" @close="environmentConfigClose"/>
|
||||
|
||||
<!--执行组件-->
|
||||
<ms-run :debug="true" :environment="currentEnvironmentId" :reportId="reportId" :run-data="debugData"
|
||||
<ms-run :debug="true" :environment="projectEnvMap" :reportId="reportId" :run-data="debugData"
|
||||
@runRefresh="runRefresh" ref="runTest"/>
|
||||
<!-- 调试结果 -->
|
||||
<el-drawer :visible.sync="debugVisible" :destroy-on-close="true" direction="ltr" :withHeader="true" :modal="false" size="90%">
|
||||
|
@ -204,44 +208,47 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {API_STATUS, PRIORITY} from "../../definition/model/JsonData";
|
||||
import {WORKSPACE_ID} from '@/common/js/constants';
|
||||
import {
|
||||
Assertions,
|
||||
ConstantTimer,
|
||||
Extract,
|
||||
IfController,
|
||||
JSR223Processor,
|
||||
LoopController
|
||||
} from "../../definition/model/ApiTestModel";
|
||||
import {parseEnvironment} from "../../definition/model/EnvironmentModel";
|
||||
import {ELEMENT_TYPE, ELEMENTS} from "./Setting";
|
||||
import MsApiCustomize from "./ApiCustomize";
|
||||
import {getCurrentProjectID, getUUID} from "@/common/js/utils";
|
||||
import ApiEnvironmentConfig from "../../definition/components/environment/ApiEnvironmentConfig";
|
||||
import MsInputTag from "./MsInputTag";
|
||||
import MsRun from "./DebugRun";
|
||||
import MsApiReportDetail from "../report/ApiReportDetail";
|
||||
import MsVariableList from "./variable/VariableList";
|
||||
import ApiImport from "../../definition/components/import/ApiImport";
|
||||
import "@/common/css/material-icons.css"
|
||||
import OutsideClick from "@/common/js/outside-click";
|
||||
import ScenarioApiRelevance from "./api/ApiRelevance";
|
||||
import ScenarioRelevance from "./api/ScenarioRelevance";
|
||||
import MsComponentConfig from "./component/ComponentConfig";
|
||||
import {handleCtrlSEvent} from "../../../../../common/js/utils";
|
||||
import {API_STATUS, PRIORITY} from "../../definition/model/JsonData";
|
||||
import {WORKSPACE_ID} from '@/common/js/constants';
|
||||
import {
|
||||
Assertions,
|
||||
ConstantTimer,
|
||||
Extract,
|
||||
IfController,
|
||||
JSR223Processor,
|
||||
LoopController
|
||||
} from "../../definition/model/ApiTestModel";
|
||||
import {parseEnvironment} from "../../definition/model/EnvironmentModel";
|
||||
import {ELEMENT_TYPE, ELEMENTS} from "./Setting";
|
||||
import MsApiCustomize from "./ApiCustomize";
|
||||
import {getCurrentProjectID, getUUID} from "@/common/js/utils";
|
||||
import ApiEnvironmentConfig from "../../definition/components/environment/ApiEnvironmentConfig";
|
||||
import MsInputTag from "./MsInputTag";
|
||||
import MsRun from "./DebugRun";
|
||||
import MsApiReportDetail from "../report/ApiReportDetail";
|
||||
import MsVariableList from "./variable/VariableList";
|
||||
import ApiImport from "../../definition/components/import/ApiImport";
|
||||
import "@/common/css/material-icons.css"
|
||||
import OutsideClick from "@/common/js/outside-click";
|
||||
import ScenarioApiRelevance from "./api/ApiRelevance";
|
||||
import ScenarioRelevance from "./api/ScenarioRelevance";
|
||||
import MsComponentConfig from "./component/ComponentConfig";
|
||||
import {handleCtrlSEvent} from "../../../../../common/js/utils";
|
||||
import {getProject} from "@/business/components/api/automation/scenario/event";
|
||||
import ApiScenarioEnv from "@/business/components/api/automation/scenario/ApiScenarioEnv";
|
||||
|
||||
export default {
|
||||
name: "EditApiScenario",
|
||||
props: {
|
||||
moduleOptions: Array,
|
||||
currentScenario: {},
|
||||
},
|
||||
components: {
|
||||
MsVariableList,
|
||||
ScenarioRelevance,
|
||||
ScenarioApiRelevance,
|
||||
ApiEnvironmentConfig,
|
||||
export default {
|
||||
name: "EditApiScenario",
|
||||
props: {
|
||||
moduleOptions: Array,
|
||||
currentScenario: {},
|
||||
},
|
||||
components: {
|
||||
ApiScenarioEnv,
|
||||
MsVariableList,
|
||||
ScenarioRelevance,
|
||||
ScenarioApiRelevance,
|
||||
ApiEnvironmentConfig,
|
||||
MsApiReportDetail,
|
||||
MsInputTag, MsRun,
|
||||
MsApiCustomize,
|
||||
|
@ -291,7 +298,9 @@
|
|||
globalOptions: {
|
||||
spacing: 30
|
||||
},
|
||||
response: {}
|
||||
response: {},
|
||||
projectIds: new Set,
|
||||
projectEnvMap: new Map
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -304,7 +313,13 @@
|
|||
this.getApiScenario();
|
||||
this.addListener(); // 添加 ctrl s 监听
|
||||
},
|
||||
directives: {OutsideClick},
|
||||
mounted() {
|
||||
getProject.$on('addProjectEnv', (projectId, projectEnv) => {
|
||||
this.projectIds.add(projectId);
|
||||
// this.projectEnvMap.set(projectId, projectEnv);
|
||||
})
|
||||
},
|
||||
directives: {OutsideClick},
|
||||
computed: {
|
||||
buttons() {
|
||||
let buttons = [
|
||||
|
@ -606,6 +621,7 @@
|
|||
request.enable === undefined ? request.enable = true : request.enable;
|
||||
request.active = false;
|
||||
request.resourceId = getUUID();
|
||||
request.projectId = item.projectId;
|
||||
if (!request.url) {
|
||||
request.url = "";
|
||||
}
|
||||
|
@ -647,6 +663,12 @@
|
|||
const parent = node.parent
|
||||
const hashTree = parent.data.hashTree || parent.data;
|
||||
const index = hashTree.findIndex(d => d.resourceId != undefined && row.resourceId != undefined && d.resourceId === row.resourceId)
|
||||
if (hashTree[index] && hashTree[index].projectId) {
|
||||
this.projectIds.delete(hashTree[index].projectId);
|
||||
if (this.projectEnvMap.has(hashTree[index].projectId)) {
|
||||
this.projectEnvMap.delete(hashTree[index].projectId);
|
||||
}
|
||||
}
|
||||
hashTree.splice(index, 1);
|
||||
this.sort();
|
||||
this.reload();
|
||||
|
@ -681,8 +703,12 @@
|
|||
},
|
||||
runDebug() {
|
||||
/*触发执行操作*/
|
||||
if (!this.currentEnvironmentId) {
|
||||
this.$error(this.$t('api_test.environment.select_environment'));
|
||||
// if (!this.currentEnvironmentId) {
|
||||
// this.$error(this.$t('api_test.environment.select_environment'));
|
||||
// return;
|
||||
// }
|
||||
let sign = this.$refs.apiScenarioEnv.checkEnv();
|
||||
if (!sign) {
|
||||
return;
|
||||
}
|
||||
this.$refs['currentScenario'].validate((valid) => {
|
||||
|
@ -696,7 +722,7 @@
|
|||
referenced: 'Created',
|
||||
enableCookieShare: this.enableCookieShare,
|
||||
headers: this.currentScenario.headers,
|
||||
environmentId: this.currentEnvironmentId,
|
||||
environmentMap: this.projectEnvMap,
|
||||
hashTree: this.scenarioDefinition
|
||||
};
|
||||
this.reportId = getUUID().substring(0, 8);
|
||||
|
@ -873,6 +899,14 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
objToStrMap(obj) {
|
||||
let strMap = new Map();
|
||||
for (let k of Object.keys(obj)) {
|
||||
strMap.set(k, obj[k]);
|
||||
}
|
||||
return strMap;
|
||||
},
|
||||
|
||||
getApiScenario() {
|
||||
if (this.currentScenario.tags != undefined && !(this.currentScenario.tags instanceof Array)) {
|
||||
this.currentScenario.tags = JSON.parse(this.currentScenario.tags);
|
||||
|
@ -891,6 +925,12 @@
|
|||
let obj = JSON.parse(response.data.scenarioDefinition);
|
||||
if (obj) {
|
||||
this.currentEnvironmentId = obj.environmentId;
|
||||
if (obj.environmentMap) {
|
||||
this.projectEnvMap = this.objToStrMap(obj.environmentMap);
|
||||
} else {
|
||||
// 兼容历史数据
|
||||
this.projectEnvMap.set(getCurrentProjectID(), obj.environmentId);
|
||||
}
|
||||
this.currentScenario.variables = [];
|
||||
let index = 1;
|
||||
if (obj.variables) {
|
||||
|
@ -922,6 +962,13 @@
|
|||
})
|
||||
}
|
||||
},
|
||||
strMapToObj(strMap){
|
||||
let obj= Object.create(null);
|
||||
for (let[k,v] of strMap) {
|
||||
obj[k] = v;
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
setParameter() {
|
||||
this.currentScenario.stepTotal = this.scenarioDefinition.length;
|
||||
this.currentScenario.projectId = getCurrentProjectID();
|
||||
|
@ -935,8 +982,9 @@
|
|||
variables: this.currentScenario.variables,
|
||||
headers: this.currentScenario.headers,
|
||||
referenced: 'Created',
|
||||
environmentId: this.currentEnvironmentId,
|
||||
hashTree: this.scenarioDefinition
|
||||
environmentMap: this.strMapToObj(this.projectEnvMap),
|
||||
hashTree: this.scenarioDefinition,
|
||||
projectId: this.projectId,
|
||||
};
|
||||
this.currentScenario.scenarioDefinition = scenario;
|
||||
if (this.currentScenario.tags instanceof Array) {
|
||||
|
@ -974,6 +1022,15 @@
|
|||
size += this.currentScenario.headers.length - 1;
|
||||
}
|
||||
return size;
|
||||
},
|
||||
beforeDestroy() {
|
||||
getProject.$off('addProjectEnv');
|
||||
},
|
||||
handleEnv() {
|
||||
this.$refs.apiScenarioEnv.open();
|
||||
},
|
||||
setProjectEnvMap(projectEnvMap) {
|
||||
this.projectEnvMap = projectEnvMap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<template>
|
||||
<relevance-dialog :title="$t('api_test.automation.scenario_import')" ref="relevanceDialog">
|
||||
|
||||
<test-case-relevance-base
|
||||
@setProject="setProject"
|
||||
ref="baseRelevance">
|
||||
<template v-slot:aside>
|
||||
<ms-api-scenario-module
|
||||
@nodeSelectEvent="nodeChange"
|
||||
|
@ -22,8 +23,7 @@
|
|||
<el-button type="primary" @click="copy" @keydown.enter.native.prevent>{{$t('commons.copy')}}</el-button>
|
||||
<el-button type="primary" @click="reference" @keydown.enter.native.prevent> {{ $t('api_test.scenario.reference') }}</el-button>
|
||||
</template>
|
||||
|
||||
</relevance-dialog>
|
||||
</test-case-relevance-base>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -37,10 +37,12 @@
|
|||
import MsApiScenarioList from "../ApiScenarioList";
|
||||
import {getUUID} from "../../../../../../common/js/utils";
|
||||
import RelevanceDialog from "../../../../track/plan/view/comonents/base/RelevanceDialog";
|
||||
import TestCaseRelevanceBase from "@/business/components/track/plan/view/comonents/base/TestCaseRelevanceBase";
|
||||
|
||||
export default {
|
||||
name: "ScenarioRelevance",
|
||||
components: {
|
||||
TestCaseRelevanceBase,
|
||||
RelevanceDialog,
|
||||
MsApiScenarioList,
|
||||
MsApiScenarioModule,
|
||||
|
@ -55,6 +57,12 @@
|
|||
isApiListEnable: true,
|
||||
currentScenario: [],
|
||||
currentScenarioIds: [],
|
||||
projectId: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
projectId() {
|
||||
this.$refs.apiScenarioList.search(this.projectId);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -65,11 +73,11 @@
|
|||
return;
|
||||
}
|
||||
this.currentScenario.forEach(item => {
|
||||
let obj = {id: item.id, name: item.name, type: "scenario", referenced: 'REF', resourceId: getUUID()};
|
||||
let obj = {id: item.id, name: item.name, type: "scenario", referenced: 'REF', resourceId: getUUID(), projectId: item.projectId};
|
||||
scenarios.push(obj);
|
||||
});
|
||||
this.$emit('save', scenarios);
|
||||
this.close();
|
||||
this.$refs.baseRelevance.close();
|
||||
},
|
||||
copy() {
|
||||
let scenarios = [];
|
||||
|
@ -82,12 +90,12 @@
|
|||
response.data.forEach(item => {
|
||||
let scenarioDefinition = JSON.parse(item.scenarioDefinition);
|
||||
if (scenarioDefinition && scenarioDefinition.hashTree) {
|
||||
let obj = {id: item.id, name: item.name, type: "scenario", referenced: 'Copy', resourceId: getUUID(), hashTree: scenarioDefinition.hashTree};
|
||||
let obj = {id: item.id, name: item.name, type: "scenario", referenced: 'Copy', resourceId: getUUID(), hashTree: scenarioDefinition.hashTree, projectId: item.projectId};
|
||||
scenarios.push(obj);
|
||||
}
|
||||
});
|
||||
this.$emit('save', scenarios);
|
||||
this.close();
|
||||
this.$refs.baseRelevance.close();
|
||||
}
|
||||
})
|
||||
},
|
||||
|
@ -96,9 +104,9 @@
|
|||
this.$refs.relevanceDialog.close();
|
||||
},
|
||||
open() {
|
||||
this.$refs.relevanceDialog.open();
|
||||
this.$refs.baseRelevance.open();
|
||||
if (this.$refs.apiScenarioList) {
|
||||
this.$refs.apiScenarioList.search();
|
||||
this.$refs.apiScenarioList.search(this.projectId);
|
||||
}
|
||||
},
|
||||
nodeChange(node, nodeIds, pNodes) {
|
||||
|
@ -117,6 +125,9 @@
|
|||
this.currentScenario = Array.from(data).map(row => row);
|
||||
this.currentScenarioIds = Array.from(data).map(row => row.id);
|
||||
},
|
||||
setProject(projectId) {
|
||||
this.projectId = projectId;
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
|
||||
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
|
||||
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
|
||||
<span style="margin-left: 20px;">{{getProjectName(request.projectId)}}</span>
|
||||
<ms-run :debug="true" :reportId="reportId" :run-data="runData"
|
||||
@runRefresh="runRefresh" ref="runTest"/>
|
||||
|
||||
|
@ -70,6 +71,7 @@ import {getUUID} from "@/common/js/utils";
|
|||
import ApiBaseComponent from "../common/ApiBaseComponent";
|
||||
import ApiResponseComponent from "./ApiResponseComponent";
|
||||
import CustomizeReqInfo from "@/business/components/api/automation/scenario/common/CustomizeReqInfo";
|
||||
import {getProject} from "@/business/components/api/automation/scenario/event";
|
||||
|
||||
export default {
|
||||
name: "MsApiComponent",
|
||||
|
@ -94,6 +96,7 @@ export default {
|
|||
reportId: "",
|
||||
runData: [],
|
||||
isShowInput: false,
|
||||
projects: []
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -102,6 +105,7 @@ export default {
|
|||
}
|
||||
// 加载引用对象数据
|
||||
this.getApiInfo();
|
||||
this.getWsProjects();
|
||||
if (this.request.protocol === 'HTTP') {
|
||||
this.setUrl(this.request.url);
|
||||
this.setUrl(this.request.path);
|
||||
|
@ -115,6 +119,7 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
getProject.$emit('addProjectEnv', this.request.projectId, this.currentEnvironmentId);
|
||||
},
|
||||
computed: {
|
||||
displayColor() {
|
||||
|
@ -270,6 +275,18 @@ export default {
|
|||
this.loading = false
|
||||
})
|
||||
},
|
||||
getWsProjects() {
|
||||
this.$get("/project/listAll", res => {
|
||||
this.projects = res.data;
|
||||
})
|
||||
},
|
||||
getProjectName(id) {
|
||||
const project = this.projects.find(p => p.id === id);
|
||||
if (project) {
|
||||
return project.name;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
|
||||
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
|
||||
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
|
||||
|
||||
<span style="margin-left: 20px;">{{getProjectName(scenario.projectId)}}</span>
|
||||
</template>
|
||||
|
||||
</api-base-component>
|
||||
|
@ -27,6 +29,7 @@
|
|||
import MsDubboBasisParameters from "../../../definition/components/request/dubbo/BasisParameters";
|
||||
import MsApiRequestForm from "../../../definition/components/request/http/ApiHttpRequestForm";
|
||||
import ApiBaseComponent from "../common/ApiBaseComponent";
|
||||
import {getProject} from "@/business/components/api/automation/scenario/event";
|
||||
|
||||
export default {
|
||||
name: "ApiScenarioComponent",
|
||||
|
@ -37,9 +40,12 @@
|
|||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
currentEnvironmentId: String,
|
||||
},
|
||||
watch: {},
|
||||
created() {
|
||||
this.getWsProjects();
|
||||
getProject.$emit('addProjectEnv', this.scenario.projectId, this.currentEnvironmentId);
|
||||
if (this.scenario.id && this.scenario.referenced === 'REF' && !this.scenario.loaded) {
|
||||
this.result = this.$get("/api/automation/getApiScenario/" + this.scenario.id, response => {
|
||||
if (response.data) {
|
||||
|
@ -63,7 +69,8 @@
|
|||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
isShowInput: false
|
||||
isShowInput: false,
|
||||
projects: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -109,6 +116,18 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
getWsProjects() {
|
||||
this.$get("/project/listAll", res => {
|
||||
this.projects = res.data;
|
||||
})
|
||||
},
|
||||
getProjectName(id) {
|
||||
const project = this.projects.find(p => p.id === id);
|
||||
if (project) {
|
||||
return project.name;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
import Vue from 'vue';
|
||||
export const getProject = new Vue();
|
|
@ -1,8 +1,8 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-container>
|
||||
<el-main style="padding-top: 0px">
|
||||
<el-row>
|
||||
<el-main style="padding-top: 0px;padding-bottom: 0px">
|
||||
<el-row style="margin-top: 10px">
|
||||
<el-select size="small" :placeholder="$t('api_test.definition.document.order')" v-model="apiSearch.orderCondition" style="float: right;width: 180px;margin-right: 5px"
|
||||
class="ms-api-header-select" @change="initApiDocSimpleList" clearable>
|
||||
<el-option key="createTimeDesc" :label="$t('api_test.definition.document.create_time_sort')" value="createTimeDesc" />
|
||||
|
@ -24,12 +24,25 @@
|
|||
</el-select>
|
||||
<el-input :placeholder="$t('api_test.definition.document.search_by_api_name')" @blur="initApiDocSimpleList()" style="float: right;width: 180px;margin-right: 5px" size="small"
|
||||
@keyup.enter.native="initApiDocSimpleList()" v-model="apiSearch.name"/>
|
||||
<api-document-batch-share v-xpack @shareApiDocument="shareApiDocument" :project-id="projectId" :share-url="batchShareUrl" style="float: right;margin: 6px;font-size: 17px"/>
|
||||
</el-row>
|
||||
<el-divider></el-divider>
|
||||
<div ref="apiDocInfoDiv">
|
||||
<div style="margin-bottom: 50px">
|
||||
<div ref="apiDocInfoDiv" @scroll="handleScroll" >
|
||||
<div v-for="(apiInfo) in apiInfoArray" :key="apiInfo.id" ref="apiDocInfoDivItem">
|
||||
<div style="font-size: 17px">
|
||||
<i class="el-icon-share"></i>{{ apiInfo.name }}
|
||||
<el-popover
|
||||
v-if="projectId"
|
||||
placement="right"
|
||||
width="260"
|
||||
@show="shareApiDocument('false')">
|
||||
<p>{{shareUrl}}</p>
|
||||
<div style="text-align: right; margin: 0">
|
||||
<el-button type="primary" size="mini"
|
||||
v-clipboard:copy="shareUrl">{{ $t("commons.copy") }}</el-button>
|
||||
</div>
|
||||
<i class="el-icon-share" slot="reference" style="margin-right: 10px;cursor: pointer"></i>
|
||||
</el-popover>
|
||||
{{ apiInfo.name }}
|
||||
<span class="apiStatusTag">
|
||||
<api-status :value="apiInfo.status"/>
|
||||
</span>
|
||||
|
@ -54,7 +67,9 @@
|
|||
<div class="blackFontClass">
|
||||
{{ $t('api_test.definition.document.request_head') }}:
|
||||
<div v-if="getJsonArr(apiInfo.requestHead).length==0">
|
||||
{{ $t('api_test.definition.document.data_set.none') }}
|
||||
<div class="simpleFontClass" style="margin-top: 10px">
|
||||
{{ $t('api_test.definition.document.data_set.none') }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-table border :show-header="false"
|
||||
|
@ -74,7 +89,9 @@
|
|||
<div class="blackFontClass">
|
||||
URL{{ $t('api_test.definition.document.request_param') }}:
|
||||
<div v-if="getJsonArr(apiInfo.urlParams).length==0">
|
||||
{{ $t('api_test.definition.document.data_set.none') }}
|
||||
<div class="simpleFontClass" style="margin-top: 10px">
|
||||
{{ $t('api_test.definition.document.data_set.none') }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-table border
|
||||
|
@ -133,7 +150,7 @@
|
|||
min-width="120px"
|
||||
show-overflow-tooltip/>
|
||||
</el-table>
|
||||
<div v-else-if="apiInfo.requestBodyParamType == 'JSON-SCHEMA'">
|
||||
<div v-else-if="apiInfo.requestBodyParamType == 'JSON-SCHEMA'" style="margin-left: 10px">
|
||||
<ms-json-code-edit :body="apiInfo.jsonSchemaBody" ref="jsonCodeEdit"/>
|
||||
</div>
|
||||
<div v-else class="showDataDiv">
|
||||
|
@ -247,7 +264,7 @@
|
|||
<el-aside width="200px" style="margin-top: 70px;">
|
||||
<div ref="apiDocList" >
|
||||
<el-steps style="height: 40%" direction="vertical" :active="apiStepIndex">
|
||||
<el-step v-for="(apiInfo) in apiSimpleInfoArray" :key="apiInfo.id" @click.native="clickStep(apiInfo.id)">
|
||||
<el-step v-for="(apiInfo) in apiInfoArray" :key="apiInfo.id" @click.native="clickStep(apiInfo.id)">
|
||||
<el-link slot="title">{{ apiInfo.name }}</el-link>
|
||||
</el-step>
|
||||
</el-steps>
|
||||
|
@ -265,18 +282,25 @@ import {formatJson,} from "@/common/js/format-utils";
|
|||
import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus";
|
||||
import {calculate} from "@/business/components/api/definition/model/ApiTestModel";
|
||||
import MsJsonCodeEdit from "@/business/components/common/json-schema/JsonSchemaEditor";
|
||||
import Api from "@/business/components/api/router";
|
||||
|
||||
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
|
||||
const apiDocumentBatchShare = requireComponent.keys().length > 0 ? requireComponent("./share/ApiDocumentBatchShare.vue") : {};
|
||||
|
||||
export default {
|
||||
name: "ApiDocumentItem",
|
||||
components: {
|
||||
Api,
|
||||
MsJsonCodeEdit,
|
||||
MsAnchor, ApiStatus, MsCodeEdit,
|
||||
"ApiDocumentBatchShare": apiDocumentBatchShare.default
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
shareUrl:"",
|
||||
batchShareUrl:"",
|
||||
apiStepIndex: 0,
|
||||
apiSimpleInfoArray: [],
|
||||
apiInfoArray: [],
|
||||
modes: ['text', 'json', 'xml', 'html'],
|
||||
formParamTypes: ['form-data', 'x-www-from-urlencoded', 'BINARY'],
|
||||
mockVariableFuncs: [],
|
||||
|
@ -285,7 +309,8 @@ export default {
|
|||
type:"ALL",
|
||||
orderCondition:"createTimeDesc",
|
||||
},
|
||||
apiInfo: {
|
||||
apiInfoBaseObj: {
|
||||
selectedFlag:false,
|
||||
method: "无",
|
||||
uri: "无",
|
||||
name: "无",
|
||||
|
@ -295,6 +320,7 @@ export default {
|
|||
requestBodyParamType: "无",
|
||||
requestBodyFormData: '[]',
|
||||
requestBodyStrutureData: "",
|
||||
sharePopoverVisible:false,
|
||||
jsonSchemaBody: {},
|
||||
responseHead: "无",
|
||||
responseBody: "",
|
||||
|
@ -309,7 +335,9 @@ export default {
|
|||
},
|
||||
props: {
|
||||
projectId: String,
|
||||
documentId: String,
|
||||
moduleIds: Array,
|
||||
pageHeaderHeight:Number,
|
||||
},
|
||||
activated() {
|
||||
this.initApiDocSimpleList();
|
||||
|
@ -327,27 +355,21 @@ export default {
|
|||
window.onresize = function () {
|
||||
this.clientHeight = `${document.documentElement.clientHeight}`;
|
||||
this.changeFixed(this.clientHeight);
|
||||
}
|
||||
};
|
||||
window.addEventListener('scroll',that.handleScroll);
|
||||
},
|
||||
mounted() {
|
||||
let that = this;
|
||||
window.onresize = function () {
|
||||
this.clientHeight = `${document.documentElement.clientHeight}`;
|
||||
if (that.$refs.apiDocInfoDiv) {
|
||||
that.$refs.apiDocInfoDiv.style.minHeight = this.clientHeight - 300 + 'px';
|
||||
that.$refs.apiDocList.style.minHeight = this.clientHeight - 300 + 'px';
|
||||
|
||||
}
|
||||
}
|
||||
that.clientHeight = `${document.documentElement.clientHeight}`;
|
||||
that.changeFixed(that.clientHeight);
|
||||
};
|
||||
// 监听滚动事件,然后用handleScroll这个方法进行相应的处理
|
||||
window.addEventListener('scroll',this.handleScroll);
|
||||
},
|
||||
computed: {
|
||||
documentId: function () {
|
||||
return this.$route.params.documentId;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$route.params.documentId'() {
|
||||
},
|
||||
moduleIds() {
|
||||
this.initApiDocSimpleList();
|
||||
},
|
||||
|
@ -365,10 +387,14 @@ export default {
|
|||
},
|
||||
changeFixed(clientHeight) {
|
||||
if (this.$refs.apiDocInfoDiv) {
|
||||
this.$refs.apiDocInfoDiv.style.height = clientHeight - 350 + 'px';
|
||||
this.$refs.apiDocInfoDiv.style.overflow = 'auto';
|
||||
this.$refs.apiDocList.style.height = clientHeight - 350 + 'px';
|
||||
let countPageHeight = 350;
|
||||
if(this.pageHeaderHeight!=0 && this.pageHeaderHeight != null){
|
||||
countPageHeight = this.pageHeaderHeight
|
||||
}
|
||||
|
||||
this.$refs.apiDocInfoDiv.style.height = clientHeight - countPageHeight + 'px';
|
||||
this.$refs.apiDocInfoDiv.style.overflow = 'auto';
|
||||
this.$refs.apiDocList.style.height = clientHeight - countPageHeight + 'px';
|
||||
}
|
||||
},
|
||||
initApiDocSimpleList() {
|
||||
|
@ -377,36 +403,71 @@ export default {
|
|||
simpleRequest.projectId = this.projectId;
|
||||
}
|
||||
if (this.documentId != null && this.documentId != "") {
|
||||
simpleRequest.documentId = this.documentId;
|
||||
simpleRequest.shareId = this.documentId;
|
||||
}
|
||||
if (this.moduleIds.length > 0) {
|
||||
simpleRequest.moduleIds = this.moduleIds;
|
||||
}
|
||||
|
||||
let simpleInfoUrl = "/api/document/selectApiSimpleInfo";
|
||||
this.apiSimpleInfoArray = [];
|
||||
this.apiInfoArray = [];
|
||||
this.$post(simpleInfoUrl, simpleRequest, response => {
|
||||
this.apiSimpleInfoArray = response.data;
|
||||
this.apiInfoArray = response.data;
|
||||
this.apiStepIndex = 0;
|
||||
if (this.apiSimpleInfoArray.length > 0) {
|
||||
this.selectApiInfo(this.apiSimpleInfoArray[0].id);
|
||||
if (this.apiInfoArray.length > 0) {
|
||||
this.checkApiInfoNode(this.apiStepIndex);
|
||||
}
|
||||
});
|
||||
},
|
||||
selectApiInfo(apiId) {
|
||||
shareApiDocument(isBatchShare){
|
||||
let thisHost = window.location.host;
|
||||
this.shareUrl = "";
|
||||
this.batchShareUrl = "";
|
||||
let shareIdArr = [];
|
||||
let shareType = "Single";
|
||||
if(isBatchShare == 'true'){
|
||||
this.apiInfoArray.forEach(f => {
|
||||
if (!f.id) {
|
||||
return;
|
||||
}
|
||||
shareIdArr.push(f.id);
|
||||
});
|
||||
shareType = "Batch";
|
||||
}else{
|
||||
shareIdArr.push(this.apiInfoArray[this.apiStepIndex].id);
|
||||
}
|
||||
let genShareInfoParam = {};
|
||||
genShareInfoParam.shareApiIdList = shareIdArr;
|
||||
genShareInfoParam.shareType = shareType;
|
||||
|
||||
this.$post("/api/document/generateApiDocumentShareInfo", genShareInfoParam, res => {
|
||||
if(shareType == "Batch"){
|
||||
this.batchShareUrl = "http://"+thisHost+"/document"+res.data.shareUrl;
|
||||
}else{
|
||||
this.shareUrl = "http://"+thisHost+"/document"+res.data.shareUrl;
|
||||
}
|
||||
}, (error) => {
|
||||
});
|
||||
},
|
||||
selectApiInfo(index,apiId) {
|
||||
let simpleInfoUrl = "/api/document/selectApiInfoById/" + apiId;
|
||||
this.$get(simpleInfoUrl, response => {
|
||||
this.apiInfo = response.data;
|
||||
//this.apiInfoObj = response.data;
|
||||
//this.apiInfoArray.push(response.data);
|
||||
this.$set(this.apiInfoArray,index,response.data);
|
||||
});
|
||||
},
|
||||
clickStep(apiId) {
|
||||
for (let index = 0; index < this.apiSimpleInfoArray.length; index++) {
|
||||
if (apiId == this.apiSimpleInfoArray[index].id) {
|
||||
for (let index = 0; index < this.apiInfoArray.length; index++) {
|
||||
if (apiId == this.apiInfoArray[index].id) {
|
||||
this.apiStepIndex = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.selectApiInfo(apiId);
|
||||
//检查数据
|
||||
this.checkApiInfoNode(this.apiStepIndex);
|
||||
//进行跳转
|
||||
this.redirectScroll(this.apiStepIndex);
|
||||
},
|
||||
stepClick(stepIndex) {
|
||||
this.apiStepIndex = stepIndex;
|
||||
|
@ -422,11 +483,10 @@ export default {
|
|||
ret = "否"
|
||||
}
|
||||
return ret;
|
||||
|
||||
},
|
||||
getJsonArr(jsonString) {
|
||||
let returnJsonArr = [];
|
||||
if (jsonString == '无') {
|
||||
if (jsonString == '无' || jsonString == null) {
|
||||
return returnJsonArr;
|
||||
}
|
||||
|
||||
|
@ -447,8 +507,10 @@ export default {
|
|||
for (var key in previewData) {
|
||||
// showDataObj.set(key,previewData[key]);
|
||||
let value = previewData[key];
|
||||
if (value.indexOf("@") >= 0) {
|
||||
value = this.showPreview(value);
|
||||
if(typeof(value)=='string'){
|
||||
if (value.indexOf("@") >= 0) {
|
||||
value = this.showPreview(value);
|
||||
}
|
||||
}
|
||||
showDataObj[key] = value;
|
||||
}
|
||||
|
@ -480,13 +542,89 @@ export default {
|
|||
itemValue = calculate(itemValue);
|
||||
return itemValue;
|
||||
},
|
||||
onCopySuccess: function (e) {
|
||||
if(this.apiStepIndex < this.apiInfoArray.length){
|
||||
this.apiInfoArray[this.apiStepIndex].sharePopoverVisible = false;
|
||||
}
|
||||
this.$message({
|
||||
message: this.$t('commons.copy_success'),
|
||||
type: 'success'
|
||||
});
|
||||
},
|
||||
onCopyError: function (e) {
|
||||
if(this.apiStepIndex < this.apiInfoArray.length){
|
||||
this.apiInfoArray[this.apiStepIndex].sharePopoverVisible = false;
|
||||
}
|
||||
this.$message.error(this.$t('api_report.error'));
|
||||
},
|
||||
handleScroll(){
|
||||
// let itemHeight = 0;
|
||||
// if(this.$refs.apiDocInfoDivItem.length>0){
|
||||
// //子元素高度为 item的高度+20(20是margin距离)
|
||||
// itemHeight = this.$refs.apiDocInfoDivItem[0].offsetHeight+20;
|
||||
// }
|
||||
|
||||
//apiDocInfoDiv的总高度,是(每个item的高度+20)数量
|
||||
let apiDocDivScrollTop = this.$refs.apiDocInfoDiv.scrollTop;
|
||||
let apiDocDivClientTop = this.$refs.apiDocInfoDiv.clientHeight;
|
||||
|
||||
let scrolledHeigh = apiDocDivScrollTop+apiDocDivClientTop;
|
||||
let lastIndex = 0;
|
||||
for (let index = 0; index < this.apiInfoArray.length; index++) {
|
||||
//判断移动到了第几个元素. 公式: 移动过的高度+页面显示高度-第index子元素的高度(含20px)>0 的 index最大值
|
||||
if(scrolledHeigh>0){
|
||||
lastIndex = index;
|
||||
let itemHeight = this.$refs.apiDocInfoDivItem[index].offsetHeight+20;
|
||||
scrolledHeigh = scrolledHeigh - itemHeight;
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.apiStepIndex = lastIndex;
|
||||
//检查上下文 3个以内的节点有没有查询出来
|
||||
this.checkApiInfoNode(this.apiStepIndex);
|
||||
},
|
||||
redirectScroll(itemIndex){
|
||||
//滚动条跳转:将滚动条下拉到显示对应对api接口的位置
|
||||
// let apiDocDivClientTop = this.$refs.apiDocInfoDiv.clientHeight;
|
||||
let apiDocDivClientTop = 0;
|
||||
let itemHeightCount = 0;
|
||||
for (let i = 0; i <= itemIndex-1; i++) {
|
||||
let itemHeight = this.$refs.apiDocInfoDivItem[i].offsetHeight+20;
|
||||
itemHeightCount+=itemHeight;
|
||||
}
|
||||
this.$refs.apiDocInfoDiv.scrollTop = (apiDocDivClientTop+itemHeightCount);
|
||||
},
|
||||
checkApiInfoNode(itemIndex){
|
||||
//检查要展示的api信息节点,和上下个3个及以内的范围内数据有没有查询过
|
||||
let beforeNodeIndex = itemIndex<3?0:(itemIndex-3);
|
||||
let afterNodeIndex = (itemIndex+3)<this.apiInfoArray.length?(itemIndex+3):this.apiInfoArray.length;
|
||||
|
||||
for(let i = itemIndex;i < afterNodeIndex;i++){
|
||||
let apiInfo = this.apiInfoArray[i];
|
||||
if(apiInfo == null || !apiInfo.selectedFlag){
|
||||
let apiId = apiInfo.id;
|
||||
this.selectApiInfo(i,apiId);
|
||||
}
|
||||
}
|
||||
|
||||
for(let i = beforeNodeIndex;i <itemIndex;i++){
|
||||
let apiInfo = this.apiInfoArray[i];
|
||||
if(apiInfo == null || !apiInfo.selectedFlag){
|
||||
let apiId = apiInfo.id;
|
||||
this.selectApiInfo(i,apiId);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.simpleFontClass {
|
||||
font-weight: normal;
|
||||
font-size: 14px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.blackFontClass {
|
||||
|
@ -496,7 +634,7 @@ export default {
|
|||
|
||||
.smallFontClass {
|
||||
font-size: 13px;
|
||||
margin: 20px 0px;
|
||||
margin: 20px 10px;
|
||||
}
|
||||
|
||||
.tip {
|
||||
|
@ -516,7 +654,7 @@ export default {
|
|||
|
||||
.showDataDiv {
|
||||
background-color: #F5F7F9;
|
||||
margin: 20px 0px;
|
||||
margin: 20px 10px;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
<template>
|
||||
<div>
|
||||
<div class="questionList-content-list">
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
export default {
|
||||
name: "TestScroll",
|
||||
components: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
seeThis:0,
|
||||
tabs:['tab0','tab1','tab2'],
|
||||
}
|
||||
},
|
||||
props: {
|
||||
projectId: String,
|
||||
documentId: String,
|
||||
moduleIds: Array,
|
||||
pageHeaderHeight:Number,
|
||||
},
|
||||
activated() {
|
||||
},
|
||||
created () {
|
||||
window.addEventListener('scroll',this.handleScroll)
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
watch: {
|
||||
},
|
||||
methods: {
|
||||
goAnchor(index) { // 也可以用scrollIntoView方法, 但由于这里头部设置了固定定位,所以用了这种方法
|
||||
// document.querySelector('#anchor'+index).scrollIntoView()
|
||||
this.seeThis = index; var anchor = this.$el.querySelector('#anchor'+index)
|
||||
document.body.scrollTop = anchor.offsetTop-100
|
||||
document.documentElement.scrollTop = anchor.offsetTop-100
|
||||
},
|
||||
handleScroll(){
|
||||
let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop // 滚动条偏移量
|
||||
let offsetTop = document.querySelector('#boxFixed').offsetTop; // 要滚动到顶部吸附的元素的偏移量
|
||||
var anchorOffset0 = this.$el.querySelector('#anchor0').offsetTop-100
|
||||
var anchorOffset1 = this.$el.querySelector('#anchor1').offsetTop-100
|
||||
var anchorOffset2 = this.$el.querySelector('#anchor2').offsetTop-100
|
||||
if(scrollTop>anchorOffset0&&scrollTop<anchorOffset1){
|
||||
this.seeThis = 0
|
||||
}
|
||||
if(scrollTop>anchorOffset1&&scrollTop<anchorOffset2){
|
||||
this.seeThis = 1
|
||||
}
|
||||
if(scrollTop>anchorOffset2){
|
||||
this.seeThis = 2
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
|
@ -236,7 +236,7 @@ import CaseBatchMove from "@/business/components/api/definition/components/basis
|
|||
import ApiListContainerWithDoc from "@/business/components/api/definition/components/list/ApiListContainerWithDoc";
|
||||
import {
|
||||
_handleSelect,
|
||||
_handleSelectAll, getLabel,
|
||||
_handleSelectAll, buildBatchParam, getLabel,
|
||||
getSelectDataCounts, initCondition,
|
||||
setUnSelectIds, toggleAllSelection
|
||||
} from "@/common/js/tableUtils";
|
||||
|
@ -555,7 +555,7 @@ export default {
|
|||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
this.$post('/api/definition/deleteBatchByParams/', this.buildBatchParam(), () => {
|
||||
this.$post('/api/definition/deleteBatchByParams/', buildBatchParam(this), () => {
|
||||
this.selectRows.clear();
|
||||
this.initTable();
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
|
@ -568,7 +568,7 @@ export default {
|
|||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
this.$post('/api/definition/removeToGcByParams/', this.buildBatchParam(), () => {
|
||||
this.$post('/api/definition/removeToGcByParams/', buildBatchParam(this), () => {
|
||||
this.selectRows.clear();
|
||||
this.initTable();
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
|
@ -592,20 +592,13 @@ export default {
|
|||
this.$refs.batchEdit.open();
|
||||
},
|
||||
batchEdit(form) {
|
||||
let param = this.buildBatchParam();
|
||||
let param = buildBatchParam(this);
|
||||
param[form.type] = form.value;
|
||||
this.$post('/api/definition/batch/editByParams', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.initTable();
|
||||
});
|
||||
},
|
||||
buildBatchParam() {
|
||||
let param = {};
|
||||
param.ids = Array.from(this.selectRows).map(row => row.id);
|
||||
param.projectId = getCurrentProjectID();
|
||||
param.condition = this.condition;
|
||||
return param;
|
||||
},
|
||||
moveSave(param) {
|
||||
let arr = Array.from(this.selectRows);
|
||||
let ids = arr.map(row => row.id);
|
||||
|
@ -686,7 +679,7 @@ export default {
|
|||
return ids;
|
||||
},
|
||||
exportApi() {
|
||||
let param = this.buildBatchParam();
|
||||
let param = buildBatchParam(this);
|
||||
param.protocol = this.currentProtocol;
|
||||
if (param.ids === undefined || param.ids.length < 1) {
|
||||
this.$warning(this.$t("api_test.definition.check_select"));
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
:destroy-on-close="true"
|
||||
v-loading="result.loading"
|
||||
>
|
||||
<el-form :model="form" label-position="right" label-width="120px" size="small" :rules="rule"
|
||||
<el-form :model="form" label-position="right" label-width="140px" size="small" :rules="rule"
|
||||
ref="testResourcePoolForm">
|
||||
<el-form-item :label="$t('commons.name')" prop="name">
|
||||
<el-input v-model="form.name" autocomplete="off"/>
|
||||
|
@ -62,7 +62,13 @@
|
|||
<el-input v-model="form.description" autocomplete="off"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.image')" prop="image">
|
||||
<el-input v-model="form.image" autocomplete="off"/>
|
||||
<el-input v-model="form.image"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="Jmeter HEAP" prop="HEAP">
|
||||
<el-input v-model="form.heap" placeholder="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="Jmeter GC_ALGO" prop="GC_ALGO">
|
||||
<el-input v-model="form.gcAlgo" placeholder="-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('test_resource_pool.type')" prop="type">
|
||||
<el-select v-model="form.type" :placeholder="$t('test_resource_pool.select_pool_type')"
|
||||
|
|
|
@ -178,9 +178,10 @@
|
|||
</el-table-column>
|
||||
<header-custom ref="headerCustom" :initTableData="initTableData" :optionalFields=headerItems
|
||||
:type=type></header-custom>
|
||||
<ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize"
|
||||
:total="total"/>
|
||||
</el-table>
|
||||
|
||||
<ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize"
|
||||
:total="total"/>
|
||||
</el-card>
|
||||
|
||||
<batch-edit ref="batchEdit" @batchEdit="batchEdit"
|
||||
|
@ -209,18 +210,18 @@ import MsTableButton from "../../../common/components/MsTableButton";
|
|||
import {TEST_CASE_CONFIGS} from "../../../common/components/search/search-components";
|
||||
import ShowMoreBtn from "./ShowMoreBtn";
|
||||
import BatchEdit from "./BatchEdit";
|
||||
import {TEST_CASE_LIST, WORKSPACE_ID} from "@/common/js/constants";
|
||||
import {PROJECT_NAME, TEST_CASE_LIST, WORKSPACE_ID} from "@/common/js/constants";
|
||||
import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent";
|
||||
import StatusTableItem from "@/business/components/track/common/tableItems/planview/StatusTableItem";
|
||||
import TestCaseDetail from "./TestCaseDetail";
|
||||
import ReviewStatus from "@/business/components/track/case/components/ReviewStatus";
|
||||
import {getCurrentProjectID, getCurrentUser} from "../../../../../common/js/utils";
|
||||
import {downloadFile, getCurrentProjectID, getCurrentUser} from "../../../../../common/js/utils";
|
||||
import MsTag from "@/business/components/common/components/MsTag";
|
||||
import {
|
||||
_filter,
|
||||
_handleSelect,
|
||||
_handleSelectAll,
|
||||
_sort, getLabel,
|
||||
_sort, buildBatchParam, getLabel,
|
||||
getSelectDataCounts, initCondition,
|
||||
setUnSelectIds,
|
||||
toggleAllSelection
|
||||
|
@ -490,16 +491,21 @@ export default {
|
|||
this.$warning(this.$t('commons.check_project_tip'));
|
||||
return;
|
||||
}
|
||||
let ids = Array.from(this.selectRows).map(row => row.id);
|
||||
|
||||
let config = {
|
||||
url: '/test/case/export/testcase',
|
||||
method: 'post',
|
||||
responseType: 'blob',
|
||||
// data: {ids: [...this.selectIds]}
|
||||
data: {ids: ids, projectId: this.projectId}
|
||||
data: buildBatchParam(this)
|
||||
};
|
||||
|
||||
if (config.data.ids === undefined || config.data.ids.length < 1) {
|
||||
this.$warning(this.$t("test_track.case.check_select"));
|
||||
return;
|
||||
}
|
||||
|
||||
this.result = this.$request(config).then(response => {
|
||||
const filename = this.$t('test_track.case.test_case') + ".xlsx";
|
||||
const filename = "Metersphere_case_" + localStorage.getItem(PROJECT_NAME) + ".xlsx";
|
||||
const blob = new Blob([response.data]);
|
||||
if ("download" in document.createElement("a")) {
|
||||
let aTag = document.createElement('a');
|
||||
|
@ -515,14 +521,7 @@ export default {
|
|||
handleBatch(type) {
|
||||
if (this.selectRows.size < 1) {
|
||||
if (type === 'export') {
|
||||
this.$alert(this.$t('test_track.case.export_all_cases'), '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
this.exportTestCase();
|
||||
}
|
||||
}
|
||||
})
|
||||
this.exportTestCase();
|
||||
return;
|
||||
} else {
|
||||
this.$warning(this.$t('test_track.plan_view.select_manipulate'));
|
||||
|
|
|
@ -14,11 +14,12 @@
|
|||
<slot></slot>
|
||||
|
||||
<template v-slot:footer>
|
||||
<ms-dialog-footer @cancel="close" @confirm="save"/>
|
||||
</template>
|
||||
|
||||
<template v-slot:footer>
|
||||
<ms-dialog-footer @cancel="close" @confirm="save"/>
|
||||
<div v-if="$slots.footer">
|
||||
<slot name="footer"></slot>
|
||||
</div>
|
||||
<div v-else>
|
||||
<ms-dialog-footer @cancel="close" @confirm="save"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
</relevance-dialog>
|
||||
|
@ -75,17 +76,15 @@
|
|||
},
|
||||
|
||||
getProject() {
|
||||
if (this.planId) {
|
||||
this.result = this.$post("/test/plan/project/", {planId: this.planId}, res => {
|
||||
let data = res.data;
|
||||
if (data) {
|
||||
this.projects = data;
|
||||
this.projectId = data[0].id;
|
||||
this.projectName = data[0].name;
|
||||
this.changeProject(data[0]);
|
||||
}
|
||||
})
|
||||
}
|
||||
this.result = this.$get("/project/listAll", res => {
|
||||
let data = res.data;
|
||||
if (data) {
|
||||
this.projects = data;
|
||||
this.projectId = data[0].id;
|
||||
this.projectName = data[0].name;
|
||||
this.changeProject(data[0]);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
changeProject(project) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 4cc8926bad84083f675a262d6766a92bb09a890a
|
||||
Subproject commit 448f6ad1178b1c04df18b386df188974b781a7fd
|
|
@ -21,6 +21,7 @@ import VueFab from 'vue-float-action-button'
|
|||
import {left2RightDrag, bottom2TopDrag, right2LeftDrag} from "../common/js/directive";
|
||||
import JsonSchemaEditor from './components/common/json-schema/schema/index';
|
||||
import JSONPathPicker from 'vue-jsonpath-picker';
|
||||
import VueClipboard from 'vue-clipboard2'
|
||||
|
||||
Vue.use(JsonSchemaEditor);
|
||||
import VuePapaParse from 'vue-papa-parse'
|
||||
|
@ -40,6 +41,7 @@ Vue.use(CKEditor);
|
|||
Vue.use(YanProgress);
|
||||
Vue.use(VueFab);
|
||||
Vue.use(JSONPathPicker);
|
||||
Vue.use(VueClipboard)
|
||||
|
||||
// v-permission
|
||||
Vue.directive('permission', permission);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {getCurrentUser, humpToLine} from "@/common/js/utils";
|
||||
import {getCurrentProjectID, getCurrentUser, humpToLine} from "@/common/js/utils";
|
||||
import {TEST_CASE_LIST} from "@/common/js/constants";
|
||||
|
||||
export function _handleSelectAll(component, selection, tableData, selectRows) {
|
||||
|
@ -119,5 +119,12 @@ export function getLabel(vueObj, type) {
|
|||
}
|
||||
|
||||
|
||||
export function buildBatchParam(vueObj) {
|
||||
let param = {};
|
||||
param.ids = Array.from(vueObj.selectRows).map(row => row.id);
|
||||
param.projectId = getCurrentProjectID();
|
||||
param.condition = vueObj.condition;
|
||||
return param;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<template>
|
||||
<div>
|
||||
<api-document-item :pageHeaderHeight="pageHeaderHeight" :project-id="projectId" :module-ids="moduleIds" :document-id="documentId" ref="apiDocumentItem"/>
|
||||
<!-- <test-scroll></test-scroll>-->
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import ApiDocumentItem from "@/business/components/api/definition/components/document/ApiDocumentItem";
|
||||
import TestScroll from "@/business/components/api/definition/components/document/TestScroll";
|
||||
|
||||
export default {
|
||||
name: "ApiDocumentsPage",
|
||||
components: {
|
||||
TestScroll,
|
||||
ApiDocumentItem,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
documentId:"",
|
||||
projectId:"",
|
||||
pageHeaderHeight:100,
|
||||
moduleIds:[],
|
||||
}
|
||||
},
|
||||
props: {
|
||||
activeDom:String,
|
||||
isApiListEnable: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
created: function () {
|
||||
this.selectDocumentInfo();
|
||||
},
|
||||
watch: {
|
||||
},
|
||||
computed: {
|
||||
|
||||
},
|
||||
methods: {
|
||||
getUrlParam(){
|
||||
let queryParams =this.$route.query;
|
||||
let documentIdParam = queryParams['documentId'];
|
||||
this.documentId = queryParams['documentId'];
|
||||
return documentIdParam;
|
||||
},
|
||||
selectDocumentInfo(){
|
||||
this.getUrlParam();
|
||||
if(this.$refs.apiDocumentItem){
|
||||
this.$refs.apiDocumentItem.initApiDocSimpleList();
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="shortcut icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<title>MeterSphere Api Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="document"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,34 @@
|
|||
import Vue from 'vue';
|
||||
import ElementUI, {Button, Col, Form, FormItem, Input, Row} from 'element-ui';
|
||||
import '../assets/theme/index.css';
|
||||
import '../common/css/menu-header.css';
|
||||
import '../common/css/main.css';
|
||||
|
||||
import Document from "./Document.vue";
|
||||
import Ajax from "@/common/js/ajax";
|
||||
import i18n from "@/i18n/i18n";
|
||||
import router from "@/business/components/common/router/router";
|
||||
import JsonSchemaEditor from "@/business/components/common/json-schema/schema/index";
|
||||
import JSONPathPicker from 'vue-jsonpath-picker';
|
||||
Vue.use(JsonSchemaEditor);
|
||||
import VuePapaParse from 'vue-papa-parse'
|
||||
Vue.use(VuePapaParse)
|
||||
|
||||
Vue.use(ElementUI, {
|
||||
i18n: (key, value) => i18n.t(key, value)
|
||||
});
|
||||
Vue.use(Row);
|
||||
Vue.use(Col);
|
||||
Vue.use(Form);
|
||||
Vue.use(FormItem);
|
||||
Vue.use(Input);
|
||||
Vue.use(Button);
|
||||
Vue.use(Ajax);
|
||||
Vue.use(JSONPathPicker);
|
||||
|
||||
new Vue({
|
||||
el: '#document',
|
||||
router,
|
||||
i18n,
|
||||
render: h => h(Document)
|
||||
});
|
|
@ -1052,6 +1052,7 @@ export default {
|
|||
cancel_relevance_success: "Unlinked successfully",
|
||||
switch_project: "Switch project",
|
||||
case: {
|
||||
check_select: "Please check the case",
|
||||
export_all_cases: 'Are you sure you want to export all use cases?',
|
||||
input_test_case: 'Please enter the associated case name',
|
||||
test_name: 'TestName',
|
||||
|
|
|
@ -1056,6 +1056,7 @@ export default {
|
|||
cancel_relevance_success: "取消关联成功",
|
||||
switch_project: "切换项目",
|
||||
case: {
|
||||
check_select: "请勾选用例",
|
||||
export_all_cases: '确定要导出全部用例吗?',
|
||||
input_test_case: '请输入关联用例名称',
|
||||
test_name: '测试名称',
|
||||
|
|
|
@ -1054,6 +1054,7 @@ export default {
|
|||
cancel_relevance_success: "取消關聯成功",
|
||||
switch_project: "切換項目",
|
||||
case: {
|
||||
check_select: "請勾選用例",
|
||||
export_all_cases: '確定要導出全部用例嗎?',
|
||||
input_test_case: '請輸入關聯用例名稱',
|
||||
test_name: '測試名稱',
|
||||
|
|
|
@ -9,10 +9,12 @@ module.exports = {
|
|||
devServer: {
|
||||
port: 8080,
|
||||
proxy: {
|
||||
['^(?!/login)']: {
|
||||
//1.8需求:增加分享功能,不登陆即可看到文档页面。所以代理设置增加了(?!/document)文档页面的相关信息
|
||||
// ['^((?!/login)']: {
|
||||
['^((?!/login)(?!/document))']: {
|
||||
target: 'http://localhost:8081',
|
||||
ws: true,
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
pages: {
|
||||
|
@ -25,6 +27,11 @@ module.exports = {
|
|||
entry: "src/login/login.js",
|
||||
template: "src/login/login.html",
|
||||
filename: "login.html"
|
||||
},
|
||||
document: {
|
||||
entry: "src/document/document.js",
|
||||
template: "src/document/document.html",
|
||||
filename: "document.html"
|
||||
}
|
||||
},
|
||||
configureWebpack: {
|
||||
|
|
Loading…
Reference in New Issue