|
@@ -5,7 +5,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
|
|
// import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
|
|
import com.rtrh.core.vo.Message;
|
|
|
+import com.rtrh.projects.modules.projects.po.SubPreNew;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.HttpEntity;
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
import org.apache.http.client.methods.HttpGet;
|
|
@@ -18,7 +20,9 @@ import org.apache.http.util.EntityUtils;
|
|
|
import java.io.IOException;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.ResourceBundle;
|
|
|
|
|
|
@Slf4j
|
|
|
public class HttpClientUtil {
|
|
@@ -37,10 +41,12 @@ public class HttpClientUtil {
|
|
|
if (params != null && !params.isEmpty()) {
|
|
|
sb.append("?");
|
|
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
|
|
- sb.append(entry.getKey())
|
|
|
- .append("=")
|
|
|
- .append(URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.toString()))
|
|
|
- .append("&");
|
|
|
+ if (StringUtils.isNotBlank(entry.getValue())){
|
|
|
+ sb.append(entry.getKey())
|
|
|
+ .append("=")
|
|
|
+ .append(URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.toString()))
|
|
|
+ .append("&");
|
|
|
+ }
|
|
|
}
|
|
|
sb.deleteCharAt(sb.length() - 1); // 移除最后一个 &
|
|
|
}
|
|
@@ -64,6 +70,15 @@ public class HttpClientUtil {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ public static Object fgwGetRequest(String url, Map<String, String> params) {
|
|
|
+ ResourceBundle resourceBundle = ResourceBundle.getBundle("config");
|
|
|
+ String inUrl = resourceBundle.getString("app.fgw.in.url");
|
|
|
+ return sendGetRequest(inUrl + url, params);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Object fgwGetRequest(String url) {
|
|
|
+ return fgwGetRequest(url, null);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 发送 POST 请求
|
|
@@ -122,4 +137,10 @@ public class HttpClientUtil {
|
|
|
public static Object sendPostRequest(String url, Object jsonBody) {
|
|
|
return sendPostRequest(url, jsonBody, null);
|
|
|
}
|
|
|
+
|
|
|
+ public static Object fgwPostRequest(String s, Object jsonBody) {
|
|
|
+ ResourceBundle resourceBundle = ResourceBundle.getBundle("config");
|
|
|
+ String inUrl = resourceBundle.getString("app.fgw.in.url");
|
|
|
+ return sendPostRequest(inUrl + s, jsonBody);
|
|
|
+ }
|
|
|
}
|