fix(项目设置): 修复编辑环境提示请输入名称的缺陷
--bug=1026466 --user=王孝刚 【项目设置】编辑环境-提示请输入名称-实际已经有名称 https://www.tapd.cn/55049933/s/1375017
This commit is contained in:
parent
d5e9d3da54
commit
29a054f0ca
|
@ -11,8 +11,10 @@ import io.metersphere.commons.exception.MSException;
|
|||
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;
|
||||
|
@ -21,6 +23,7 @@ import org.springframework.web.client.RestTemplate;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
|
@ -89,15 +92,27 @@ public class ApiPoolDebugService {
|
|||
LoggerUtil.info("校验项目为:【" + projectId + "】", runConfig.getReportId());
|
||||
ProjectConfig config = projectApplicationService.getProjectConfig(projectId);
|
||||
List<TestResourcePoolDTO> poolList = systemParameterService.getTestResourcePool();
|
||||
boolean contains = poolList.stream().map(TestResourcePoolDTO::getId)
|
||||
.collect(Collectors.toList()).contains(config.getResourcePoolId());
|
||||
|
||||
if (StringUtils.isEmpty(config.getResourcePoolId()) || !contains || BooleanUtils.isFalse(config.getPoolEnable())) {
|
||||
String id = systemParameterService.filterQuota(poolList);
|
||||
if (StringUtils.isBlank(id)) {
|
||||
MSException.throwException("请在【项目设置-应用管理-接口测试】中选择资源池");
|
||||
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()) && BooleanUtils.isTrue(config.getPoolEnable());
|
||||
|
||||
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;
|
||||
|
|
|
@ -286,19 +286,6 @@ public class SystemParameterService {
|
|||
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")) {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue