feat(接口测试): 接口导入修改加版本置新功能

--story=1010629 --user=郭雨琦
https://www.tapd.cn/55049933/prong/stories/view/1155049933001010629
This commit is contained in:
guoyuqi 2022-12-05 19:05:40 +08:00 committed by 刘瑞斌
parent de8d6ff963
commit 00cb5c7343
26 changed files with 2099 additions and 1700 deletions

View File

@ -18,6 +18,13 @@ public class ApiDefinitionImportParamDTO {
private List<ApiDefinitionWithBLOBs> updateList;
private List<ApiTestCaseWithBLOBs> caseList;
private List<ApiDefinitionWithBLOBs> repeatList;
public ApiDefinitionImportParamDTO() {
}
@ -28,4 +35,6 @@ public class ApiDefinitionImportParamDTO {
this.updateList = updateList;
this.caseList = caseList;
}
}

View File

@ -7,12 +7,15 @@ import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
@Getter
@Setter
public class UpdateApiModuleDTO {
private List<ApiModule> moduleList;
private List<ApiDefinitionWithBLOBs> needUpdateList;
private Boolean fullCoverage;
private ApiModuleDTO chooseModule;
private Map<String, String> idPathMap;
private Map<String, ApiModule> moduleMap;
private List<ApiDefinitionWithBLOBs> definitionWithBLOBs;
private List<ApiTestCaseWithBLOBs> caseWithBLOBs;

View File

@ -19,6 +19,7 @@ import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.JSONUtil;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.service.BaseCheckPermissionService;
import io.metersphere.service.definition.ApiDefinitionImportUtilService;
import io.metersphere.service.definition.ApiDefinitionService;
import io.metersphere.service.definition.ApiTestCaseService;
import io.metersphere.service.scenario.ApiScenarioModuleService;
@ -231,6 +232,7 @@ public class ApiScenarioImportUtil {
} else {
test.setPath(object.optString("path"));
}
ApiDefinitionImportUtilService apiDefinitionImportUtilService = CommonBeanFactory.getBean(ApiDefinitionImportUtilService.class);
test.setCreateUser(SessionUtils.getUserId());
test.setProjectId(projectId);
test.setCreateTime(System.currentTimeMillis());
@ -259,7 +261,7 @@ public class ApiScenarioImportUtil {
test.setResponse(httpResponse.toString());
test.setUserId(SessionUtils.getUserId());
test.setLatest(true);
test.setOrder(apiDefinitionService.getImportNextOrder(projectId));
test.setOrder(apiDefinitionImportUtilService.getImportNextOrder(projectId));
if (test.getName().length() > 255) {
test.setName(test.getName().substring(0, 255));
}
@ -294,6 +296,7 @@ public class ApiScenarioImportUtil {
} else {
apiTestCase.setNum(apiDefinition.getNum() * 1000 + caseNameSet.size() + 1);
}
ApiDefinitionImportUtilService apiDefinitionImportUtilService = CommonBeanFactory.getBean(ApiDefinitionImportUtilService.class);
object.put("id", apiTestCase.getId());
object.put("resourceId", apiTestCase.getId());
object.put("projectId", projectId);
@ -303,7 +306,7 @@ public class ApiScenarioImportUtil {
objectNew.remove("refType");
objectNew.remove("referenced");
apiTestCase.setRequest(objectNew.toString());
apiTestCase.setOrder(apiDefinitionService.getImportNextCaseOrder(projectId));
apiTestCase.setOrder(apiDefinitionImportUtilService.getImportNextCaseOrder(projectId));
if (apiTestCase.getName().length() > 255) {
apiTestCase.setName(apiTestCase.getName().substring(0, 255));
}
@ -331,5 +334,4 @@ public class ApiScenarioImportUtil {
}
}
}
}

View File

@ -62,6 +62,7 @@ public class ApiDefinitionController {
@Resource
private ApiExecuteService apiExecuteService;
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions("PROJECT_API_DEFINITION:READ")
public Pager<List<ApiDefinitionResult>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) {

View File

@ -0,0 +1,424 @@
package io.metersphere.service.definition;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.metersphere.api.dto.definition.ApiDefinitionResult;
import io.metersphere.api.parse.api.ApiDefinitionImport;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ApiModuleMapper;
import io.metersphere.base.mapper.ApiTestCaseMapper;
import io.metersphere.base.mapper.EsbApiParamsMapper;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.PropertyConstant;
import io.metersphere.commons.enums.ApiTestDataStatus;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.i18n.Translator;
import io.metersphere.notice.sender.NoticeModel;
import io.metersphere.notice.service.NoticeSendService;
import io.metersphere.request.ApiSyncCaseRequest;
import io.metersphere.xpack.api.service.ApiDefinitionSyncService;
import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.SqlSession;
import java.util.*;
import java.util.stream.Collectors;
public class ApiDefinitionImportUtil {
public static final String HEADERS = "headers";
public static final String ARGUMENTS = "arguments";
public static final String REST = "rest";
public static final String BODY = "body";
public static final String JSONSCHEMA = "jsonSchema";
public static final String PROPERTIES = "properties";
public static Boolean checkIsSynchronize(ApiDefinitionWithBLOBs existApi, ApiDefinitionWithBLOBs apiDefinition) {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
ApiSyncCaseRequest apiSyncCaseRequest = null;
Boolean toUpdate = false;
ApiDefinitionSyncService apiDefinitionSyncService = CommonBeanFactory.getBean(ApiDefinitionSyncService.class);
if (apiDefinitionSyncService != null) {
toUpdate = apiDefinitionSyncService.getProjectApplications(existApi.getProjectId());
apiSyncCaseRequest = apiDefinitionSyncService.getApiSyncCaseRequest(existApi.getProjectId());
}
//Compare the basic information of the API. If it contains the comparison that needs to be done for the synchronization information,
// put the data into the to-be-synchronized
if (apiSyncCaseRequest == null) {
return false;
}
Boolean diffBasicInfo = delBasicInfo(existApi, apiDefinition, apiSyncCaseRequest, toUpdate);
if (diffBasicInfo != null) return diffBasicInfo;
Boolean diffApiRequest = delRequest(existApi, apiDefinition, objectMapper, apiSyncCaseRequest, toUpdate);
if (diffApiRequest != null) return diffApiRequest;
Boolean diffResponse = delResponse(existApi, apiDefinition, objectMapper);
if (diffResponse != null) return diffResponse;
return false;
}
/**
* 比较导入的与系统中重复的两个api的基础信息
*
* @param existApi
* @param apiDefinition
* @param apiSyncCaseRequest
* @param toUpdate
* @return
*/
private static Boolean delBasicInfo(ApiDefinitionWithBLOBs existApi, ApiDefinitionWithBLOBs apiDefinition, ApiSyncCaseRequest apiSyncCaseRequest, Boolean toUpdate) {
if (!StringUtils.equals(apiDefinition.getMethod(), existApi.getMethod())) {
if (apiSyncCaseRequest.getMethod() && toUpdate) {
apiDefinition.setToBeUpdateTime(System.currentTimeMillis());
}
return true;
}
if (!StringUtils.equals(apiDefinition.getProtocol(), existApi.getProtocol())) {
if (apiSyncCaseRequest.getProtocol() && toUpdate) {
apiDefinition.setToBeUpdateTime(System.currentTimeMillis());
}
return true;
}
if (!StringUtils.equals(apiDefinition.getPath(), existApi.getPath())) {
if (apiSyncCaseRequest.getPath() && toUpdate) {
apiDefinition.setToBeUpdateTime(System.currentTimeMillis());
}
return true;
}
if (!StringUtils.equals(apiDefinition.getCreateUser(), existApi.getCreateUser())) {
return true;
}
if (!StringUtils.equals(apiDefinition.getStatus(), existApi.getStatus()) && StringUtils.isNotBlank(existApi.getStatus()) && StringUtils.isNotBlank(apiDefinition.getStatus())) {
return true;
}
if (!StringUtils.equals(apiDefinition.getTags(), existApi.getTags())) {
if (apiDefinition.getTags() != null && Objects.equals(apiDefinition.getTags(), StringUtils.EMPTY) && existApi.getTags() != null && Objects.equals(existApi.getTags(), StringUtils.EMPTY)) {
return true;
}
}
if (!StringUtils.equals(existApi.getRemark(), apiDefinition.getRemark()) && StringUtils.isNotBlank(existApi.getRemark()) && StringUtils.isNotBlank(apiDefinition.getRemark())) {
return true;
}
if (!StringUtils.equals(existApi.getDescription(), apiDefinition.getDescription()) && StringUtils.isNotBlank(existApi.getDescription()) && StringUtils.isNotBlank(apiDefinition.getDescription())) {
return true;
}
return null;
}
/**
* 比较导入的与系统中重复的两个api的响应体信息
*
* @param existApi
* @param apiDefinition
* @param objectMapper
* @return
*/
private static Boolean delRequest(ApiDefinitionWithBLOBs existApi, ApiDefinitionWithBLOBs apiDefinition, ObjectMapper objectMapper, ApiSyncCaseRequest apiSyncCaseRequest, Boolean toUpdate) {
JsonNode exApiRequest = null;
JsonNode apiRequest = null;
try {
exApiRequest = objectMapper.readTree(existApi.getRequest());
apiRequest = objectMapper.readTree(apiDefinition.getRequest());
} catch (JsonProcessingException e) {
e.printStackTrace();
}
if (exApiRequest == null || apiRequest == null) {
return exApiRequest != null || apiRequest != null;
}
List<String> compareProList = Arrays.asList(HEADERS, ARGUMENTS, REST);
Map<String, Boolean> applicationMap = new HashMap<>(4);
applicationMap.put(HEADERS, apiSyncCaseRequest.getHeaders());
applicationMap.put(ARGUMENTS, apiSyncCaseRequest.getQuery());
applicationMap.put(REST, apiSyncCaseRequest.getRest());
applicationMap.put(BODY, apiSyncCaseRequest.getBody());
boolean diffByNodes = false;
for (String property : compareProList) {
JsonNode exApiJsonNode = exApiRequest.get(property);
JsonNode apiJsonNode = apiRequest.get(property);
if (exApiJsonNode != null && apiJsonNode != null) {
diffByNodes = getDiffByArrayNodes(apiRequest, exApiRequest, objectMapper, property);
if (diffByNodes) {
if (toUpdate && applicationMap.get(property)) {
apiDefinition.setToBeUpdateTime(System.currentTimeMillis());
}
break;
}
}
}
if (diffByNodes) {
return true;
}
return delBody(apiDefinition, objectMapper, toUpdate, exApiRequest, apiRequest, applicationMap);
}
private static Boolean delResponse(ApiDefinitionWithBLOBs existApi, ApiDefinitionWithBLOBs apiDefinition, ObjectMapper objectMapper) {
JsonNode exApiResponse = null;
JsonNode apiResponse = null;
if (StringUtils.isBlank(apiDefinition.getResponse()) || StringUtils.isBlank(existApi.getResponse())) {
return !StringUtils.isBlank(apiDefinition.getResponse()) || !StringUtils.isBlank(existApi.getResponse());
}
try {
exApiResponse = objectMapper.readTree(existApi.getResponse());
apiResponse = objectMapper.readTree(apiDefinition.getResponse());
} catch (JsonProcessingException e) {
e.printStackTrace();
}
if (exApiResponse == null || apiResponse == null) {
return exApiResponse != null || apiResponse != null;
}
if (exApiResponse.get(HEADERS) != null && apiResponse.get(HEADERS) != null) {
if (!StringUtils.equals(exApiResponse.get(HEADERS).toString(), apiResponse.get(HEADERS).toString())) {
return true;
}
}
if (exApiResponse.get(PropertyConstant.TYPE) != null && apiResponse.get(PropertyConstant.TYPE) != null) {
if (!StringUtils.equals(exApiResponse.get(PropertyConstant.TYPE).toString(), apiResponse.get(PropertyConstant.TYPE).toString())) {
return true;
}
}
if (exApiResponse.get("name") != null && apiResponse.get("name") != null) {
if (!StringUtils.equals(exApiResponse.get("name").toString(), apiResponse.get("name").toString())) {
return true;
}
}
if (exApiResponse.get(BODY) != null && apiResponse.get(BODY) != null) {
if (!StringUtils.equals(exApiResponse.get(BODY).toString(), apiResponse.get(BODY).toString())) {
return true;
}
}
if (exApiResponse.get("statusCode") != null && apiResponse.get("statusCode") != null) {
if (!StringUtils.equals(exApiResponse.get("statusCode").toString(), apiResponse.get("statusCode").toString())) {
return true;
}
}
if (exApiResponse.get("enable") != null && apiResponse.get("enable") != null) {
return !StringUtils.equals(exApiResponse.get("enable").toString(), apiResponse.get("enable").toString());
}
return null;
}
private static boolean getDiffByArrayNodes(JsonNode apiRequest, JsonNode exApiRequest, ObjectMapper objectMapper, String name) {
JsonNode apiNameNode = apiRequest.get(name);
JsonNode caseNameNode = exApiRequest.get(name);
if (apiNameNode == null || caseNameNode == null) {
return false;
}
Map<String, String> apiMap = new HashMap<>();
getKeyNameMap(apiNameNode, objectMapper, apiMap, "name");
Map<String, String> exApiMap = new HashMap<>();
getKeyNameMap(caseNameNode, objectMapper, exApiMap, "name");
if (apiMap.size() != exApiMap.size()) {
return true;
}
Set<String> apiKey = apiMap.keySet();
Set<String> exApiKey = exApiMap.keySet();
List<String> collect = apiKey.stream().filter(exApiKey::contains).collect(Collectors.toList());
if (collect.size() != apiKey.size()) {
return true;
}
return false;
}
public static void getKeyNameMap(JsonNode apiNameNode, ObjectMapper objectMapper, Map<String, String> nameMap, String nodeKey) {
for (int i = 0; i < apiNameNode.size(); i++) {
JsonNode apiName = apiNameNode.get(i);
if (apiName.has(nodeKey)) {
String keyName = null;
try {
keyName = objectMapper.writeValueAsString(apiName.get(nodeKey));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
if (StringUtils.isNotBlank(keyName) && !StringUtils.equals(keyName, "\"\"") && !StringUtils.equals(keyName, "null")) {
try {
nameMap.put(apiName.get(nodeKey).toString(), objectMapper.writeValueAsString(apiName));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
}
}
}
private static Boolean delBody(ApiDefinitionWithBLOBs apiDefinition, ObjectMapper objectMapper, Boolean toUpdate, JsonNode exApiRequest, JsonNode apiRequest, Map<String, Boolean> applicationMap) {
JsonNode exBodyNode = exApiRequest.get(BODY);
JsonNode bodyNode = apiRequest.get(BODY);
if (exBodyNode != null && bodyNode != null) {
JsonNode exRowNode = exBodyNode.get("raw");
JsonNode rowNode = bodyNode.get("raw");
if (exRowNode != null && rowNode != null) {
if (!StringUtils.equals(exRowNode.asText(), rowNode.asText())) {
if (applicationMap.get(BODY)) {
apiDefinition.setToBeUpdateTime(System.currentTimeMillis());
}
return true;
}
}
boolean diffByNodes = getDiffByArrayNodes(bodyNode, exBodyNode, objectMapper, "kvs");
if (diffByNodes && toUpdate && applicationMap.get(BODY)) {
apiDefinition.setToBeUpdateTime(System.currentTimeMillis());
}
if (diffByNodes) {
return true;
}
JsonNode exApiJsonSchema = exBodyNode.get(JSONSCHEMA);
JsonNode apiJsonSchema = bodyNode.get(JSONSCHEMA);
if (exApiJsonSchema == null || apiJsonSchema == null) {
return false;
}
JsonNode exApiProperties = exApiJsonSchema.get(PROPERTIES);
JsonNode apiProperties = apiJsonSchema.get(PROPERTIES);
if (exApiProperties == null || apiProperties == null) {
return false;
}
boolean diffJsonschema = replenishCaseProperties(exApiProperties, apiProperties);
if (diffJsonschema && toUpdate && applicationMap.get(BODY)) {
apiDefinition.setToBeUpdateTime(System.currentTimeMillis());
}
return diffJsonschema;
}
return null;
}
private static boolean replenishCaseProperties(JsonNode exApiProperties, JsonNode apiProperties) {
Iterator<Map.Entry<String, JsonNode>> apiFields = apiProperties.fields();
Iterator<Map.Entry<String, JsonNode>> exApiFields = exApiProperties.fields();
boolean diffProp = false;
while (apiFields.hasNext()) {
Map.Entry<String, JsonNode> apiNode = apiFields.next();
if (diffProp) {
break;
}
if (exApiFields.hasNext()) {
Map.Entry<String, JsonNode> exChildNode = null;
Map.Entry<String, JsonNode> exNode = exApiFields.next();
if (StringUtils.equalsIgnoreCase(apiNode.getKey(), exNode.getKey())) {
exChildNode = exNode;
} else {
diffProp = true;
}
if (exChildNode == null) {
continue;
}
JsonNode value = apiNode.getValue();
JsonNode value1 = exChildNode.getValue();
JsonNode apiPropertiesNode = value.get(PROPERTIES);
JsonNode exApiPropertiesNode = value1.get(PROPERTIES);
if (apiPropertiesNode == null || exApiPropertiesNode == null) {
continue;
}
replenishCaseProperties(exApiPropertiesNode, apiPropertiesNode);
} else {
return true;
}
}
return false;
}
public static ApiTestCaseWithBLOBs addNewCase(ApiDefinitionWithBLOBs apiDefinition) {
ApiTestCaseWithBLOBs apiTestCase = new ApiTestCaseWithBLOBs();
apiTestCase.setApiDefinitionId(apiDefinition.getId());
apiTestCase.setProjectId(apiDefinition.getProjectId());
apiTestCase.setName(apiDefinition.getName());
apiTestCase.setRequest(apiDefinition.getRequest());
return apiTestCase;
}
public static void setModule(ApiDefinitionWithBLOBs item, ApiModuleMapper apiModuleMapper) {
if (item != null && StringUtils.isEmpty(item.getModuleId()) || "default-module".equals(item.getModuleId())) {
ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo("未规划接口");
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) {
item.setModuleId(modules.get(0).getId());
item.setModulePath(modules.get(0).getName());
}
}
}
public static void sendImportApiNotice(ApiDefinitionWithBLOBs apiDefinitionWithBLOBs, String context, String event, String tip) {
NoticeSendService noticeSendService = CommonBeanFactory.getBean(NoticeSendService.class);
BeanMap beanMap = new BeanMap(apiDefinitionWithBLOBs);
Map paramMap = new HashMap<>(beanMap);
paramMap.put("operator", SessionUtils.getUserId());
NoticeModel noticeModel = NoticeModel.builder().operator(SessionUtils.getUserId()).context(context).testId(apiDefinitionWithBLOBs.getId()).subject(Translator.get(tip)).paramMap(paramMap).excludeSelf(true).event(event).build();
noticeSendService.send(NoticeConstants.TaskType.API_DEFINITION_TASK, noticeModel);
}
public static void sendImportCaseNotice(ApiTestCase apiTestCase, String context, String event, String tip) {
NoticeSendService noticeSendService = CommonBeanFactory.getBean(NoticeSendService.class);
BeanMap beanMap = new BeanMap(apiTestCase);
Map paramMap = new HashMap<>(beanMap);
paramMap.put("operator", SessionUtils.getUserId());
NoticeModel noticeModel = NoticeModel.builder().operator(SessionUtils.getUserId()).context(context).testId(apiTestCase.getId()).subject(Translator.get(tip)).paramMap(paramMap).excludeSelf(true).event(event).build();
noticeSendService.send(NoticeConstants.TaskType.API_DEFINITION_TASK, noticeModel);
}
public static ApiDefinitionResult getApiDefinitionResult(ApiDefinitionWithBLOBs apiDefinition, boolean isUpdate) {
ApiDefinitionResult apiDefinitionResult = new ApiDefinitionResult();
BeanUtils.copyBean(apiDefinitionResult, apiDefinition);
apiDefinitionResult.setUpdated(isUpdate);
return apiDefinitionResult;
}
public static Map<String, List<ApiTestCaseWithBLOBs>> getOldCaseMap(List<ApiDefinitionWithBLOBs> repeatApiDefinitionWithBLOBs, ApiTestCaseMapper apiTestCaseMapper) {
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap;
List<String> definitionIds = repeatApiDefinitionWithBLOBs.stream().map(ApiDefinition::getId).collect(Collectors.toList());
ApiTestCaseExample testCaseExample = new ApiTestCaseExample();
testCaseExample.createCriteria().andApiDefinitionIdIn(definitionIds);
testCaseExample.or(testCaseExample.createCriteria().andStatusNotEqualTo(ApiTestDataStatus.TRASH.getValue()).andStatusIsNull());
List<ApiTestCaseWithBLOBs> caseWithBLOBs = apiTestCaseMapper.selectByExampleWithBLOBs(testCaseExample);
oldCaseMap = caseWithBLOBs.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId));
return oldCaseMap;
}
public static void delEsbData(ApiDefinitionImport apiImport, SqlSession sqlSession) {
if (apiImport.getEsbApiParamsMap() != null && apiImport.getEsbApiParamsMap().size() > 0) {
EsbApiParamsMapper esbApiParamsMapper = sqlSession.getMapper(EsbApiParamsMapper.class);
for (EsbApiParamsWithBLOBs model : apiImport.getEsbApiParamsMap().values()) {
EsbApiParamsExample example = new EsbApiParamsExample();
example.createCriteria().andResourceIdEqualTo(model.getResourceId());
List<EsbApiParamsWithBLOBs> exitModelList = esbApiParamsMapper.selectByExampleWithBLOBs(example);
if (exitModelList.isEmpty()) {
esbApiParamsMapper.insert(model);
} else {
model.setId(exitModelList.get(0).getId());
esbApiParamsMapper.updateByPrimaryKeyWithBLOBs(model);
}
}
}
}
}

View File

@ -13,8 +13,6 @@ import io.metersphere.base.domain.ApiDefinitionExample;
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
import io.metersphere.base.domain.ApiModule;
import io.metersphere.base.domain.ApiModuleExample;
import io.metersphere.base.domain.ApiTestCase;
import io.metersphere.base.domain.ApiTestCaseExample;
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
import io.metersphere.base.domain.EsbApiParamsWithBLOBs;
import io.metersphere.base.mapper.ApiDefinitionMapper;
@ -27,7 +25,6 @@ import io.metersphere.commons.constants.PropertyConstant;
import io.metersphere.commons.constants.TestCaseConstants;
import io.metersphere.commons.enums.ApiTestDataStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.JSON;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SessionUtils;
@ -57,9 +54,7 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -76,8 +71,6 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
@Resource
private ApiDefinitionService apiDefinitionService;
@Resource
private ApiTestCaseMapper apiTestCaseMapper;
@Resource
private ExtApiTestCaseMapper extApiTestCaseMapper;
@Resource
@ -625,8 +618,6 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
Map<String, ApiModuleDTO> idModuleMap, ApiTestImportRequest request,
Boolean fullCoverage, List<ApiTestCaseWithBLOBs> importCases, Map<String, EsbApiParamsWithBLOBs> esbApiParamsMap) {
List<ApiDefinitionWithBLOBs> optionData = new ArrayList<>();
//系统原有的需要更新的list
List<ApiDefinitionWithBLOBs> toUpdateList = new ArrayList<>();
//去重TCP,SQL,DUBBO 模块下名称唯一
removeRepeatOrigin(data, fullCoverage, optionData);
//上传文件时选的模块ID
@ -644,105 +635,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
//处理模块
setModule(moduleMap, pidChildrenMap, idPathMap, idModuleMap, optionData, chooseModule);
List<ApiDefinitionWithBLOBs> repeatApiDefinitionWithBLOBs = getApiDefinitionWithBLOBsList(request, optionData);
//重复接口的case
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
oldCaseMap = getOldCaseMap(repeatApiDefinitionWithBLOBs);
}
Map<String, ApiDefinitionWithBLOBs> repeatDataMap = null;
Map<String, ApiDefinitionWithBLOBs> optionMap = new HashMap<>();
if (chooseModule != null) {
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
String chooseModuleParentId = getChooseModuleParentId(chooseModule);
String chooseModulePath = getChooseModulePath(idPathMap, chooseModule, chooseModuleParentId);
if (fullCoverage) {
List<ApiDefinitionWithBLOBs> singleOptionData = new ArrayList<>();
removeOtherChooseModuleRepeat(optionData, singleOptionData, chooseModulePath);
optionData = singleOptionData;
optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getName().concat(chooseModulePath), api -> api));
} else {
getNoHChooseModuleUrlRepeatOptionMap(optionData, optionMap, chooseModulePath);
}
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().filter(t -> t.getModuleId().equals(chooseModuleId)).collect(Collectors.toMap(t -> t.getName().concat(t.getModulePath()), api -> api));
}
} else {
buildOptionMap(optionData, optionMap);
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.toMap(t -> t.getName().concat(t.getModulePath()), api -> api));
}
}
Boolean fullCoverageApi = getFullCoverageApi(request);
String updateVersionId = getUpdateVersionId(request);
String versionId = getVersionId(request);
//处理数据
if (fullCoverage) {
if (fullCoverageApi) {
coverModule(toUpdateList, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap, esbApiParamsMap);
} else {
moduleMap = cover(moduleMap, toUpdateList, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap, esbApiParamsMap);
}
} else {
//不覆盖
removeRepeat(optionData, optionMap, repeatDataMap, moduleMap, versionId, optionDataCases);
}
//系统内检查重复
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.toMap(t -> t.getName().concat(t.getModulePath()), api -> api));
optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getName().concat(t.getModulePath()), api -> api));
if (fullCoverage) {
cover(moduleMap, toUpdateList, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap, esbApiParamsMap);
} else {
//不覆盖,同一接口不做更新
removeRepeat(optionData, optionMap, repeatDataMap, moduleMap, versionId, optionDataCases);
}
}
if (optionData.isEmpty()) {
moduleMap = new HashMap<>();
}
//将原来的case和更改的case组合在一起为了同步的设置
List<String> caseIds = optionDataCases.stream().map(ApiTestCase::getId).filter(StringUtils::isNotBlank).collect(Collectors.toList());
buildCases(optionDataCases, oldCaseMap, caseIds);
return getUpdateApiModuleDTO(moduleMap, toUpdateList, optionData, optionDataCases);
}
private void getNoHChooseModuleUrlRepeatOptionMap(List<ApiDefinitionWithBLOBs> optionData, Map<String, ApiDefinitionWithBLOBs> optionMap, String chooseModulePath) {
for (ApiDefinitionWithBLOBs optionDatum : optionData) {
if (optionDatum.getModulePath() == null) {
optionMap.put(optionDatum.getName().concat(chooseModulePath), optionDatum);
} else {
optionMap.put(optionDatum.getName().concat(chooseModulePath).concat(optionDatum.getModulePath()), optionDatum);
}
}
}
private void removeOtherChooseModuleRepeat(List<ApiDefinitionWithBLOBs> optionData, List<ApiDefinitionWithBLOBs> singleOptionData, String chooseModulePath) {
LinkedHashMap<String, List<ApiDefinitionWithBLOBs>> methodPathMap = optionData.stream().collect(Collectors.groupingBy(t -> t.getName().concat(chooseModulePath), LinkedHashMap::new, Collectors.toList()));
methodPathMap.forEach((k, v) -> {
singleOptionData.add(v.get(v.size() - 1));
});
}
private void buildOptionMap(List<ApiDefinitionWithBLOBs> optionData, Map<String, ApiDefinitionWithBLOBs> optionMap) {
for (ApiDefinitionWithBLOBs optionDatum : optionData) {
if (optionDatum.getModulePath() == null) {
optionMap.put(optionDatum.getName(), optionDatum);
} else {
optionMap.put(optionDatum.getName().concat(optionDatum.getModulePath()), optionDatum);
}
}
}
private List<ApiDefinitionWithBLOBs> getApiDefinitionWithBLOBsList(ApiTestImportRequest request, List<ApiDefinitionWithBLOBs> optionData) {
//处理数据
List<String> nameList = optionData.stream().map(ApiDefinitionWithBLOBs::getName).collect(Collectors.toList());
String projectId = request.getProjectId();
String protocol = request.getProtocol();
//获取系统内重复数据
return extApiDefinitionMapper.selectRepeatByProtocol(nameList, protocol, projectId);
return getUpdateApiModuleDTO(chooseModule,idPathMap,optionData,fullCoverage, moduleMap,optionDataCases);
}
private UpdateApiModuleDTO dealHttp(List<ApiDefinitionWithBLOBs> data,
@ -751,8 +644,6 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
Boolean fullCoverage, boolean urlRepeat, List<ApiTestCaseWithBLOBs> importCases) {
List<ApiDefinitionWithBLOBs> optionData = new ArrayList<>();
//系统原有的需要更新的list
List<ApiDefinitionWithBLOBs> toUpdateList = new ArrayList<>();
//去重 如果url可重复 则模块+名称+请求方式+路径 唯一否则 请求方式+路径唯一
//覆盖模式留重复的最后一个不覆盖留第一个
removeHttpRepeat(data, fullCoverage, urlRepeat, optionData);
@ -772,182 +663,12 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
//处理模块
setModule(moduleMap, pidChildrenMap, idPathMap, idModuleMap, optionData, chooseModule);
if (urlRepeat) {
optionData = dealHttpUrlRepeat(chooseModule, idPathMap, optionData, fullCoverage, request, moduleMap, toUpdateList, optionDataCases);
} else {
dealHttpUrlNoRepeat(optionData, fullCoverage, request, moduleMap, toUpdateList, optionDataCases);
}
if (optionData.isEmpty()) {
moduleMap = new HashMap<>();
}
return getUpdateApiModuleDTO(moduleMap, toUpdateList, optionData, optionDataCases);
return getUpdateApiModuleDTO(chooseModule,idPathMap,optionData,fullCoverage, moduleMap,optionDataCases);
}
private void dealHttpUrlNoRepeat(List<ApiDefinitionWithBLOBs> optionData,
Boolean fullCoverage, ApiTestImportRequest request, Map<String, ApiModule> moduleMap,
List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiTestCaseWithBLOBs> optionDataCases) {
//这个是名称加请求方式加路径加模块为key的map 就是为了去重
Map<String, ApiDefinitionWithBLOBs> optionMap;
String updateVersionId = getUpdateVersionId(request);
String versionId = getVersionId(request);
Boolean fullCoverageApi = getFullCoverageApi(request);
String projectId = request.getProjectId();
//系统内重复的数据
List<ApiDefinitionWithBLOBs> repeatApiDefinitionWithBLOBs = extApiDefinitionMapper.selectRepeatByBLOBs(optionData, projectId);
//这个是系统内重复的数据
Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.groupingBy(t -> t.getMethod().concat(t.getPath())));
//按照原来的顺序
optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getMethod().concat(t.getPath()), api -> api));
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap = new HashMap<>();
//重复接口的case
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
oldCaseMap = getOldCaseMap(repeatApiDefinitionWithBLOBs);
}
if (fullCoverage) {
if (fullCoverageApi) {
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
startCoverModule(toUpdateList, optionData, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
}
} else {
//不覆盖模块
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
startCover(toUpdateList, optionData, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
}
}
} else {
//不覆盖,同一接口不做更新
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
removeSameData(repeatDataMap, optionMap, optionData, moduleMap, versionId, optionDataCases);
}
}
//将原来的case和更改的case组合在一起为了同步的设置
List<String> caseIds = optionDataCases.stream().map(ApiTestCase::getId).filter(StringUtils::isNotBlank).collect(Collectors.toList());
buildCases(optionDataCases, oldCaseMap, caseIds);
}
private List<ApiDefinitionWithBLOBs> dealHttpUrlRepeat(ApiModuleDTO chooseModule, Map<String, String> idPathMap, List<ApiDefinitionWithBLOBs> optionData,
Boolean fullCoverage, ApiTestImportRequest request, Map<String, ApiModule> moduleMap,
List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiTestCaseWithBLOBs> optionDataCases) {
String updateVersionId = getUpdateVersionId(request);
String versionId = getVersionId(request);
Boolean fullCoverageApi = getFullCoverageApi(request);
String projectId = request.getProjectId();
//系统内重复的数据
List<ApiDefinitionWithBLOBs> repeatApiDefinitionWithBLOBs = extApiDefinitionMapper.selectRepeatByBLOBs(optionData, projectId);
//这个是名称加请求方式加路径加模块为key的map 就是为了去重
Map<String, ApiDefinitionWithBLOBs> optionMap = new HashMap<>();
//这个是系统内重复的数据
Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap;
//按照原来的顺序
if (chooseModule != null) {
//如果有选中的模块则在选中的模块下过滤 过滤规则是 选择的模块路径+名称+method+path
String chooseModuleParentId = getChooseModuleParentId(chooseModule);
String chooseModulePath = getChooseModulePath(idPathMap, chooseModule, chooseModuleParentId);
//这样的过滤规则下可能存在重复接口如果是覆盖模块需要按照去重规则再次去重否则就加上接口原有的模块
if (fullCoverage) {
List<ApiDefinitionWithBLOBs> singleOptionData = new ArrayList<>();
removeHttpChooseModuleRepeat(optionData, singleOptionData, chooseModulePath);
optionData = singleOptionData;
optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(chooseModulePath), api -> api));
} else {
getChooseModuleUrlRepeatOptionMap(optionData, optionMap, chooseModulePath);
}
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().filter(t -> t.getModuleId().equals(chooseModule.getId())).collect(Collectors.groupingBy(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(t.getModulePath())));
} else {
//否则在整个系统中过滤
getUrlRepeatOptionMap(optionData, optionMap);
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.groupingBy(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(t.getModulePath())));
}
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap = new HashMap<>();
//重复接口的case
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
oldCaseMap = getOldCaseMap(repeatApiDefinitionWithBLOBs);
}
//覆盖接口
if (fullCoverage) {
//允许覆盖模块用导入的重复数据的最后一条覆盖查询的所有重复数据; case 在覆盖的时候是拼接到原来的casename唯一不覆盖就用原来的
if (fullCoverageApi) {
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
startCoverModule(toUpdateList, optionData, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
}
} else {
//覆盖但不覆盖模块
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
//过滤同一层级重复模块导入文件没有新增接口无需创建接口模块
moduleMap = judgeModuleMap(moduleMap, optionMap, repeatDataMap);
startCover(toUpdateList, optionData, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
}
}
} else {
//不覆盖,同一接口不做更新;可能创建新版本case也直接创建
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
removeSameData(repeatDataMap, optionMap, optionData, moduleMap, versionId, optionDataCases);
}
}
//最后在整个体统内检查一遍防止在有选择的模块时未找到重复直接创建的情况
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.groupingBy(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(t.getModulePath())));
optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(t.getModulePath()), api -> api));
if (fullCoverage) {
startCover(toUpdateList, optionData, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
} else {
//不覆盖,同一接口不做更新
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
removeSameData(repeatDataMap, optionMap, optionData, moduleMap, versionId, optionDataCases);
}
}
}
//将原来的case和更改的case组合在一起为了同步的设置
List<String> caseIds = optionDataCases.stream().map(ApiTestCase::getId).filter(StringUtils::isNotBlank).collect(Collectors.toList());
buildCases(optionDataCases, oldCaseMap, caseIds);
return optionData;
}
private void removeHttpChooseModuleRepeat(List<ApiDefinitionWithBLOBs> optionData, List<ApiDefinitionWithBLOBs> singleOptionData, String chooseModulePath) {
LinkedHashMap<String, List<ApiDefinitionWithBLOBs>> methodPathMap = optionData.stream().collect(Collectors.groupingBy(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(chooseModulePath), LinkedHashMap::new, Collectors.toList()));
methodPathMap.forEach((k, v) -> singleOptionData.add(v.get(v.size() - 1)));
}
private void getChooseModuleUrlRepeatOptionMap(List<ApiDefinitionWithBLOBs> optionData, Map<String, ApiDefinitionWithBLOBs> optionMap, String chooseModulePath) {
for (ApiDefinitionWithBLOBs optionDatum : optionData) {
if (optionDatum.getModulePath() == null) {
optionMap.put(optionDatum.getName().concat(optionDatum.getMethod()).concat(optionDatum.getPath()).concat(chooseModulePath), optionDatum);
} else {
optionMap.put(optionDatum.getName().concat(optionDatum.getMethod()).concat(optionDatum.getPath()).concat(chooseModulePath).concat(optionDatum.getModulePath()), optionDatum);
}
}
}
private void getUrlRepeatOptionMap(List<ApiDefinitionWithBLOBs> optionData, Map<String, ApiDefinitionWithBLOBs> optionMap) {
for (ApiDefinitionWithBLOBs optionDatum : optionData) {
if (optionDatum.getModulePath() == null) {
optionMap.put(optionDatum.getName().concat(optionDatum.getMethod()).concat(optionDatum.getPath()), optionDatum);
} else {
optionMap.put(optionDatum.getName().concat(optionDatum.getMethod()).concat(optionDatum.getPath()).concat(optionDatum.getModulePath()), optionDatum);
}
}
}
@NotNull
private Boolean getFullCoverageApi(ApiTestImportRequest request) {
Boolean fullCoverageApi = request.getCoverModule();
if (fullCoverageApi == null) {
fullCoverageApi = false;
}
return fullCoverageApi;
}
@NotNull
private Boolean getFullCoverage(ApiDefinitionImport apiImport, Boolean fullCoverage) {
if (fullCoverage == null) {
@ -961,18 +682,6 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
return fullCoverage;
}
private void buildCases(List<ApiTestCaseWithBLOBs> optionDataCases, Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap, List<String> caseIds) {
if (MapUtils.isNotEmpty(oldCaseMap)) {
List<ApiTestCaseWithBLOBs> oldCaseList = new ArrayList<>();
Collection<List<ApiTestCaseWithBLOBs>> values = oldCaseMap.values();
for (List<ApiTestCaseWithBLOBs> value : values) {
oldCaseList.addAll(value);
}
List<ApiTestCaseWithBLOBs> collect = oldCaseList.stream().filter(t -> !caseIds.contains(t.getId())).collect(Collectors.toList());
optionDataCases.addAll(collect);
}
}
private void removeRepeatCase(Boolean fullCoverage, List<ApiTestCaseWithBLOBs> importCases, List<ApiTestCaseWithBLOBs> optionDataCases) {
LinkedHashMap<String, List<ApiTestCaseWithBLOBs>> apiIdNameMap = importCases.stream().collect(Collectors.groupingBy(t -> t.getName().concat(t.getApiDefinitionId()), LinkedHashMap::new, Collectors.toList()));
if (fullCoverage) {
@ -990,164 +699,17 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
}
}
private Map<String, List<ApiTestCaseWithBLOBs>> getOldCaseMap(List<ApiDefinitionWithBLOBs> repeatApiDefinitionWithBLOBs) {
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap;
List<String> definitionIds = repeatApiDefinitionWithBLOBs.stream().map(ApiDefinition::getId).collect(Collectors.toList());
ApiTestCaseExample testCaseExample = new ApiTestCaseExample();
testCaseExample.createCriteria().andApiDefinitionIdIn(definitionIds);
testCaseExample.or(testCaseExample.createCriteria().andStatusNotEqualTo(ApiTestDataStatus.TRASH.getValue()).andStatusIsNull());
List<ApiTestCaseWithBLOBs> caseWithBLOBs = apiTestCaseMapper.selectByExampleWithBLOBs(testCaseExample);
oldCaseMap = caseWithBLOBs.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId));
return oldCaseMap;
}
private UpdateApiModuleDTO getUpdateApiModuleDTO(Map<String, ApiModule> moduleMap, List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiDefinitionWithBLOBs> optionData, List<ApiTestCaseWithBLOBs> optionDataCases) {
private UpdateApiModuleDTO getUpdateApiModuleDTO(ApiModuleDTO chooseModule,Map<String, String> idPathMap,List<ApiDefinitionWithBLOBs> optionData,Boolean fullCoverage,Map<String, ApiModule> moduleMap, List<ApiTestCaseWithBLOBs> optionDataCases) {
UpdateApiModuleDTO updateApiModuleDTO = new UpdateApiModuleDTO();
updateApiModuleDTO.setModuleList(new ArrayList<>(moduleMap.values()));
updateApiModuleDTO.setNeedUpdateList(toUpdateList);
updateApiModuleDTO.setChooseModule(chooseModule);
updateApiModuleDTO.setIdPathMap(idPathMap);
updateApiModuleDTO.setFullCoverage(fullCoverage);
updateApiModuleDTO.setModuleMap(moduleMap);
updateApiModuleDTO.setDefinitionWithBLOBs(optionData);
updateApiModuleDTO.setCaseWithBLOBs(optionDataCases);
return updateApiModuleDTO;
}
private void removeRepeat(List<ApiDefinitionWithBLOBs> optionData, Map<String, ApiDefinitionWithBLOBs> nameModuleMap,
Map<String, ApiDefinitionWithBLOBs> repeatDataMap, Map<String, ApiModule> moduleMap,
String versionId,
List<ApiTestCaseWithBLOBs> optionDataCases) {
if (MapUtils.isEmpty(nameModuleMap) || MapUtils.isEmpty(repeatDataMap)) {
return;
}
Map<String, List<ApiDefinitionWithBLOBs>> moduleOptionData = optionData.stream().collect(Collectors.groupingBy(ApiDefinition::getModulePath));
repeatDataMap.forEach((k, v) -> {
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
if (apiDefinitionWithBLOBs == null) {
return;
}
Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp = optionDataCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId));
List<ApiTestCaseWithBLOBs> distinctNameCases = definitionIdCaseMAp.get(apiDefinitionWithBLOBs.getId());
String modulePath = apiDefinitionWithBLOBs.getModulePath();
List<ApiDefinitionWithBLOBs> moduleData = moduleOptionData.get(modulePath);
if (moduleData != null && moduleData.size() <= 1) {
moduleMap.remove(modulePath);
removeModulePath(moduleMap, moduleOptionData, modulePath);
moduleData.remove(apiDefinitionWithBLOBs);
}
//不覆盖选择版本如果被选版本有同接口不导入否则创建新版本接口
if (v.getVersionId().equals(versionId)) {
optionData.remove(apiDefinitionWithBLOBs);
if (CollectionUtils.isNotEmpty(distinctNameCases)) {
distinctNameCases.forEach(optionDataCases::remove);
}
} else {
//这里是为了标识当前数据是需要创建版本的不是全新增的数据
addNewVersionApi(apiDefinitionWithBLOBs, v, "new");
}
});
}
private void addNewVersionApi(ApiDefinitionWithBLOBs apiDefinitionWithBLOBs, ApiDefinitionWithBLOBs v, String version) {
apiDefinitionWithBLOBs.setVersionId(version);
apiDefinitionWithBLOBs.setNum(v.getNum());
apiDefinitionWithBLOBs.setStatus(v.getStatus());
apiDefinitionWithBLOBs.setOrder(v.getOrder());
apiDefinitionWithBLOBs.setRefId(v.getRefId());
apiDefinitionWithBLOBs.setLatest(v.getLatest());
}
private Map<String, ApiModule> cover(Map<String, ApiModule> moduleMap, List<ApiDefinitionWithBLOBs> toUpdateList,
Map<String, ApiDefinitionWithBLOBs> nameModuleMap, Map<String, ApiDefinitionWithBLOBs> repeatDataMap,
String updateVersionId, List<ApiTestCaseWithBLOBs> optionDataCases,
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap, Map<String, EsbApiParamsWithBLOBs> esbApiParamsMap) {
//覆盖但不覆盖模块
if (MapUtils.isEmpty(nameModuleMap) || MapUtils.isEmpty(repeatDataMap)) {
return moduleMap;
}
//导入文件没有新增接口无需创建接口模块
moduleMap = judgeModule(moduleMap, nameModuleMap, repeatDataMap);
repeatDataMap.forEach((k, v) -> {
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
if (apiDefinitionWithBLOBs != null) {
//系统内重复的数据的版本如果不是选择的数据更新版本则在数据更新版本新增否则更新这个版本的数据
if (!v.getVersionId().equals(updateVersionId)) {
addNewVersionApi(apiDefinitionWithBLOBs, v, "update");
return;
}
Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp = optionDataCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId));
//该接口的case
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
updateEsb(esbApiParamsMap, v.getId(), apiDefinitionWithBLOBs.getId());
//组合case
if (MapUtils.isNotEmpty(caseNameMap)) {
buildCaseList(oldCaseMap, caseNameMap, v, optionDataCases);
}
apiDefinitionWithBLOBs.setId(v.getId());
apiDefinitionWithBLOBs.setModuleId(v.getModuleId());
apiDefinitionWithBLOBs.setModulePath(v.getModulePath());
setApiParam(apiDefinitionWithBLOBs, updateVersionId, v);
toUpdateList.add(v);
}
});
return moduleMap;
}
private void updateEsb(Map<String, EsbApiParamsWithBLOBs> esbApiParamsMap, String newId, String oldId) {
if (MapUtils.isNotEmpty(esbApiParamsMap)) {
EsbApiParamsWithBLOBs esbApiParamsWithBLOBs = esbApiParamsMap.get(oldId);
if (esbApiParamsWithBLOBs != null) {
esbApiParamsMap.remove(oldId);
esbApiParamsWithBLOBs.setResourceId(newId);
esbApiParamsMap.put(newId, esbApiParamsWithBLOBs);
}
}
}
private Map<String, ApiModule> judgeModule(Map<String, ApiModule> moduleMap, Map<String, ApiDefinitionWithBLOBs> nameModuleMap, Map<String, ApiDefinitionWithBLOBs> repeatDataMap) {
AtomicBoolean remove = new AtomicBoolean(true);
if (repeatDataMap.size() >= nameModuleMap.size()) {
repeatDataMap.forEach((k, v) -> {
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
if (apiDefinitionWithBLOBs == null) {
remove.set(false);
}
});
if (remove.get()) {
moduleMap = new HashMap<>();
}
}
return moduleMap;
}
private void coverModule(List<ApiDefinitionWithBLOBs> toUpdateList, Map<String, ApiDefinitionWithBLOBs> nameModuleMap,
Map<String, ApiDefinitionWithBLOBs> repeatDataMap, String updateVersionId, List<ApiTestCaseWithBLOBs> optionDataCases,
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap, Map<String, EsbApiParamsWithBLOBs> esbApiParamsMap) {
if (MapUtils.isEmpty(nameModuleMap) || MapUtils.isEmpty(repeatDataMap)) {
return;
}
repeatDataMap.forEach((k, v) -> {
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
if (apiDefinitionWithBLOBs != null) {
//系统内重复的数据的版本如果不是选择的数据更新版本则在数据更新版本新增否则更新这个版本的数据
if (!v.getVersionId().equals(updateVersionId)) {
addNewVersionApi(apiDefinitionWithBLOBs, v, "update");
return;
}
//该接口的case
Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp = optionDataCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId));
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
updateEsb(esbApiParamsMap, v.getId(), apiDefinitionWithBLOBs.getId());
//组合case
if (MapUtils.isNotEmpty(caseNameMap)) {
buildCaseList(oldCaseMap, caseNameMap, v, optionDataCases);
}
apiDefinitionWithBLOBs.setId(v.getId());
setApiParam(apiDefinitionWithBLOBs, updateVersionId, v);
toUpdateList.add(v);
}
});
}
private void removeRepeatOrigin(List<ApiDefinitionWithBLOBs> data, Boolean fullCoverage, List<ApiDefinitionWithBLOBs> optionData) {
LinkedHashMap<String, List<ApiDefinitionWithBLOBs>> methodPathMap = data.stream().collect(Collectors.groupingBy(t -> t.getName() + (t.getModulePath() == null ? StringUtils.EMPTY : t.getModulePath()), LinkedHashMap::new, Collectors.toList()));
if (fullCoverage) {
@ -1175,257 +737,6 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
}
}
private String getVersionId(ApiTestImportRequest request) {
String versionId;
if (request.getVersionId() == null) {
versionId = request.getDefaultVersion();
} else {
versionId = request.getVersionId();
}
return versionId;
}
private String getUpdateVersionId(ApiTestImportRequest request) {
String updateVersionId;
if (request.getUpdateVersionId() != null) {
updateVersionId = request.getUpdateVersionId();
} else {
updateVersionId = request.getDefaultVersion();
}
return updateVersionId;
}
private void removeSameData(Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap, Map<String, ApiDefinitionWithBLOBs> methodPathMap,
List<ApiDefinitionWithBLOBs> optionData, Map<String, ApiModule> moduleMap, String versionId,
List<ApiTestCaseWithBLOBs> optionDataCases) {
Map<String, List<ApiDefinitionWithBLOBs>> moduleOptionData = optionData.stream().collect(Collectors.groupingBy(ApiDefinition::getModulePath));
repeatDataMap.forEach((k, v) -> {
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = methodPathMap.get(k);
if (apiDefinitionWithBLOBs != null) {
Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp = optionDataCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId));
List<ApiTestCaseWithBLOBs> distinctNameCases = definitionIdCaseMAp.get(apiDefinitionWithBLOBs.getId());
String modulePath = apiDefinitionWithBLOBs.getModulePath();
List<ApiDefinitionWithBLOBs> moduleData = moduleOptionData.get(modulePath);
if (moduleData != null && moduleData.size() <= 1) {
moduleMap.remove(modulePath);
removeModulePath(moduleMap, moduleOptionData, modulePath);
moduleData.remove(apiDefinitionWithBLOBs);
}
//不覆盖选择版本如果被选版本有同接口不导入否则创建新版本接口
List<ApiDefinitionWithBLOBs> sameVersionList = v.stream().filter(t -> t.getVersionId().equals(versionId)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(sameVersionList)) {
optionData.remove(apiDefinitionWithBLOBs);
if (CollectionUtils.isNotEmpty(distinctNameCases)) {
distinctNameCases.forEach(optionDataCases::remove);
}
} else {
for (ApiDefinitionWithBLOBs definitionWithBLOBs : v) {
addNewVersionApi(apiDefinitionWithBLOBs, definitionWithBLOBs, "new");
}
}
}
});
}
private void setApiParam(ApiDefinitionWithBLOBs apiDefinitionWithBLOBs, String versionId, ApiDefinitionWithBLOBs definitionWithBLOBs) {
apiDefinitionWithBLOBs.setVersionId(versionId);
apiDefinitionWithBLOBs.setNum(definitionWithBLOBs.getNum());
apiDefinitionWithBLOBs.setStatus(definitionWithBLOBs.getStatus());
apiDefinitionWithBLOBs.setOrder(definitionWithBLOBs.getOrder());
apiDefinitionWithBLOBs.setRefId(definitionWithBLOBs.getRefId());
apiDefinitionWithBLOBs.setLatest(definitionWithBLOBs.getLatest());
apiDefinitionWithBLOBs.setCreateTime(definitionWithBLOBs.getCreateTime());
apiDefinitionWithBLOBs.setUpdateTime(definitionWithBLOBs.getUpdateTime());
}
private void removeModulePath(Map<String, ApiModule> moduleMap, Map<String, List<ApiDefinitionWithBLOBs>> moduleOptionData, String modulePath) {
if (StringUtils.isBlank(modulePath)) {
return;
}
String[] pathTree = getPathTree(modulePath);
String lastPath = pathTree[pathTree.length - 1];
String substring = modulePath.substring(0, modulePath.indexOf("/" + lastPath));
if (moduleOptionData.get(substring) == null || moduleOptionData.get(substring).size() == 0) {
moduleMap.remove(substring);
removeModulePath(moduleMap, moduleOptionData, substring);
}
}
private void startCoverModule(List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiDefinitionWithBLOBs> optionData,
Map<String, ApiDefinitionWithBLOBs> methodPathMap, Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap,
String updateVersionId, List<ApiTestCaseWithBLOBs> optionDataCases,
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap) {
List<ApiDefinitionWithBLOBs> coverApiList = new ArrayList<>();
List<ApiDefinitionWithBLOBs> updateApiList = new ArrayList<>();
repeatDataMap.forEach((k, v) -> {
//导入的与系统是相同接口的数据
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = methodPathMap.get(k);
if (apiDefinitionWithBLOBs != null) {
//该接口的case
Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp = optionDataCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId));
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
//循环系统内重复接口
int i = 0;
for (ApiDefinitionWithBLOBs definitionWithBLOBs : v) {
if (!definitionWithBLOBs.getVersionId().equals(updateVersionId)) {
i += 1;
continue;
}
//组合case
if (MapUtils.isNotEmpty(caseNameMap)) {
buildCaseList(oldCaseMap, caseNameMap, definitionWithBLOBs, optionDataCases);
}
ApiDefinitionWithBLOBs api = new ApiDefinitionWithBLOBs();
BeanUtils.copyBean(api, apiDefinitionWithBLOBs);
api.setId(definitionWithBLOBs.getId());
setApiParam(api, updateVersionId, definitionWithBLOBs);
coverApiList.add(api);
updateApiList.add(definitionWithBLOBs);
}
if (i == v.size()) {
//如果系统内的所有版本都不是当前选择的数据更新版本则在数据更新版本这里新建数据
addNewVersionApi(apiDefinitionWithBLOBs, v.get(0), "update");
} else {
optionData.remove(apiDefinitionWithBLOBs);
}
}
});
buildOtherParam(toUpdateList, optionData, coverApiList, updateApiList);
}
private void buildCaseList(Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap,
Map<String, ApiTestCaseWithBLOBs> caseNameMap,
ApiDefinitionWithBLOBs definitionWithBLOBs, List<ApiTestCaseWithBLOBs> optionDataCases) {
//找出系统内重复接口的case表里可能一个接口有多个同名case的可能
List<ApiTestCaseWithBLOBs> oldApiTestCases = oldCaseMap.get(definitionWithBLOBs.getId());
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseNameMap;
//如果同名重复用例有多个则覆盖最后的那个
if (CollectionUtils.isNotEmpty(oldApiTestCases)) {
oldCaseNameMap = oldApiTestCases.stream().collect(Collectors.groupingBy(ApiTestCase::getName));
caseNameMap.forEach((name, importCaseWithBLOBs) -> {
//如果导入的有重名覆盖接口ID替换成系统内的
importCaseWithBLOBs.setApiDefinitionId(definitionWithBLOBs.getId());
List<ApiTestCaseWithBLOBs> caseWithBLOBs = oldCaseNameMap.get(name);
if (CollectionUtils.isNotEmpty(caseWithBLOBs)) {
for (int i = 0; i < caseWithBLOBs.size(); i++) {
int version = 0;
if (caseWithBLOBs.get(i).getVersion() != null) {
version = caseWithBLOBs.get(i).getVersion() + 1;
}
if (i == 0) {
//被覆盖数据
importCaseWithBLOBs.setId(caseWithBLOBs.get(i).getId());
importCaseWithBLOBs.setNum(caseWithBLOBs.get(i).getNum());
importCaseWithBLOBs.setVersion(version);
importCaseWithBLOBs.setCreateUserId(caseWithBLOBs.get(i).getCreateUserId());
importCaseWithBLOBs.setUpdateUserId(caseWithBLOBs.get(i).getCreateUserId());
} else {
//同名的旧数据处理
caseWithBLOBs.get(i).setVersionId("old_case");
optionDataCases.add(caseWithBLOBs.get(i));
}
}
oldCaseNameMap.remove(name);
}
});
//不同名的旧数据处理
oldCaseNameMap.forEach((k, v) -> {
if (CollectionUtils.isNotEmpty(v)) {
for (ApiTestCaseWithBLOBs apiTestCaseWithBLOBs : v) {
apiTestCaseWithBLOBs.setVersionId("old_case");
optionDataCases.add(apiTestCaseWithBLOBs);
}
}
});
} else {
//否则直接给新增用例赋值新的接口ID
caseNameMap.forEach((name, caseWithBLOBs1) -> {
caseWithBLOBs1.setApiDefinitionId(definitionWithBLOBs.getId());
caseWithBLOBs1.setVersion(0);
});
}
}
private Map<String, ApiTestCaseWithBLOBs> getDistinctCaseNameMap(Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp, ApiDefinitionWithBLOBs apiDefinitionWithBLOBs) {
if (MapUtils.isEmpty(definitionIdCaseMAp)) {
return null;
}
List<ApiTestCaseWithBLOBs> caseWithBLOBs = definitionIdCaseMAp.get(apiDefinitionWithBLOBs.getId());
if (CollectionUtils.isNotEmpty(caseWithBLOBs)) {
return caseWithBLOBs.stream().filter(t -> !StringUtils.equalsIgnoreCase("old_case", t.getVersionId())).collect(Collectors.toMap(ApiTestCase::getName, testCase -> testCase));
} else {
return null;
}
}
private void startCover(List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiDefinitionWithBLOBs> optionData,
Map<String, ApiDefinitionWithBLOBs> methodPathMap, Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap,
String updateVersionId, List<ApiTestCaseWithBLOBs> optionDataCases,
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap) {
List<ApiDefinitionWithBLOBs> coverApiList = new ArrayList<>();
List<ApiDefinitionWithBLOBs> updateApiList = new ArrayList<>();
repeatDataMap.forEach((k, v) -> {
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = methodPathMap.get(k);
if (apiDefinitionWithBLOBs != null) {
//该接口的case
Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp = optionDataCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId));
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
int i = 0;
for (ApiDefinitionWithBLOBs definitionWithBLOBs : v) {
if (!definitionWithBLOBs.getVersionId().equals(updateVersionId)) {
i += 1;
continue;
}
//组合case
if (MapUtils.isNotEmpty(caseNameMap)) {
buildCaseList(oldCaseMap, caseNameMap, definitionWithBLOBs, optionDataCases);
}
ApiDefinitionWithBLOBs api = new ApiDefinitionWithBLOBs();
BeanUtils.copyBean(api, apiDefinitionWithBLOBs);
api.setId(definitionWithBLOBs.getId());
api.setModuleId(definitionWithBLOBs.getModuleId());
api.setModulePath(definitionWithBLOBs.getModulePath());
setApiParam(api, updateVersionId, definitionWithBLOBs);
coverApiList.add(api);
updateApiList.add(definitionWithBLOBs);
}
if (i == v.size()) {
//如果系统内的所有版本都不是当前选择的数据更新版本则在数据更新版本这里新建数据
addNewVersionApi(apiDefinitionWithBLOBs, v.get(0), "update");
} else {
optionData.remove(apiDefinitionWithBLOBs);
}
}
});
buildOtherParam(toUpdateList, optionData, coverApiList, updateApiList);
}
private Map<String, ApiModule> judgeModuleMap(Map<String, ApiModule> moduleMap, Map<String, ApiDefinitionWithBLOBs> methodPathMap, Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap) {
Set<String> repeatKeys = repeatDataMap.keySet();
Set<String> importKeys = methodPathMap.keySet();
List<String> repeatKeyList = new ArrayList<>(repeatKeys);
List<String> importKeysList = new ArrayList<>(importKeys);
List<String> intersection = repeatKeyList.stream().filter(importKeysList::contains).collect(Collectors.toList());
if (intersection.size() == importKeysList.size()) {
//导入文件没有新增接口无需创建接口模块
moduleMap = new HashMap<>();
}
return moduleMap;
}
private void buildOtherParam(List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiDefinitionWithBLOBs> optionData, List<ApiDefinitionWithBLOBs> coverApiList, List<ApiDefinitionWithBLOBs> updateApiList) {
optionData.addAll(coverApiList);
toUpdateList.addAll(updateApiList);
}
private void setModule(Map<String, ApiModule> moduleMap, Map<String, List<ApiModule>> pidChildrenMap,
Map<String, String> idPathMap, Map<String, ApiModuleDTO> idModuleMap, List<ApiDefinitionWithBLOBs> data, ApiModuleDTO chooseModule) {
for (ApiDefinitionWithBLOBs datum : data) {
@ -1482,25 +793,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
datum.setModulePath(idPathMap.get(chooseModule.getId()));
}
}
private String getChooseModulePath(Map<String, String> idPathMap, ApiModuleDTO chooseModule, String chooseModuleParentId) {
String s;
if (chooseModuleParentId.equals(PropertyConstant.ROOT)) {
s = "/" + chooseModule.getName();
} else {
s = idPathMap.get(chooseModule.getId());
}
return s;
}
private String getChooseModuleParentId(ApiModuleDTO chooseModule) {
if (chooseModule.getParentId() == null) {
chooseModule.setParentId(PropertyConstant.ROOT);
}
return chooseModule.getParentId();
}
private String[] getPathTree(String modulePath) {
public String[] getPathTree(String modulePath) {
String substring = modulePath.substring(0, 1);
if (substring.equals("/")) {
modulePath = modulePath.substring(1);

View File

@ -231,6 +231,8 @@
ref="versionHistory"
:version-data="versionData"
:current-id="currentScenario.id"
:has-latest="hasLatest"
@setLatest="setLatest"
@compare="compare"
@checkout="checkout"
@create="create"
@ -574,10 +576,12 @@ import {
saveScenario,
} from '@/business/automation/api-automation';
import MsComponentConfig from './component/ComponentConfig';
import { ENV_TYPE } from 'metersphere-frontend/src/utils/constants';
import { mergeRequestDocumentData } from '@/business/definition/api-definition';
import { getEnvironmentByProjectId } from 'metersphere-frontend/src/api/environment';
import { useApiStore } from '@/store';
import {ENV_TYPE} from 'metersphere-frontend/src/utils/constants';
import {mergeRequestDocumentData} from '@/business/definition/api-definition';
import {getEnvironmentByProjectId} from 'metersphere-frontend/src/api/environment';
import {useApiStore} from '@/store';
import {getDefaultVersion, setLatestVersionById} from 'metersphere-frontend/src/api/version';
const store = useApiStore();
@ -785,6 +789,8 @@ export default {
oldUserName: '',
debugReportId: '',
isPreventReClick: false,
latestVersionId: '',
hasLatest: false
};
},
created() {
@ -808,7 +814,7 @@ export default {
this.initPlugins();
});
this.getVersionHistory();
this.getDefaultVersion();
},
mounted() {
this.$nextTick(() => {
@ -2479,6 +2485,16 @@ export default {
this.currentItem = data;
this.$refs.scenarioVariableAdvance.open();
},
getDefaultVersion() {
if (!hasLicense()) {
return;
}
getDefaultVersion(this.projectId)
.then(response => {
this.latestVersionId = response.data;
this.getVersionHistory();
});
},
getVersionHistory() {
if (!hasLicense()) {
return;
@ -2489,6 +2505,12 @@ export default {
} else {
this.versionData = response.data;
}
let latestVersionData = response.data.filter((v) => v.versionId === this.latestVersionId);
if (latestVersionData.length > 0) {
this.hasLatest = false
} else {
this.hasLatest = true;
}
});
},
compare(row) {
@ -2540,6 +2562,18 @@ export default {
},
});
},
setLatest(row) {
let param = {
projectId: this.projectId,
type: 'SCENARIO',
versionId: row.id,
resourceId: this.currentScenario.id
}
setLatestVersionById(param).then(() => {
this.$success(this.$t('commons.modify_success'));
this.checkout(row);
});
},
},
};
</script>

View File

@ -40,10 +40,12 @@
ref="versionHistory"
:version-data="versionData"
:current-id="basisData.id"
:has-latest="hasLatest"
@setLatest="setLatest"
@compare="compare"
@checkout="checkout"
@create="create"
@del="del" />
@del="del"/>
<el-button type="primary" size="small" @click="saveApi" title="ctrl + s">{{ $t('commons.save') }}</el-button>
</div>
</el-col>
@ -92,7 +94,7 @@ import {
delDefinitionByRefId,
getDefinitionById,
getDefinitionByIdAndRefId,
getDefinitionVersions,
getDefinitionVersions, updateDefinitionFollows,
} from '@/api/definition';
import MsBasisApi from './BasisApi';
import MsBasisParameters from '../request/dubbo/BasisParameters';
@ -105,7 +107,8 @@ import { createComponent } from '.././jmeter/components';
import { TYPE_TO_C } from '@/business/automation/scenario/Setting';
import MsDialogFooter from 'metersphere-frontend/src/components/MsDialogFooter';
import { useApiStore } from '@/store';
import { apiTestCaseCount } from '@/api/api-test-case';
import {apiTestCaseCount} from '@/api/api-test-case';
import {getDefaultVersion, setLatestVersionById} from 'metersphere-frontend/src/api/version';
const store = useApiStore();
const { Body } = require('@/business/definition/model/ApiTestModel');
@ -161,7 +164,7 @@ export default {
}
});
if (hasLicense()) {
this.getVersionHistory();
this.getDefaultVersion();
}
},
data() {
@ -175,6 +178,8 @@ export default {
newRequest: {},
newResponse: {},
createNewVersionVisible: false,
latestVersionId: '',
hasLatest: false
};
},
methods: {
@ -234,6 +239,13 @@ export default {
}
}
},
getDefaultVersion() {
getDefaultVersion(this.basisData.projectId)
.then(response => {
this.latestVersionId = response.data;
this.getVersionHistory();
});
},
getVersionHistory() {
getDefinitionVersions(this.basisData.id).then((response) => {
if (this.basisData.isCopy) {
@ -241,6 +253,12 @@ export default {
} else {
this.versionData = response.data;
}
let latestVersionData = response.data.filter((v) => v.versionId === this.latestVersionId);
if (latestVersionData.length > 0) {
this.hasLatest = false
} else {
this.hasLatest = true;
}
});
},
compare(row) {
@ -409,6 +427,19 @@ export default {
},
});
},
setLatest(row) {
let param = {
projectId: this.basisData.projectId,
type: 'API',
versionId: row.id,
resourceId: this.basisData.id
}
setLatestVersionById(param).then(() => {
this.$success(this.$t('commons.modify_success'));
this.checkout(row);
});
},
},
computed: {},

View File

@ -39,10 +39,13 @@
ref="versionHistory"
:version-data="versionData"
:current-id="httpForm.id"
:has-latest="hasLatest"
@compare="compare"
@checkout="checkout"
@create="create"
@del="del" />
@setLatest="setLatest"
@del="del"
/>
<el-button
v-if="!isXpack || !apiSyncRuleRelation.showUpdateRule"
type="primary"
@ -257,20 +260,22 @@ import MsJsr233Processor from '../../../automation/scenario/component/Jsr233Proc
import MsSelectTree from 'metersphere-frontend/src/components/select-tree/SelectTree';
import MsChangeHistory from '@/business/history/ApiHistory';
import { getCurrentUser } from 'metersphere-frontend/src/utils/token';
import { getUUID } from 'metersphere-frontend/src/utils';
import { hasLicense } from 'metersphere-frontend/src/utils/permission';
import {getUUID} from 'metersphere-frontend/src/utils';
import {hasLicense} from 'metersphere-frontend/src/utils/permission';
import MsFormDivider from 'metersphere-frontend/src/components/MsFormDivider';
import ApiOtherInfo from '@/business/definition/components/complete/ApiOtherInfo';
import HttpApiVersionDiff from './version/HttpApiVersionDiff';
import { createComponent } from '.././jmeter/components';
import { TYPE_TO_C } from '@/business/automation/scenario/Setting';
import {createComponent} from '.././jmeter/components';
import {TYPE_TO_C} from '@/business/automation/scenario/Setting';
import MsDialogFooter from 'metersphere-frontend/src/components/MsDialogFooter';
import { getProjectMemberOption } from '@/api/project';
import { deepClone } from 'metersphere-frontend/src/utils/tableUtils';
import SyncSetting from '@/business/definition/util/SyncSetting';
import { useApiStore } from '@/store';
import {getProjectMemberOption} from '@/api/project';
import {deepClone} from 'metersphere-frontend/src/utils/tableUtils';
import {getDefaultVersion, setLatestVersionById} from 'metersphere-frontend/src/api/version';
const { Body } = require('@/business/definition/model/ApiTestModel');
import SyncSetting from '@/business/definition/util/SyncSetting';
import {useApiStore} from '@/store';
const {Body} = require('@/business/definition/model/ApiTestModel');
const Sampler = require('@/business/definition/components/jmeter/components/sampler/sampler');
const store = useApiStore();
@ -384,6 +389,8 @@ export default {
},
noShowSyncRuleRelation: false,
citedScenarioCount: 0,
latestVersionId: '',
hasLatest: false
};
},
props: {
@ -761,6 +768,13 @@ export default {
}
}
},
getDefaultVersion() {
getDefaultVersion(this.projectId)
.then(response => {
this.latestVersionId = response.data;
this.getVersionHistory();
});
},
getVersionHistory() {
getDefinitionVersions(this.httpForm.id).then((response) => {
if (this.httpForm.isCopy) {
@ -768,6 +782,12 @@ export default {
} else {
this.versionData = response.data;
}
let latestVersionData = response.data.filter((v) => v.versionId === this.latestVersionId);
if (latestVersionData.length > 0) {
this.hasLatest = false
} else {
this.hasLatest = true;
}
});
},
compare(row) {
@ -954,6 +974,18 @@ export default {
},
});
},
setLatest(row) {
let param = {
projectId: this.projectId,
type: 'API',
versionId: row.id,
resourceId: this.basisData.id
}
setLatestVersionById(param).then(() => {
this.$success(this.$t('commons.modify_success'));
this.checkout(row);
});
},
gotoApiMessage() {
let apiResolve = this.$router.resolve({
path: '/project/messagesettings',
@ -1041,7 +1073,7 @@ export default {
this.initMockEnvironment();
if (hasLicense()) {
this.getVersionHistory();
this.getDefaultVersion();
this.getSyncRule();
this.getCitedScenarioCount();
this.getCaseCount();

View File

@ -40,9 +40,11 @@
ref="versionHistory"
:version-data="versionData"
:current-id="basisData.id"
:has-latest="hasLatest"
@compare="compare"
@checkout="checkout"
@create="create"
@setLatest="setLatest"
@del="del" />
<el-button type="primary" size="small" @click="saveApi" title="ctrl + s">{{ $t('commons.save') }}</el-button>
</div>
@ -101,14 +103,15 @@ import MsBasisApi from './BasisApi';
import MsBasisParameters from '../request/database/BasisParameters';
import MsChangeHistory from '@/business/history/ApiHistory';
import ApiOtherInfo from '@/business/definition/components/complete/ApiOtherInfo';
import { getCurrentUser } from 'metersphere-frontend/src/utils/token';
import { hasLicense } from 'metersphere-frontend/src/utils/permission';
import {getCurrentProjectID, getCurrentUser} from 'metersphere-frontend/src/utils/token';
import {hasLicense} from 'metersphere-frontend/src/utils/permission';
import SQLApiVersionDiff from './version/SQLApiVersionDiff';
import { createComponent } from '.././jmeter/components';
import { TYPE_TO_C } from '@/business/automation/scenario/Setting';
import MsDialogFooter from 'metersphere-frontend/src/components/MsDialogFooter';
import { useApiStore } from '@/store';
import { apiTestCaseCount } from '@/api/api-test-case';
import {apiTestCaseCount} from '@/api/api-test-case';
import {getDefaultVersion, setLatestVersionById} from 'metersphere-frontend/src/api/version';
const store = useApiStore();
const { Body } = require('@/business/definition/model/ApiTestModel');
@ -164,6 +167,8 @@ export default {
newRequest: {},
newResponse: {},
createNewVersionVisible: false,
latestVersionId: '',
hasLatest: false
};
},
created() {
@ -178,7 +183,7 @@ export default {
});
if (hasLicense()) {
this.getVersionHistory();
this.getDefaultVersion();
}
if (!this.request.environmentId) {
@ -244,6 +249,13 @@ export default {
}
}
},
getDefaultVersion() {
getDefaultVersion(getCurrentProjectID())
.then(response => {
this.latestVersionId = response.data;
this.getVersionHistory();
});
},
getVersionHistory() {
getDefinitionVersions(this.basisData.id).then((response) => {
if (this.basisData.isCopy) {
@ -251,6 +263,12 @@ export default {
} else {
this.versionData = response.data;
}
let latestVersionData = response.data.filter((v) => v.versionId === this.latestVersionId);
if (latestVersionData.length > 0) {
this.hasLatest = false
} else {
this.hasLatest = true;
}
});
},
compare(row) {
@ -421,6 +439,19 @@ export default {
},
});
},
setLatest(row) {
let param = {
projectId: getCurrentProjectID(),
type: 'API',
versionId: row.id,
resourceId: this.basisData.id
}
setLatestVersionById(param).then(() => {
this.$success(this.$t('commons.modify_success'));
this.checkout(row);
});
},
},
};
</script>

View File

@ -40,9 +40,11 @@
ref="versionHistory"
:version-data="versionData"
:current-id="basisData.id"
:has-latest="hasLatest"
@compare="compare"
@checkout="checkout"
@create="create"
@setLatest="setLatest"
@del="del" />
<el-button type="primary" size="small" @click="saveApi" title="ctrl + s">{{ $t('commons.save') }}</el-button>
</div>
@ -110,7 +112,7 @@ import {
delDefinitionByRefId,
getDefinitionById,
getDefinitionByIdAndRefId,
getDefinitionVersions,
getDefinitionVersions, updateDefinitionFollows,
} from '@/api/definition';
import MsTcpBasicApi from './TCPBasicApi';
import MsTcpFormatParameters from '../request/tcp/TcpFormatParameters';
@ -123,7 +125,8 @@ import { createComponent } from '.././jmeter/components';
import { TYPE_TO_C } from '@/business/automation/scenario/Setting';
import MsDialogFooter from 'metersphere-frontend/src/components/MsDialogFooter';
import { useApiStore } from '@/store';
import { apiTestCaseCount } from '@/api/api-test-case';
import {apiTestCaseCount} from '@/api/api-test-case';
import {getDefaultVersion, setLatestVersionById} from 'metersphere-frontend/src/api/version';
const store = useApiStore();
const { Body } = require('@/business/definition/model/ApiTestModel');
@ -171,6 +174,8 @@ export default {
newResponse: {},
newApiProtocol: 'TCP',
createNewVersionVisible: false,
latestVersionId: '',
hasLatest: false
};
},
created: function () {
@ -200,7 +205,7 @@ export default {
});
this.getMockInfo();
if (hasLicense()) {
this.getVersionHistory();
this.getDefaultVersion();
}
},
watch: {
@ -340,6 +345,14 @@ export default {
}
}
},
getDefaultVersion() {
getDefaultVersion(getCurrentProjectID())
.then(response => {
this.latestVersionId = response.data;
this.getVersionHistory();
});
},
getVersionHistory() {
getDefinitionVersions(this.basisData.id).then((response) => {
if (this.basisData.isCopy) {
@ -347,6 +360,12 @@ export default {
} else {
this.versionData = response.data;
}
let latestVersionData = response.data.filter((v) => v.versionId === this.latestVersionId);
if (latestVersionData.length > 0) {
this.hasLatest = false
} else {
this.hasLatest = true;
}
});
},
compare(row) {
@ -500,7 +519,7 @@ export default {
this.$set(this.basisData, 'newVersionCase', this.basisData.caseTotal > 0);
createMockConfig({
projectId: this.projectId,
projectId: getCurrentProjectID(),
apiId: this.basisData.id,
}).then((response) => {
this.$set(this.basisData, 'newVersionMock', response.data.mockExpectConfigList.length > 0);
@ -534,6 +553,18 @@ export default {
},
});
},
setLatest(row) {
let param = {
projectId: getCurrentProjectID(),
type: 'API',
versionId: row.id,
resourceId: this.basisData.id
}
setLatestVersionById(param).then(() => {
this.$success(this.$t('commons.modify_success'));
this.checkout(row);
});
},
},
};
</script>

View File

@ -1,10 +1,14 @@
import {get} from "../plugins/request"
import {get, post} from "../plugins/request"
import {hasLicense} from "../utils/permission";
export function getProjectVersions(projectId) {
return get(`/project/version/get-project-versions/${projectId}`);
}
export function getDefaultVersion(projectId) {
return get(`/project/version/get-default-version/${projectId}`);
}
export function getProjectMembers() {
return get('/user/project/member/list');
}
@ -13,6 +17,10 @@ export function isProjectVersionEnable(projectId) {
return get(`/project/version/enable/${projectId}`)
}
export function setLatestVersionById(data) {
return post('/project/version/set/latest/version', data)
}
export function getVersionFilters(projectId) {
return hasLicense() && projectId ? new Promise((resolve) => {
getProjectVersions(projectId)

View File

@ -70,6 +70,7 @@ export default {
{
type: 'pie',
radius: this.radius,
minAngle: 3,
itemStyle: {
borderRadius: 0,
borderColor: '#fff',
@ -77,7 +78,7 @@ export default {
},
label: {
show: false,
position:'outside',
position: 'outside',
formatter: '{c}, {d}%',
},
center: ['126', '128'],
@ -270,15 +271,16 @@ export default {
}
},
data:this.pieData,
formatter:function(name){
formatter:function(name) {
//name
let singleData = self.pieData.filter(function(item){
return item.name === name
})
if (!singleData[0].value) {
singleData[0].value = 0;
let singleData = self.pieData.filter(function (item) {
return item.name === name;
});
let showValue = singleData[0].value;
if (showValue === '-') {
showValue = 0;
}
return [`{name|${name}}`, `{num|${singleData[0].value}}`].join("");
return [`{name|${name}}`, `{num|${showValue}}`].join('');
}
};
})

View File

@ -51,6 +51,11 @@
<el-link @click="del(scope.row)" v-if="scope.row.isCheckout" :disabled="scope.row.isCurrent || isRead">
{{ $t('commons.delete') }}&nbsp;
</el-link>
<el-link @click="setLatest(scope.row)" v-if="hasLatest && !scope.row.isCurrent && scope.row.isCheckout"
:disabled="scope.row.isCurrent || isRead">
{{ $t('project.version.set_new') }}&nbsp;
</el-link>
</template>
</el-table-column>
</el-table>
@ -66,7 +71,7 @@
import {getCurrentProjectID} from "../../utils/token";
import {hasLicense} from "../../utils/permission";
import {getProjectMembers, getProjectVersions, isProjectVersionEnable} from "../../api/version";
import {getDefaultVersion, getProjectMembers, getProjectVersions, isProjectVersionEnable} from "../../api/version";
export default {
name: "MxVersionHistory",
@ -88,7 +93,11 @@ export default {
default() {
return getCurrentProjectID();
}
}
},
hasLatest: {
type: Boolean,
default: false
},
},
data() {
return {
@ -144,6 +153,10 @@ export default {
this.loading = true;
this.$emit('del', row);
},
setLatest(row) {
this.loading = true;
this.$emit('setLatest', row);
},
handleVersionOptions() {
let versionData = this.versionData;
if (versionData.length === 0) {

View File

@ -888,6 +888,7 @@ const message = {
delete_tip: 'This version has associated system resources, this operation will delete the associated resources',
checkout: 'Checkout',
compare: 'Compare',
set_new: 'SetNew',
change_latest_tip: 'This operation will modify the default display of the interface, scene, test case and other list pages, which may take some time. Please wait! '
},
project_file: {
@ -1914,8 +1915,8 @@ const message = {
no_cover_tip_scenario_1: "1. The same Scenario that already exists in the system will not be changed",
no_cover_tip_scenario_2: "2. Add Scenario that do not exist in the system",
import_version: 'Import version',
data_update_version: 'Api update version',
data_new_version: 'Api creation version',
data_update_version: 'New API created to',
data_new_version: 'The same API is updated to',
latest_version: 'Latest version',
},
home_page: {

View File

@ -897,6 +897,7 @@ const message = {
delete_tip: '此版本已经关联系统资源,此操作会将所关联的资源一并删除',
checkout: '切换',
compare: '对比',
set_new: '置新',
change_latest_tip: '此操作会修改接口,场景,测试用例等列表页面的默认展示,可能会消耗一些时间。请耐心等待!'
},
project_file: {
@ -1923,8 +1924,8 @@ const message = {
no_cover_tip_scenario_1: "1. 系统已存在的同一场景,则不做变更",
no_cover_tip_scenario_2: "2. 系统不存在的场景则新增",
import_version: '导入版本',
data_update_version: '数据更新版本',
data_new_version: '数据创建版本',
data_update_version: '同一API更新到',
data_new_version: '新增API创建到',
latest_version: '最新版本',
},
home_page: {

View File

@ -893,6 +893,7 @@ const message = {
delete_tip: '此版本已經關聯繫統資源,此操作會將所關聯的資源一併刪除',
checkout: '切換',
compare: '對比',
set_new: '置新',
change_latest_tip: '此操作會修改接口,場景,測試用例等列表頁面的默認展示,可能會消耗一些時間。請耐心等待! '
},
project_file: {
@ -1919,8 +1920,8 @@ const message = {
no_cover_tip_1: "1. 系統已存在的同一介面,則不做變更",
no_cover_tip_2: "2. 系統不存在的介面則新增",
import_version: '導入版本',
data_update_version: '數據更新版本',
data_new_version: '數據創建版本',
data_update_version: '同一API更新到',
data_new_version: '新增API創建到',
latest_version: '最新版本',
},
home_page: {

View File

@ -16,4 +16,8 @@ public class ProjectVersionRequest {
private List<OrderRequest> orders;
private Map<String, List<String>> filters;
private Map<String, Object> combine;
private String type;
private String versionId;
private String resourceId;
}

View File

@ -22,4 +22,6 @@ public interface ProjectVersionService {
void changeStatus(String id, String status);
List<ProjectVersion> getProjectVersionByIds(List<String> versionIds);
void setLatestVersionById(ProjectVersionRequest request);
}

View File

@ -34,6 +34,8 @@
:version-data="versionData"
:current-id="testId"
:is-read="isReadOnly"
:has-latest="hasLatest"
@setLatest="setLatest"
@compare="compare" @checkout="checkout" @create="create" @del="del"/>
<el-button :disabled="isReadOnly" type="primary" size="small" plain @click="save"
v-permission="['PROJECT_PERFORMANCE_TEST:READ+EDIT']"
@ -123,6 +125,7 @@ import {
saveTest,
syncScenario
} from "@/api/performance";
import {getDefaultVersion, setLatestVersionById} from 'metersphere-frontend/src/api/version';
export default {
name: "EditPerformanceTest",
@ -173,6 +176,8 @@ export default {
maintainerOptions: [],
versionData: [],
projectEnvMap: {},
latestVersionId: '',
hasLatest: false
};
},
watch: {
@ -199,7 +204,7 @@ export default {
this.isReadOnly = !hasPermission('PROJECT_PERFORMANCE_TEST:READ+EDIT');
this.getTest(this.$route.params.testId);
if (hasLicense()) {
this.getVersionHistory();
this.getDefaultVersion();
}
this.$EventBus.$on('projectChange', this.handleProjectChange);
},
@ -592,6 +597,13 @@ export default {
}
}
},
getDefaultVersion() {
getDefaultVersion(getCurrentProjectID())
.then(response => {
this.latestVersionId = response.data;
this.getVersionHistory();
});
},
getVersionHistory() {
let testId = undefined;
if (this.testId) {
@ -600,6 +612,12 @@ export default {
getTestVersionHistory(testId)
.then(response => {
this.versionData = response.data;
let latestVersionData = response.data.filter((v) => v.versionId === this.latestVersionId);
if (latestVersionData.length > 0) {
this.hasLatest = false
} else {
this.hasLatest = true;
}
});
},
compare(row) {
@ -661,6 +679,18 @@ export default {
}
});
},
setLatest(row) {
let param = {
projectId: getCurrentProjectID(),
type: 'PERFORMANCE',
versionId: row.id,
resourceId: this.test.id
}
setLatestVersionById(param).then(() => {
this.$success(this.$t('commons.modify_success'));
this.checkout(row);
});
},
handleProjectChange() {
if (this.$route.path.startsWith('/performance/test/edit')) {
this.$nextTick(() => {

View File

@ -46,6 +46,8 @@
:is-read="currentTestCaseInfo.trashEnable || readOnly"
@confirmOtherInfo="confirmOtherInfo"
:current-project-id="currentProjectId"
:has-latest="hasLatest"
@setLatest="setLatest"
@compare="compare" @checkout="checkout" @create="create" @del="del"/>
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand"
@command="handleCommand" size="small" style="float: right;margin-right: 20px"
@ -192,6 +194,7 @@ import {
import {getProjectListAll, getProjectMemberOption} from "@/business/utils/sdk-utils";
import {testCaseCommentList} from "@/api/test-case-comment";
import {getDefaultVersion, setLatestVersionById} from 'metersphere-frontend/src/api/version';
export default {
name: "TestCaseEdit",
@ -306,7 +309,9 @@ export default {
selectedOtherInfo: null,
currentProjectId: "",
casePublic: false,
isClickAttachmentTab: false
isClickAttachmentTab: false,
latestVersionId: '',
hasLatest: false
};
},
props: {
@ -800,7 +805,7 @@ export default {
//
if (hasLicense()) {
this.getVersionHistory();
this.getDefaultVersion();
}
}).catch(() => {
this.loading = false;
@ -990,6 +995,13 @@ export default {
});
}
},
getDefaultVersion() {
getDefaultVersion(this.projectId)
.then(response => {
this.latestVersionId = response.data;
this.getVersionHistory();
});
},
getVersionHistory() {
getTestCaseVersions(this.currentTestCaseInfo.id)
.then(response => {
@ -1001,6 +1013,12 @@ export default {
this.currentProjectId = getCurrentProjectID();
}
this.versionData = response.data;
let latestVersionData = response.data.filter((v) => v.versionId === this.latestVersionId);
if (latestVersionData.length > 0) {
this.hasLatest = false
} else {
this.hasLatest = true;
}
if (this.$refs.versionHistory) {
this.$refs.versionHistory.loading = false;
}
@ -1122,16 +1140,28 @@ export default {
}
});
},
setLatest(row) {
let param = {
projectId: getCurrentProjectID(),
type: 'TEST_CASE',
versionId: row.id,
resourceId: this.currentTestCaseInfo.id
}
setLatestVersionById(param).then(() => {
this.$success(this.$t('commons.modify_success'));
this.checkout(row);
});
},
hasOtherInfo() {
return new Promise((resolve) => {
if (this.form.id) {
hasTestCaseOtherInfo(this.form.id)
.then((res) => {
resolve(res.data);
});
} else {
resolve();
}
if (this.form.id) {
hasTestCaseOtherInfo(this.form.id)
.then((res) => {
resolve(res.data);
});
} else {
resolve();
}
}
);
},

View File

@ -4,7 +4,6 @@ import {hasLicense} from "metersphere-frontend/src/utils/permission";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {getUUID} from "metersphere-frontend/src/utils";
import {getCurrentProject} from "@/api/project";
import {JIRA} from "metersphere-frontend/src/utils/constants";
export function getJiraIssueType(param) {
return post('/issues/jira/issuetype', param);
@ -33,24 +32,27 @@ export function getDashboardIssues(page) {
export function getIssuePartTemplateWithProject(callback) {
getCurrentProject().then((response) => {
let currentProject = response.data;
if (enableThirdPartTemplate(currentProject)) {
getIssueThirdPartTemplate()
.then((template) => {
if (callback)
callback(template, currentProject);
});
} else {
getIssueTemplate()
.then((template) => {
if (callback)
callback(template, currentProject);
});
}
enableThirdPartTemplate(currentProject.id)
.then((r) => {
if (r.data) {
getIssueThirdPartTemplate()
.then((template) => {
if (callback)
callback(template, currentProject);
});
} else {
getIssueTemplate()
.then((template) => {
if (callback)
callback(template, currentProject);
});
}
});
});
}
export function enableThirdPartTemplate(currentProject) {
return currentProject && currentProject.thirdPartTemplate && currentProject.platform === JIRA;
export function enableThirdPartTemplate(projectId) {
return get('/issues/third/part/template/enable/' + projectId);
}
export function getIssueThirdPartTemplate() {
@ -76,3 +78,7 @@ export function getIssuesWeekCount(workstationId) {
return get('/workstation/issue/week/count/'+workstationId);
}
export function getPlatformOption() {
return get( '/issues/platform/option');
}

View File

@ -157,7 +157,7 @@ import MsTableButton from "metersphere-frontend/src/components/MsTableButton";
import MsTablePagination from "metersphere-frontend/src/components/pagination/TablePagination";
import {ISSUE_PLATFORM_OPTION, ISSUE_STATUS_MAP, SYSTEM_FIELD_NAME_MAP} from "metersphere-frontend/src/utils/table-constants";
import MsTableHeader from "metersphere-frontend/src/components/MsTableHeader";
import {getDashboardIssues, getIssuePartTemplateWithProject, getIssues} from "@/api/issue";
import {getDashboardIssues, getIssuePartTemplateWithProject, getIssues, getPlatformOption} from "@/api/issue";
import {
getCustomFieldValue,
getCustomTableWidth,
@ -192,10 +192,14 @@ export default {
issueTemplate: {},
members: [],
isThirdPart: false,
platformOptions: [],
};
},
activated() {
getPlatformOption()
.then((r) => {
this.platformOptions = r.data;
});
},
props: {
isFocus: {
@ -227,7 +231,9 @@ export default {
},
computed: {
platformFilters() {
return ISSUE_PLATFORM_OPTION;
let options = [...ISSUE_PLATFORM_OPTION];
options.push(...this.platformOptions);
return options;
},
issueStatusMap() {
return ISSUE_STATUS_MAP;

View File

@ -43,26 +43,26 @@ export default{
this.result = getMyCreatedCaseGroupContMap(isWeek).then(response => {
let tableData = response.data
const testCaseCount = {
value:tableData.testCaseCount===0?'':tableData.testCaseCount,
name:this.$t('workstation.table_name.track_case'),
value: tableData.testCaseCount === 0 ? '-' : tableData.testCaseCount,
name: this.$t('workstation.table_name.track_case'),
}
this.loadCharData.push(testCaseCount)
const apiTestCaseCount = {
value:tableData.apiTestCaseCount===0?'':tableData.apiTestCaseCount,
name:this.$t('workstation.table_name.api_case'),
value: tableData.apiTestCaseCount === 0 ? '-' : tableData.apiTestCaseCount,
name: this.$t('workstation.table_name.api_case'),
}
this.loadCharData.push(apiTestCaseCount)
const apiScenarioCaseCount = {
value:tableData.apiScenarioCaseCount===0?'':tableData.apiScenarioCaseCount,
name:this.$t('workstation.table_name.scenario_case'),
value: tableData.apiScenarioCaseCount === 0 ? '-' : tableData.apiScenarioCaseCount,
name: this.$t('workstation.table_name.scenario_case'),
}
this.loadCharData.push(apiScenarioCaseCount)
const loadTestCount = {
value:tableData.loadTestCount===0?'':tableData.loadTestCount,
name:this.$t('test_track.plan.load_case.case'),
value: tableData.loadTestCount === 0 ? '-' : tableData.loadTestCount,
name: this.$t('test_track.plan.load_case.case'),
}
this.loadCharData.push(loadTestCount)