Quellcode durchsuchen

结算中心模块-https请求将token添加到请求头,从而避免接口地址显示

ZhangWenQiang vor 5 Jahren
Ursprung
Commit
accc183d2c

+ 4 - 1
happy-boot-module-settlement/src/main/java/org/jeecg/common/utils/HttpsUtils.java

@@ -29,7 +29,7 @@ public class HttpsUtils {
      * @param outputStr     提交的数据
      * @return json字符串
      */
-    public static JSONObject doRequest(String requestUrl, String requestMethod, String outputStr) {
+    public static JSONObject doRequest(String requestUrl, String requestMethod, String outputStr, String token) {
         StringBuffer buffer = new StringBuffer();
         JSONObject jsonObject;
         try {
@@ -49,6 +49,9 @@ public class HttpsUtils {
             httpUrlConn.setUseCaches(false);
             // 设置请求方式(GET/POST)
             httpUrlConn.setRequestMethod(requestMethod);
+            //设置Authorization授权token
+            httpUrlConn.setRequestProperty("Authorization", "bearer" + token);
+            httpUrlConn.setRequestProperty("Content-type", "application/json");
 
             if ("GET".equalsIgnoreCase(requestMethod)) {
                 httpUrlConn.connect();