Skip to content

Commit

Permalink
fix(项目设置): 修复编辑环境提示请输入名称的缺陷
Browse files Browse the repository at this point in the history
--bug=1026466 --user=王孝刚 【项目设置】编辑环境-提示请输入名称-实际已经有名称
https://www.tapd.cn/55049933/s/1375017
  • Loading branch information
wxg0103 authored and fit2-zhao committed May 29, 2023
1 parent d5e9d3d commit 29a054f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.dto.*;
import io.metersphere.service.ProjectApplicationService;
import io.metersphere.service.QuotaService;
import io.metersphere.service.SystemParameterService;
import io.metersphere.utils.LoggerUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.ResponseEntity;
Expand All @@ -21,6 +23,7 @@

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

@Service
Expand Down Expand Up @@ -89,15 +92,27 @@ public void verifyPool(String projectId, RunModeConfigDTO runConfig) {
LoggerUtil.info("校验项目为:【" + projectId + "】", runConfig.getReportId());
ProjectConfig config = projectApplicationService.getProjectConfig(projectId);
List<TestResourcePoolDTO> poolList = systemParameterService.getTestResourcePool();

QuotaService baseQuotaService = CommonBeanFactory.getBean(QuotaService.class);
Set<String> poolSets = baseQuotaService.getQuotaResourcePools();
if (CollectionUtils.isNotEmpty(poolSets)) {
poolList = poolList.stream().filter(pool -> poolSets.contains(pool.getId())).collect(Collectors.toList());
}

if (CollectionUtils.isEmpty(poolList)) {
MSException.throwException("请在【项目设置-应用管理-接口测试】中选择资源池");
}

boolean contains = poolList.stream().map(TestResourcePoolDTO::getId)
.collect(Collectors.toList()).contains(config.getResourcePoolId());
.collect(Collectors.toList()).contains(config.getResourcePoolId()) && BooleanUtils.isTrue(config.getPoolEnable());

if (StringUtils.isEmpty(config.getResourcePoolId()) || !contains || BooleanUtils.isFalse(config.getPoolEnable())) {
String id = systemParameterService.filterQuota(poolList);
if (StringUtils.isBlank(id)) {
MSException.throwException("请在【项目设置-应用管理-接口测试】中选择资源池");
if (!contains) {
List<TestResourcePoolDTO> pools = poolList.stream().filter(pool ->
StringUtils.equals(pool.getName(), "LOCAL")).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(pools)) {
config.setResourcePoolId(pools.get(0).getId());
} else {
config.setResourcePoolId(id);
config.setResourcePoolId(poolList.get(0).getId());
}
}
runConfig = runConfig == null ? new RunModeConfigDTO() : runConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,19 +286,6 @@ public void saveBaseInfo(List<SystemParameter> parameters) {
SystemParameterExample example = new SystemParameterExample();

parameters.forEach(param -> {
if (param.getParamKey().equals("base.concurrency")) {
if (StringUtils.isNotEmpty(param.getParamValue())) {
try {
int poolSize = Integer.parseInt(param.getParamValue());
if (poolSize > 10000) {
MSException.throwException("并发数设置太大,请重新设置");
}
CommonBeanFactory.getBean(ExecThreadPoolExecutor.class).setCorePoolSize(poolSize);
} catch (Exception e) {
MSException.throwException("并发数设置不规范,请重新设置");
}
}
}
// 去掉路径最后的 /
param.setParamValue(StringUtils.removeEnd(param.getParamValue(), "/"));
if (StringUtils.equals(param.getParamKey(), "base.url")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</el-card>

<!-- 创建、编辑、复制环境时的对话框 -->
<el-dialog :visible.sync="dialogVisible" :close-on-click-modal="false" width="66%" top="50px">
<el-dialog :visible.sync="dialogVisible" :close-on-click-modal="false" width="66%" top="50px" destroy-on-close>
<template #title>
<ms-dialog-header :title="dialogTitle" :hide-button="true"
@cancel="dialogVisible = false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
<el-input v-model="formInline.url" :placeholder="$t('system_config.base.url_tip')"/>
<i>({{ $t('commons.examples') }}:https://rdmetersphere.fit2cloud.com)</i>
</el-form-item>
<el-form-item :label="$t('report.max_users')" prop="concurrency">
<el-input v-model="formInline.concurrency" :placeholder="$t('report.max_users')"/>
</el-form-item>
<el-form-item :label="$t('system_config.prometheus.host')" prop="prometheusHost">
<el-input v-model="formInline.prometheusHost" :placeholder="$t('system_config.prometheus.host_tip')"/>
<i>({{ $t('commons.examples') }}:http://ms-prometheus:9090)</i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</el-card>

<!-- 创建、编辑、复制环境时的对话框 -->
<el-dialog :visible.sync="dialogVisible" :close-on-click-modal="false" top="50px" width="66%">
<el-dialog :visible.sync="dialogVisible" :close-on-click-modal="false" top="50px" width="66%" destroy-on-close>
<template #title>
<ms-dialog-header :title="dialogTitle"
@cancel="dialogVisible = false"
Expand Down

0 comments on commit 29a054f

Please sign in to comment.