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); } }