From d98e92ff3cd9bde1398d4f84a393da9397cb6e70 Mon Sep 17 00:00:00 2001
From: 彭雪彬 <1724387007@qq.com>
Date: Tue, 15 Jul 2025 19:57:04 +0800
Subject: [PATCH] Merge branch 'xin' into pxb

---
 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