fix(项目设置): 修复编辑环境提示请输入名称的缺陷

--bug=1026466 --user=王孝刚 【项目设置】编辑环境-提示请输入名称-实际已经有名称
https://www.tapd.cn/55049933/s/1375017
This commit is contained in:
wxg0103 2023-05-24 14:22:46 +08:00 committed by fit2-zhao
parent d5e9d3da54
commit 29a054f0ca
5 changed files with 24 additions and 25 deletions

View File

@ -11,8 +11,10 @@ import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.dto.*; import io.metersphere.dto.*;
import io.metersphere.service.ProjectApplicationService; import io.metersphere.service.ProjectApplicationService;
import io.metersphere.service.QuotaService;
import io.metersphere.service.SystemParameterService; import io.metersphere.service.SystemParameterService;
import io.metersphere.utils.LoggerUtil; import io.metersphere.utils.LoggerUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -21,6 +23,7 @@ import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@ -89,15 +92,27 @@ public class ApiPoolDebugService {
LoggerUtil.info("校验项目为:【" + projectId + "", runConfig.getReportId()); LoggerUtil.info("校验项目为:【" + projectId + "", runConfig.getReportId());
ProjectConfig config = projectApplicationService.getProjectConfig(projectId); ProjectConfig config = projectApplicationService.getProjectConfig(projectId);
List<TestResourcePoolDTO> poolList = systemParameterService.getTestResourcePool(); 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())) { QuotaService baseQuotaService = CommonBeanFactory.getBean(QuotaService.class);
String id = systemParameterService.filterQuota(poolList); Set<String> poolSets = baseQuotaService.getQuotaResourcePools();
if (StringUtils.isBlank(id)) { if (CollectionUtils.isNotEmpty(poolSets)) {
MSException.throwException("请在【项目设置-应用管理-接口测试】中选择资源池"); 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 { } else {
config.setResourcePoolId(id); config.setResourcePoolId(poolList.get(0).getId());
} }
} }
runConfig = runConfig == null ? new RunModeConfigDTO() : runConfig; runConfig = runConfig == null ? new RunModeConfigDTO() : runConfig;

View File

@ -286,19 +286,6 @@ public class SystemParameterService {
SystemParameterExample example = new SystemParameterExample(); SystemParameterExample example = new SystemParameterExample();
parameters.forEach(param -> { 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(), "/")); param.setParamValue(StringUtils.removeEnd(param.getParamValue(), "/"));
if (StringUtils.equals(param.getParamKey(), "base.url")) { if (StringUtils.equals(param.getParamKey(), "base.url")) {

View File

@ -59,7 +59,7 @@
</el-card> </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> <template #title>
<ms-dialog-header :title="dialogTitle" :hide-button="true" <ms-dialog-header :title="dialogTitle" :hide-button="true"
@cancel="dialogVisible = false" @cancel="dialogVisible = false"

View File

@ -8,9 +8,6 @@
<el-input v-model="formInline.url" :placeholder="$t('system_config.base.url_tip')"/> <el-input v-model="formInline.url" :placeholder="$t('system_config.base.url_tip')"/>
<i>({{ $t('commons.examples') }}:https://rdmetersphere.fit2cloud.com)</i> <i>({{ $t('commons.examples') }}:https://rdmetersphere.fit2cloud.com)</i>
</el-form-item> </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-form-item :label="$t('system_config.prometheus.host')" prop="prometheusHost">
<el-input v-model="formInline.prometheusHost" :placeholder="$t('system_config.prometheus.host_tip')"/> <el-input v-model="formInline.prometheusHost" :placeholder="$t('system_config.prometheus.host_tip')"/>
<i>({{ $t('commons.examples') }}:http://ms-prometheus:9090)</i> <i>({{ $t('commons.examples') }}:http://ms-prometheus:9090)</i>

View File

@ -64,7 +64,7 @@
</el-card> </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> <template #title>
<ms-dialog-header :title="dialogTitle" <ms-dialog-header :title="dialogTitle"
@cancel="dialogVisible = false" @cancel="dialogVisible = false"