From a6ac90e29e513b80b7ad881da8e319338021ef8b Mon Sep 17 00:00:00 2001
From: xin <1099200748@qq.com>
Date: Thu, 25 Sep 2025 22:41:40 +0800
Subject: [PATCH] 生产环境配置
---
oying-common/src/main/java/com/oying/utils/HttpRequest.java | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/oying-common/src/main/java/com/oying/utils/HttpRequest.java b/oying-common/src/main/java/com/oying/utils/HttpRequest.java
index d3293c4..215eb3e 100644
--- a/oying-common/src/main/java/com/oying/utils/HttpRequest.java
+++ b/oying-common/src/main/java/com/oying/utils/HttpRequest.java
@@ -14,6 +14,7 @@
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import javax.net.ssl.SSLContext;
@@ -22,6 +23,8 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
/**
@@ -79,6 +82,28 @@
return headers;
}
+ private static HttpHeaders getMsg() {
+ HttpHeaders headers = new HttpHeaders();
+ List<MediaType> mediaTypes = new ArrayList<>();
+ mediaTypes.add(MediaType.ALL);
+ headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); // 表单格式
+ headers.setAccept(mediaTypes);
+ headers.setConnection("Keep-Alive");
+ headers.set("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+ return headers;
+ }
+
+ /**
+ * 短信
+ * http返回String xml
+ */
+ public static String exchangeMsg(HttpMethod httpMethod, String url, MultiValueMap<String, String> map) {
+ HttpHeaders headers = getMsg();
+ HttpEntity<Object> httpEntity = new HttpEntity<>(map, headers);
+ RestTemplate restTemplate = new RestTemplate(getFactory());
+ return restTemplate.exchange(url, httpMethod, httpEntity, String.class).getBody();
+ }
+
/**
* http返回String
*/
@@ -98,4 +123,6 @@
RestTemplate restTemplate = new RestTemplate();
return restTemplate.exchange(url, httpMethod, httpEntity, JSONObject.class).getBody();
}
+
+
}
--
Gitblit v1.9.3