diff --git a/core/backend/src/main/java/io/dataease/listener/ProxyListener.java b/core/backend/src/main/java/io/dataease/listener/ProxyListener.java new file mode 100644 index 0000000000..11883df637 --- /dev/null +++ b/core/backend/src/main/java/io/dataease/listener/ProxyListener.java @@ -0,0 +1,31 @@ +package io.dataease.listener; + +import io.dataease.commons.utils.LogUtil; +import io.dataease.plugins.common.util.SpringContextUtil; +import io.dataease.plugins.xpack.proxy.service.ProxyXpackService; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +import java.util.Map; + +@Component +public class ProxyListener implements ApplicationListener { + @Override + public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { + try { + Map beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((ProxyXpackService.class)); + if (beansOfType.keySet().size() == 0) { + return; + } + ProxyXpackService xpackService = SpringContextUtil.getBean(ProxyXpackService.class); + if (ObjectUtils.isNotEmpty(xpackService)) { + xpackService.setProxy(); + } + } catch (Exception e) { + LogUtil.error(e.getMessage(), e); + } + + } +} diff --git a/core/backend/src/main/java/io/dataease/plugins/server/XProxyServer.java b/core/backend/src/main/java/io/dataease/plugins/server/XProxyServer.java new file mode 100644 index 0000000000..8cd15fa05c --- /dev/null +++ b/core/backend/src/main/java/io/dataease/plugins/server/XProxyServer.java @@ -0,0 +1,28 @@ +package io.dataease.plugins.server; + +import io.dataease.plugins.common.util.SpringContextUtil; +import io.dataease.plugins.xpack.display.dto.response.SysSettingDto; +import io.dataease.plugins.xpack.proxy.dto.ProxyInfo; +import io.dataease.plugins.xpack.proxy.service.ProxyXpackService; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.List; + +@ApiIgnore +@RequestMapping("/plugin/proxy") +@RestController +public class XProxyServer { + + @GetMapping("/query") + public ProxyInfo query() { + ProxyXpackService xpackService = SpringContextUtil.getBean(ProxyXpackService.class); + return xpackService.info(); + } + + @PostMapping("/save") + public void save(@RequestBody List list) { + ProxyXpackService xpackService = SpringContextUtil.getBean(ProxyXpackService.class); + xpackService.save(list); + } +} diff --git a/core/frontend/src/lang/en.js b/core/frontend/src/lang/en.js index cd4e8439f4..5a578b52eb 100644 --- a/core/frontend/src/lang/en.js +++ b/core/frontend/src/lang/en.js @@ -828,6 +828,11 @@ export default { edite_organization: 'Edit organization' }, system_parameter_setting: { + proxy_setting: 'Proxy setting', + proxy_account: 'Proxy account', + proxy_pwd: 'Proxy password', + proxy_host: 'Proxy address', + proxy_port: '服务端口', email_server_config: 'Mailbox server configuration', edit_success: 'Edit success', mailbox_service_settings: 'Mail Setting', diff --git a/core/frontend/src/lang/tw.js b/core/frontend/src/lang/tw.js index ead1122ef7..5960434292 100644 --- a/core/frontend/src/lang/tw.js +++ b/core/frontend/src/lang/tw.js @@ -827,6 +827,11 @@ export default { edite_organization: '編輯組織' }, system_parameter_setting: { + proxy_setting: '代理設置', + proxy_account: '代理賬號', + proxy_pwd: '代理密碼', + proxy_host: '代理服務地址', + proxy_port: '服务端口', email_server_config: '郵箱服務器配置', edit_success: '編輯成功', mailbox_service_settings: '郵件設置', diff --git a/core/frontend/src/lang/zh.js b/core/frontend/src/lang/zh.js index b426b87466..9032d07f7b 100644 --- a/core/frontend/src/lang/zh.js +++ b/core/frontend/src/lang/zh.js @@ -826,6 +826,11 @@ export default { edite_organization: '编辑组织' }, system_parameter_setting: { + proxy_setting: '代理设置', + proxy_account: '代理账号', + proxy_pwd: '代理密码', + proxy_host: '代理服务地址', + proxy_port: '服务端口', email_server_config: '邮箱服务器配置', edit_success: '编辑成功', mailbox_service_settings: '邮件设置', diff --git a/core/frontend/src/views/system/sysParam/index.vue b/core/frontend/src/views/system/sysParam/index.vue index c483866b40..8488fbe445 100644 --- a/core/frontend/src/views/system/sysParam/index.vue +++ b/core/frontend/src/views/system/sysParam/index.vue @@ -45,6 +45,13 @@ :label="$t('system_parameter_setting.kettle_setting')" name="eight" /> + +
+
@@ -76,6 +88,7 @@ import KettleSetting from './KettleSetting' import DeLayoutContent from '@/components/business/DeLayoutContent' import { pluginLoaded } from '@/api/user' import { engineMode } from '@/api/system/engine' +import PluginCom from '@/views/system/plugin/PluginCom' export default { components: { BasicSetting, @@ -84,7 +97,8 @@ export default { SimpleMode, ClusterMode, KettleSetting, - MapSetting + MapSetting, + PluginCom }, data() { return { diff --git a/sdk/dataease-plugin-common/src/main/java/io/dataease/plugins/common/util/HttpClientUtil.java b/sdk/dataease-plugin-common/src/main/java/io/dataease/plugins/common/util/HttpClientUtil.java index 6bdde41934..0a2b68ce23 100755 --- a/sdk/dataease-plugin-common/src/main/java/io/dataease/plugins/common/util/HttpClientUtil.java +++ b/sdk/dataease-plugin-common/src/main/java/io/dataease/plugins/common/util/HttpClientUtil.java @@ -23,6 +23,7 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.impl.conn.SystemDefaultRoutePlanner; import org.apache.http.message.BasicNameValuePair; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.util.EntityUtils; @@ -30,6 +31,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; +import java.net.ProxySelector; import java.nio.charset.StandardCharsets; import java.security.cert.X509Certificate; import java.util.ArrayList; @@ -58,8 +60,8 @@ public class HttpClientUtil { .register("http", new PlainConnectionSocketFactory()) .register("https", socketFactory).build(); HttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(registry); - CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(connManager).build(); - return httpClient; + SystemDefaultRoutePlanner routePlanner = new SystemDefaultRoutePlanner(ProxySelector.getDefault()); + return HttpClients.custom().setConnectionManager(connManager).setRoutePlanner(routePlanner).build(); } else { // http return HttpClientBuilder.create().build(); diff --git a/sdk/dataease-plugin-interface/src/main/java/io/dataease/plugins/xpack/proxy/dto/ProxyInfo.java b/sdk/dataease-plugin-interface/src/main/java/io/dataease/plugins/xpack/proxy/dto/ProxyInfo.java new file mode 100644 index 0000000000..36452c26e5 --- /dev/null +++ b/sdk/dataease-plugin-interface/src/main/java/io/dataease/plugins/xpack/proxy/dto/ProxyInfo.java @@ -0,0 +1,15 @@ +package io.dataease.plugins.xpack.proxy.dto; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class ProxyInfo implements Serializable { + + private String httpProxy; + + private String proxyAccount; + + private String proxyPwd; +} diff --git a/sdk/dataease-plugin-interface/src/main/java/io/dataease/plugins/xpack/proxy/service/ProxyXpackService.java b/sdk/dataease-plugin-interface/src/main/java/io/dataease/plugins/xpack/proxy/service/ProxyXpackService.java new file mode 100644 index 0000000000..4088364b6c --- /dev/null +++ b/sdk/dataease-plugin-interface/src/main/java/io/dataease/plugins/xpack/proxy/service/ProxyXpackService.java @@ -0,0 +1,16 @@ +package io.dataease.plugins.xpack.proxy.service; + +import io.dataease.plugins.common.service.PluginComponentService; +import io.dataease.plugins.xpack.display.dto.response.SysSettingDto; +import io.dataease.plugins.xpack.proxy.dto.ProxyInfo; + +import java.util.List; + +public abstract class ProxyXpackService extends PluginComponentService { + + public abstract ProxyInfo info(); + + public abstract void save(List settings); + + public abstract void setProxy(); +}