From 8c5a6b2f0d9fc0acf656be7f872e6268a8c52155 Mon Sep 17 00:00:00 2001 From: aoshiguchen <1052045476@qq.com> Date: Thu, 31 Aug 2023 16:29:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=AB=AF=E5=8F=A3=E6=98=A0?= =?UTF-8?q?=E5=B0=84=E7=BC=96=E8=BE=91=E6=97=B6=EF=BC=8C=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E5=8F=B7=E6=B2=A1=E6=9C=89=E5=8F=98=E5=8A=A8?= =?UTF-8?q?=EF=BC=8C=E5=88=99=E4=B8=8D=E9=AA=8C=E8=AF=81=E3=80=82=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E5=87=BA=E7=8E=B0=E7=AB=AF=E5=8F=A3=E6=98=A0=E5=B0=84?= =?UTF-8?q?=E6=AD=A3=E5=9C=A8=E4=BD=BF=E7=94=A8=E6=97=B6=EF=BC=8C=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=9B=B4=E6=96=B0=E7=AB=AF=E5=8F=A3=E6=98=A0=E5=B0=84?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E4=BF=A1=E6=81=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/proxy/portMapping.vue | 18 +++++++++--------- .../server/controller/PortPoolController.java | 4 ++-- .../server/service/PortPoolService.java | 10 +++++++++- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/neutrino-proxy-admin/src/views/proxy/portMapping.vue b/neutrino-proxy-admin/src/views/proxy/portMapping.vue index 2dbcb44f..59ca8c9b 100644 --- a/neutrino-proxy-admin/src/views/proxy/portMapping.vue +++ b/neutrino-proxy-admin/src/views/proxy/portMapping.vue @@ -232,18 +232,18 @@ export default { loadSelect }, data() { - let isPortAvailable = (rule, value, callback) => { - if(value!=null){ - let param = {port: value} + const isPortAvailable = (rule, value, callback) => { + if (value != null) { + const param = { port: value, portMappingId: this.temp.id } portAvailable(param).then(res => { - if(!res.data.data){ - return callback(new Error('该端口被占用')); - }else{ - callback(); + if (!res.data.data) { + return callback(new Error('该端口被占用')) + } else { + callback() } - }); + }) } - }; + } return { tableKey: 0, list: null, diff --git a/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/controller/PortPoolController.java b/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/controller/PortPoolController.java index 60b1aa30..cf0f32ec 100644 --- a/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/controller/PortPoolController.java +++ b/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/controller/PortPoolController.java @@ -136,9 +136,9 @@ public class PortPoolController { @Get @Mapping("/port-available") - public boolean portAvailable(Integer port) { + public boolean portAvailable(Integer port, Integer portMappingId) { ParamCheckUtil.checkNotNull(port, "port"); - return portPoolService.portAvailable(port); + return portPoolService.portAvailable(port, portMappingId); } } diff --git a/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/service/PortPoolService.java b/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/service/PortPoolService.java index 97cb2fba..e6e49534 100644 --- a/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/service/PortPoolService.java +++ b/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/service/PortPoolService.java @@ -202,10 +202,18 @@ public class PortPoolService { /** * 检查端口是否被占用 + * 端口映射编辑时,如果端口号没有变动,则不验证。避免出现端口映射正在使用时,无法更新端口映射其他信息的问题 * @param port + * @param portMappingId * @return */ - public boolean portAvailable(Integer port) { + public boolean portAvailable(Integer port, Integer portMappingId) { + if (null != portMappingId) { + PortMappingDO portMappingDO = portMappingMapper.findById(portMappingId); + if (null != portMappingDO && portMappingDO.getServerPort().equals(port)) { + return Boolean.TRUE; + } + } return PortAvailableUtil.isPortAvailable(port); } }