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 0000000000000000000000000000000000000000..612a2b5209e8644b22dc0df49b3f3d835b99d24a --- /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 0000000000000000000000000000000000000000..3a5059c12a5c8802070e0a8cdf45de7302161cf2 --- /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 4370734284e5400ec79a8c61c06b28fe284a467a..b8bf69d004c2004345b7a2817775c71f67752e34 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();