diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index bb4d054465..64b03f08a4 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -353,7 +353,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { if (StringUtils.isNotEmpty(useEvnId) && !StringUtils.equals(useEvnId, this.getEnvironmentId())) { this.setEnvironmentId(useEvnId); } - HttpConfig httpConfig = getHttpConfig(config.getConfig().get(this.getProjectId()).getHttpConfig()); + HttpConfig httpConfig = matchConfig(config); httpConfig.setPreProcessor(environmentConfig.getPreProcessor()); httpConfig.setPostProcessor(environmentConfig.getPostProcessor()); return httpConfig; @@ -725,10 +725,11 @@ public class MsHTTPSamplerProxy extends MsTestElement { /** * 按照环境规则匹配环境 * - * @param httpConfig + * @param parameterConfig * @return */ - private HttpConfig getHttpConfig(HttpConfig httpConfig) { + private HttpConfig matchConfig(ParameterConfig parameterConfig) { + HttpConfig httpConfig = parameterConfig.getConfig().get(this.getProjectId()).getHttpConfig(); boolean isNext = true; if (CollectionUtils.isNotEmpty(httpConfig.getConditions())) { for (HttpConfigCondition item : httpConfig.getConditions()) { diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/HttpConfig.java b/backend/src/main/java/io/metersphere/api/dto/scenario/HttpConfig.java index 5f9fa79c6d..dc1dd68fe6 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/HttpConfig.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/HttpConfig.java @@ -2,11 +2,16 @@ package io.metersphere.api.dto.scenario; import io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor; import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor; +import io.metersphere.base.domain.ApiModule; +import io.metersphere.base.domain.ApiModuleExample; +import io.metersphere.base.mapper.ApiModuleMapper; import io.metersphere.commons.utils.BeanUtils; +import io.metersphere.commons.utils.CommonBeanFactory; import lombok.Data; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -24,6 +29,8 @@ public class HttpConfig { private MsJSR223PreProcessor preProcessor; private MsJSR223PostProcessor postProcessor; + private ApiModuleMapper apiModuleMapper; + public HttpConfig initHttpConfig(HttpConfigCondition configCondition) { HttpConfig config = new HttpConfig(); config.isMock = this.isMock; @@ -42,10 +49,33 @@ public class HttpConfig { return null; } + private void getAllChild(String moduleId, List allChild) { + // 找出所有子模块 + if (apiModuleMapper == null) { + apiModuleMapper = CommonBeanFactory.getBean(ApiModuleMapper.class); + } + allChild.add(moduleId); + ApiModuleExample example = new ApiModuleExample(); + example.createCriteria().andParentIdEqualTo(moduleId); + List modules = apiModuleMapper.selectByExample(example); + for (ApiModule module : modules) { + getAllChild(module.getId(), allChild); + } + } + public HttpConfig getModuleCondition(String moduleId, HttpConfigCondition configCondition) { + List moduleIds = new ArrayList<>(); if (CollectionUtils.isNotEmpty(configCondition.getDetails())) { - List details = configCondition.getDetails().stream().filter(detail -> StringUtils.contains(detail.getValue(), moduleId)).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(details)) { + if (CollectionUtils.isEmpty(configCondition.getModuleIds())) { + for (KeyValue keyValue : configCondition.getDetails()) { + getAllChild(keyValue.getValue(), moduleIds); + } + configCondition.setModuleIds(moduleIds); + } else { + moduleIds = configCondition.getModuleIds(); + } + + if (moduleIds.contains(moduleId)) { return initHttpConfig(configCondition); } } diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/HttpConfigCondition.java b/backend/src/main/java/io/metersphere/api/dto/scenario/HttpConfigCondition.java index 06805a1477..144da98354 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/HttpConfigCondition.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/HttpConfigCondition.java @@ -13,4 +13,6 @@ public class HttpConfigCondition { private String domain; private int port; private List headers; + + private List moduleIds; } diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 4083bd0ba2..9be63e288d 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -196,7 +196,7 @@ highlight-current @node-expand="nodeExpand" @node-collapse="nodeCollapse" - :allow-drop="allowDrop" @node-drag-end="allowDrag" @node-click="nodeClick" v-if="!loading" draggable ref="stepTree"> + :allow-drop="allowDrop" @node-drag-end="allowDrag" @node-click="nodeClick" draggable ref="stepTree"> d.resourceId !== undefined && row.resourceId !== undefined && d.resourceId === row.resourceId) hashTree.splice(index, 1); this.sort(); - this.reload(); } } }); @@ -1060,7 +1059,6 @@ export default { hashTree.push(obj); } this.sort(); - this.reload(); }, reload() { this.loading = true diff --git a/frontend/src/business/components/api/definition/components/debug/DebugDubboPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugDubboPage.vue index d7493328a3..a77c926376 100644 --- a/frontend/src/business/components/api/definition/components/debug/DebugDubboPage.vue +++ b/frontend/src/business/components/api/definition/components/debug/DebugDubboPage.vue @@ -5,9 +5,6 @@ {{ $t('commons.test') }} - - {{ $t('report.stop_btn') }} - {{ $t('commons.test') }} @@ -15,6 +12,9 @@ {{ $t('api_test.definition.request.save_as_case') }} + + {{ $t('report.stop_btn') }} +

{{ $t('api_test.definition.request.req_param') }}

diff --git a/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue index 20b1990ba8..f05587a06b 100644 --- a/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue +++ b/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue @@ -5,9 +5,6 @@ {{ $t('commons.test') }} - - {{ $t('report.stop_btn') }} - {{ $t('commons.test') }} @@ -15,6 +12,9 @@ {{ $t('api_test.definition.request.save_as_case') }} + + {{ $t('report.stop_btn') }} +

{{ $t('api_test.definition.request.req_param') }}

diff --git a/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue index ad1202a8c1..1c848b42aa 100644 --- a/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue +++ b/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue @@ -13,9 +13,6 @@ {{ $t('commons.test') }} - - {{ $t('report.stop_btn') }} - {{ $t('commons.test') }} @@ -24,6 +21,9 @@ + + {{ $t('report.stop_btn') }} +