fix(项目设置): 修复开启TCP Mock时,默认端口号为0未随机一个可用端口号的问题

--bug=1014028 --user=宋天阳 【接口测试】开启TCP
Mock时,默认端口号为0未随机一个可用端口号
{#_orginal_url#}
This commit is contained in:
song-tianyang 2022-06-14 16:56:35 +08:00 committed by f2c-ci-robot[bot]
parent b0859ef84c
commit 884abde6e5
5 changed files with 57 additions and 43 deletions

View File

@ -569,7 +569,7 @@ public class ProjectService {
.andTypeValueEqualTo(String.valueOf(project.getMockTcpPort())) .andTypeValueEqualTo(String.valueOf(project.getMockTcpPort()))
.andProjectIdNotEqualTo(projectId); .andProjectIdNotEqualTo(projectId);
if (projectApplicationMapper.countByExample(example) > 0) { if (projectApplicationMapper.countByExample(example) > 0) {
MSException.throwException("TCP Port is not unique"); MSException.throwException(Translator.get("tcp_mock_not_unique"));
} }
} }
} }
@ -958,7 +958,7 @@ public class ProjectService {
} }
} }
if (returnPort == 0) { if (returnPort == 0) {
MSException.throwException("无可用TCP端口"); MSException.throwException(Translator.get("no_tcp_mock_port"));
} }
return String.valueOf(returnPort); return String.valueOf(returnPort);
} }

View File

@ -313,25 +313,24 @@ count=Count
cannot_find_project=Cannot find project cannot_find_project=Cannot find project
project_repeatable_is_false=Url repeatable not open project_repeatable_is_false=Url repeatable not open
#环境组 #环境组
null_environment_group_name = Environment group name is null null_environment_group_name=Environment group name is null
environment_group_name = Environment group name environment_group_name=Environment group name
environment_group_exist = already exists environment_group_exist=already exists
environment_group_has_duplicate_project=Environment group has duplicate project environment_group_has_duplicate_project=Environment group has duplicate project
#误报库 #误报库
error_report_library=Error report error_report_library=Error report
issue_jira_info_error=Check the service integration information or Jira project ID issue_jira_info_error=Check the service integration information or Jira project ID
error_code_is_unique=Error code is not unique error_code_is_unique=Error code is not unique
no_version_exists=version not exists no_version_exists=version not exists
jira_auth_error=Account name or password (Token) is wrong jira_auth_error=Account name or password (Token) is wrong
jira_auth_url_error=The test connection failed, please check whether the Jira address is correct jira_auth_url_error=The test connection failed, please check whether the Jira address is correct
#ui 指令校驗 #ui 指令校驗
param_error=Param Error param_error=Param Error
is_null= can't be null is_null=can't be null
url_is_null= URL can't be null url_is_null=URL can't be null
frame_index_is_null= frame index can't be null frame_index_is_null=frame index can't be null
element_is_null= element can't be null element_is_null=element can't be null
locator_is_null= locator can't be null locator_is_null=locator can't be null
coord=coord coord=coord
input_content=input input_content=input
subitem_type=subitem type subitem_type=subitem type
@ -374,4 +373,6 @@ cmdElseIf=ElseIf
close=close close=close
cmdExtraction=extracion cmdExtraction=extracion
cmdExtractWindow=window extraction cmdExtractWindow=window extraction
cmdExtractElement=element extraction cmdExtractElement=element extraction
tcp_mock_not_unique=This tcp port is be used
no_tcp_mock_port=No idle tcp port, please contact administrators.

View File

@ -312,9 +312,9 @@ count=统计
cannot_find_project=未找到测试项目 cannot_find_project=未找到测试项目
project_repeatable_is_false=项目未配置URL可重复 project_repeatable_is_false=项目未配置URL可重复
#环境组 #环境组
null_environment_group_name = 环境组名称不存在 null_environment_group_name=环境组名称不存在
environment_group_name = 环境组名称 environment_group_name=环境组名称
environment_group_exist = 已存在 environment_group_exist=已存在
environment_group_has_duplicate_project=每个项目只能选择一个环境! environment_group_has_duplicate_project=每个项目只能选择一个环境!
#误报库 #误报库
error_report_library=误报库 error_report_library=误报库
@ -325,11 +325,11 @@ jira_auth_error=账号名或密码(Token)错误
jira_auth_url_error=测试连接失败请检查Jira地址是否正确 jira_auth_url_error=测试连接失败请检查Jira地址是否正确
#ui 指令校验 #ui 指令校验
param_error=参数校验失败!请检查 param_error=参数校验失败!请检查
is_null= 不能为空 is_null=不能为空
url_is_null= URL 参数不能为空 url_is_null=URL 参数不能为空
frame_index_is_null= 网页索引号不能为空 frame_index_is_null=网页索引号不能为空
element_is_null= 元素对象已经被删除 element_is_null=元素对象已经被删除
locator_is_null= 元素定位参数不能有空 locator_is_null=元素定位参数不能有空
coord=坐标 coord=坐标
input_content=输入内容 input_content=输入内容
subitem_type=子选项类型 subitem_type=子选项类型
@ -372,4 +372,6 @@ cmdElseIf=ElseIf
close=关闭网页 close=关闭网页
cmdExtraction=数据提取 cmdExtraction=数据提取
cmdExtractWindow=提取窗口信息 cmdExtractWindow=提取窗口信息
cmdExtractElement=提取元素信息 cmdExtractElement=提取元素信息
tcp_mock_not_unique=该TCP端口号已被使用
no_tcp_mock_port=无可用的TCP端口号请联系管理员

View File

@ -311,25 +311,24 @@ count=統計
cannot_find_project=未找到測試項目 cannot_find_project=未找到測試項目
project_repeatable_is_false=項目未配置URL可重複 project_repeatable_is_false=項目未配置URL可重複
#环境组 #环境组
null_environment_group_name = 環境組名稱不存在 null_environment_group_name=環境組名稱不存在
environment_group_name = 環境組名稱 environment_group_name=環境組名稱
environment_group_exist = 已存在 environment_group_exist=已存在
environment_group_has_duplicate_project=每個項目只能選擇一個環境! environment_group_has_duplicate_project=每個項目只能選擇一個環境!
#误报库 #误报库
error_report_library=誤報庫 error_report_library=誤報庫
issue_jira_info_error=請檢查服務集成信息或Jira項目ID issue_jira_info_error=請檢查服務集成信息或Jira項目ID
error_code_is_unique=錯誤代碼不可重複 error_code_is_unique=錯誤代碼不可重複
no_version_exists=不存在版本!請先創建項目的版本 no_version_exists=不存在版本!請先創建項目的版本
jira_auth_error=賬號名或密碼(Token)錯誤 jira_auth_error=賬號名或密碼(Token)錯誤
jira_auth_url_error=測試連接失敗請檢查Jira地址是否正確 jira_auth_url_error=測試連接失敗請檢查Jira地址是否正確
#ui 指令校驗 #ui 指令校驗
param_error=參數校驗失敗!請檢查 param_error=參數校驗失敗!請檢查
is_null= 不能為空 is_null=不能為空
url_is_null= URL 參數不能為空 url_is_null=URL 參數不能為空
frame_index_is_null= 網頁索引號不能為空 frame_index_is_null=網頁索引號不能為空
element_is_null= 元素對象已經被刪除 element_is_null=元素對象已經被刪除
locator_is_null= 元素定位參數不能有空 locator_is_null=元素定位參數不能有空
coord=坐標 coord=坐標
input_content=輸入內容 input_content=輸入內容
subitem_type=子選項類型 subitem_type=子選項類型
@ -372,4 +371,6 @@ cmdElseIf=ElseIf
close=關閉網頁 close=關閉網頁
cmdExtraction=數據提取 cmdExtraction=數據提取
cmdExtractWindow=提取窗口信息 cmdExtractWindow=提取窗口信息
cmdExtractElement=提取元素信息 cmdExtractElement=提取元素信息
tcp_mock_not_unique=該TCP端口號已被使用
no_tcp_mock_port=無可用的TCP端口號請聯繫管理員

View File

@ -66,7 +66,7 @@
</template> </template>
<template #append> <template #append>
<el-switch v-model="config.mockTcpOpen" <el-switch v-model="config.mockTcpOpen"
@change="switchChange('MOCK_TCP_OPEN', $event, ['MOCK_TCP_PORT', config.mockTcpPort])"></el-switch> @change="tcpMockSwitchChange($event, ['MOCK_TCP_PORT', config.mockTcpPort])"></el-switch>
</template> </template>
</app-manage-item> </app-manage-item>
<timing-item ref="apiTimingItem" :choose.sync="config.cleanApiReport" <timing-item ref="apiTimingItem" :choose.sync="config.cleanApiReport"
@ -74,8 +74,10 @@
@chooseChange="switchChange('CLEAN_API_REPORT', config.cleanApiReport, ['CLEAN_API_REPORT_EXPR', config.cleanApiReportExpr])" @chooseChange="switchChange('CLEAN_API_REPORT', config.cleanApiReport, ['CLEAN_API_REPORT_EXPR', config.cleanApiReportExpr])"
:title="$t('project.timing_clean_api_report')"/> :title="$t('project.timing_clean_api_report')"/>
<timing-item ref="trackTimingItem" :choose.sync="config.shareReport" <timing-item ref="trackTimingItem" :choose.sync="config.shareReport"
:expr.sync="config.apiShareReportTime" :share-link="true" :unit-options="applyUnitOptions" :expr.sync="config.apiShareReportTime" :share-link="true"
@chooseChange="switchChange('API_SHARE_REPORT_TIME', config.apiShareReportTime)" :title="$t('report.report_sharing_link')"/> :unit-options="applyUnitOptions"
@chooseChange="switchChange('API_SHARE_REPORT_TIME', config.apiShareReportTime)"
:title="$t('report.report_sharing_link')"/>
</el-row> </el-row>
</el-col> </el-col>
<el-col :span="8" :offset="4"> <el-col :span="8" :offset="4">
@ -100,9 +102,9 @@
</el-col> </el-col>
</el-row> </el-row>
</el-tab-pane> </el-tab-pane>
<!-- UI 测试 --> <!-- UI 测试 -->
<el-tab-pane v-if="isXpack" :label="$t('commons.ui_test')" name="ui_test" > <el-tab-pane v-if="isXpack" :label="$t('commons.ui_test')" name="ui_test">
<el-row style="margin-top: 10px"> <el-row style="margin-top: 10px">
<span style="font-weight:bold">{{ $t('commons.view_settings') }}</span> <span style="font-weight:bold">{{ $t('commons.view_settings') }}</span>
</el-row> </el-row>
@ -153,12 +155,7 @@
import MsContainer from "@/business/components/common/components/MsContainer"; import MsContainer from "@/business/components/common/components/MsContainer";
import MsMainContainer from "@/business/components/common/components/MsMainContainer"; import MsMainContainer from "@/business/components/common/components/MsMainContainer";
import { import {getCurrentProjectID, hasLicense,} from "@/common/js/utils";
getCurrentProjectID,
getCurrentUserId,
getCurrentWorkspaceId,
hasLicense,
} from "@/common/js/utils";
import AppManageItem from "@/business/components/project/menu/appmanage/AppManageItem"; import AppManageItem from "@/business/components/project/menu/appmanage/AppManageItem";
import TimingItem from "@/business/components/project/menu/appmanage/TimingItem"; import TimingItem from "@/business/components/project/menu/appmanage/TimingItem";
@ -225,6 +222,19 @@ export default {
}, },
}, },
methods: { methods: {
tcpMockSwitchChange(value, other) {
if (value && this.config.mockTcpPort === 0) {
this.result = this.$get('/project/genTcpMockPort/' + this.projectId, res => {
let port = res.data;
this.config.mockTcpPort = port;
this.$nextTick(() => {
this.switchChange("MOCK_TCP_OPEN", value, ['MOCK_TCP_PORT', this.config.mockTcpPort]);
})
});
} else {
this.switchChange("MOCK_TCP_OPEN", value, other);
}
},
switchChange(type, value, other) { switchChange(type, value, other) {
let configs = []; let configs = [];
if (other && value) { if (other && value) {
@ -247,7 +257,7 @@ export default {
if (res.data) { if (res.data) {
this.config = res.data; this.config = res.data;
this.config.shareReport = true; this.config.shareReport = true;
if(!this.config.uiQuickMenu){ if (!this.config.uiQuickMenu) {
this.config.uiQuickMenu = "server"; this.config.uiQuickMenu = "server";
} }
} }