123
This commit is contained in:
53
ruoyi-admin/src/main/java/com/ruoyi/proxy/PayProxyInit.java
Normal file
53
ruoyi-admin/src/main/java/com/ruoyi/proxy/PayProxyInit.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package com.ruoyi.proxy;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.ijpay.core.http.AbstractHttpDelegate;
|
||||
import com.ijpay.core.kit.HttpKit;
|
||||
import com.ruoyi.cai.config.CaiProperties;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
|
||||
@Component
|
||||
public class PayProxyInit {
|
||||
@Autowired
|
||||
private CaiProperties caiProperties;
|
||||
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
boolean openPayProxy = caiProperties.isOpenPayProxy();
|
||||
if(openPayProxy){
|
||||
String proxyIp = caiProperties.getProxyIp();
|
||||
int proxyHost = caiProperties.getProxyHost();
|
||||
ProxyHttpKit proxyHttpKit = new ProxyHttpKit();
|
||||
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyIp, proxyHost));
|
||||
proxyHttpKit.setCustomProxy(proxy);
|
||||
HttpKit.setDelegate(proxyHttpKit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Setter
|
||||
public static class ProxyHttpKit extends AbstractHttpDelegate {
|
||||
|
||||
private Proxy customProxy;
|
||||
|
||||
@Override
|
||||
public Proxy getProxy(){
|
||||
return customProxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String post(String url, String data) {
|
||||
return HttpRequest.post(url)
|
||||
.setProxy(customProxy)
|
||||
.body(data)
|
||||
.execute().body();
|
||||
// return HttpUtil.post(url, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,3 +113,6 @@ knife4j:
|
||||
secret: 0rhEH2ILED2WiVReyXeWEXE5NklDARdWkerW9/IruLY=
|
||||
# 当前服务名称
|
||||
service-name: oneToOne
|
||||
cai:
|
||||
enable-api-encryption: false
|
||||
open-pay-proxy: false
|
||||
|
||||
@@ -101,6 +101,9 @@ yunxin:
|
||||
app-secret: 470345ca2832
|
||||
cai:
|
||||
enable-api-encryption: true
|
||||
open-pay-proxy: false
|
||||
proxy-ip: 159.75.218.177
|
||||
proxy-host: 7693
|
||||
springdoc:
|
||||
api-docs:
|
||||
enabled: false
|
||||
|
||||
Reference in New Issue
Block a user