Merge pull request #8358 from dataease/pr@dev@feat_xpack_proxy_config
feat(X-Pack): 代理设置 close #8300
This commit is contained in:
commit
120936cc52
@ -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<ApplicationReadyEvent> {
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
|
||||
try {
|
||||
Map<String, ProxyXpackService> 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -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<SysSettingDto> list) {
|
||||
ProxyXpackService xpackService = SpringContextUtil.getBean(ProxyXpackService.class);
|
||||
xpackService.save(list);
|
||||
}
|
||||
}
|
||||
@ -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',
|
||||
|
||||
@ -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: '郵件設置',
|
||||
|
||||
@ -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: '邮件设置',
|
||||
|
||||
@ -45,6 +45,13 @@
|
||||
:label="$t('system_parameter_setting.kettle_setting')"
|
||||
name="eight"
|
||||
/>
|
||||
|
||||
<el-tab-pane
|
||||
v-if="isPluginLoaded"
|
||||
lazy
|
||||
:label="$t('system_parameter_setting.proxy_setting')"
|
||||
name="nine"
|
||||
/>
|
||||
</el-tabs>
|
||||
<div
|
||||
class="tabs-container"
|
||||
@ -61,6 +68,11 @@
|
||||
<simple-mode v-if="activeName === 'six'" />
|
||||
<cluster-mode v-if="activeName === 'seven'" />
|
||||
<kettle-setting v-if="activeName === 'eight'" />
|
||||
<plugin-com
|
||||
v-if="isPluginLoaded && activeName === 'nine'"
|
||||
ref="ProxySetting"
|
||||
component-name="ProxySetting"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -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 {
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -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<SysSettingDto> settings);
|
||||
|
||||
public abstract void setProxy();
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user