From dbed5147e0c93a3df1aeeb3bd81de4f9662fd075 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Thu, 17 Apr 2025 19:29:22 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E9=9B=86=E6=88=90?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E8=AE=B0=E5=BD=95=E8=8E=B7=E5=8F=96=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E6=97=B6=E6=8A=9B=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1401579456921600]集成调用记录获取失败时抛异常 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1401579456921600 --- .../server/ServerHostIsBankException.java | 27 +++++++++++++++++++ .../server/ServerNotFoundException.java | 27 +++++++++++++++++++ .../framework/service/FileServiceImpl.java | 10 +++++-- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 src/main/java/neatlogic/framework/exception/server/ServerHostIsBankException.java create mode 100644 src/main/java/neatlogic/framework/exception/server/ServerNotFoundException.java diff --git a/src/main/java/neatlogic/framework/exception/server/ServerHostIsBankException.java b/src/main/java/neatlogic/framework/exception/server/ServerHostIsBankException.java new file mode 100644 index 000000000..612a2b520 --- /dev/null +++ b/src/main/java/neatlogic/framework/exception/server/ServerHostIsBankException.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.exception.server; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class ServerHostIsBankException extends ApiRuntimeException { + + public ServerHostIsBankException(Integer serverId) { + super("serverId为{0}的应用服务器的服务器地址为空,请到服务器管理页设置", serverId); + } +} diff --git a/src/main/java/neatlogic/framework/exception/server/ServerNotFoundException.java b/src/main/java/neatlogic/framework/exception/server/ServerNotFoundException.java new file mode 100644 index 000000000..3a5059c12 --- /dev/null +++ b/src/main/java/neatlogic/framework/exception/server/ServerNotFoundException.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.exception.server; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class ServerNotFoundException extends ApiRuntimeException { + + public ServerNotFoundException(Integer serverId) { + super("找不到serverId为{0}的应用服务器", serverId); + } +} diff --git a/src/main/java/neatlogic/module/framework/service/FileServiceImpl.java b/src/main/java/neatlogic/module/framework/service/FileServiceImpl.java index 437073428..b8bf69d00 100644 --- a/src/main/java/neatlogic/module/framework/service/FileServiceImpl.java +++ b/src/main/java/neatlogic/module/framework/service/FileServiceImpl.java @@ -27,6 +27,8 @@ import neatlogic.framework.exception.file.FileAccessDeniedException; import neatlogic.framework.exception.file.FileNotFoundException; import neatlogic.framework.exception.file.FilePathIllegalException; import neatlogic.framework.exception.file.FileTypeHandlerNotFoundException; +import neatlogic.framework.exception.server.ServerHostIsBankException; +import neatlogic.framework.exception.server.ServerNotFoundException; import neatlogic.framework.exception.user.NoTenantException; import neatlogic.framework.file.core.FileOperationType; import neatlogic.framework.file.core.FileTypeHandlerFactory; @@ -216,10 +218,12 @@ public class FileServiceImpl implements IFileCrossoverService { ServerClusterVo serverClusterVo = serverMapper.getServerByServerId(serverId); if (serverClusterVo != null) { host = serverClusterVo.getHost(); + } else { + throw new ServerNotFoundException(serverId); } TenantContext.get().setUseMasterDatabase(false); if (StringUtils.isBlank(host)) { - return resultObj; + throw new ServerHostIsBankException(serverId); } HttpServletRequest request = RequestContext.get().getRequest(); String url = host + request.getRequestURI(); @@ -292,10 +296,12 @@ public class FileServiceImpl implements IFileCrossoverService { ServerClusterVo serverClusterVo = serverMapper.getServerByServerId(serverId); if (serverClusterVo != null) { host = serverClusterVo.getHost(); + } else { + throw new ServerNotFoundException(serverId); } TenantContext.get().setUseMasterDatabase(false); if (StringUtils.isBlank(host)) { - return; + throw new ServerHostIsBankException(serverId); } String url = host + request.getRequestURI(); HttpRequestUtil httpRequestUtil = HttpRequestUtil.download(url, "POST", response.getOutputStream()).setPayload(paramObj.toJSONString()).setAuthType(AuthenticateType.BUILDIN).sendRequest(); -- Gitee