|
|
@ -1,12 +1,6 @@
|
|
|
package com.yihu.jw.care.util;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.entity.base.dict.BaseExceptionDictDO;
|
|
|
import com.yihu.jw.entity.base.dict.BaseExceptionLogDO;
|
|
|
import com.yihu.jw.entity.base.dict.BaseExceptionServerDictDO;
|
|
|
import com.yihu.jw.util.dao.BaseExceptionDictUtilDao;
|
|
|
import com.yihu.jw.util.dao.BaseExceptionLogUtilDao;
|
|
|
import com.yihu.jw.util.dao.BaseExceptionServerDictUtilDao;
|
|
|
import org.apache.http.Consts;
|
|
|
import org.apache.http.HttpEntity;
|
|
|
import org.apache.http.NameValuePair;
|
|
|
@ -20,14 +14,10 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.HttpMethod;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
@ -35,7 +25,10 @@ import java.io.*;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
import java.net.URLConnection;
|
|
|
import java.util.*;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Component
|
|
|
public class HttpClientUtilCare {
|
|
|
@ -566,14 +559,24 @@ public class HttpClientUtilCare {
|
|
|
}
|
|
|
|
|
|
public org.springframework.http.HttpEntity<JSONObject> iotAssesTokenPostHttp(String url, MultiValueMap<String, String> params,HttpMethod method){
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
MediaType type = MediaType.parseMediaType(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
|
|
|
headers.setContentType(type);
|
|
|
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
|
|
|
org.springframework.http.HttpEntity<MultiValueMap<String, String>> request = new org.springframework.http.HttpEntity<>(params, headers);
|
|
|
org.springframework.http.HttpEntity<JSONObject> response = restTemplate.exchange(url, method, request, JSONObject.class);
|
|
|
return response;
|
|
|
try {
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
MediaType type = MediaType.parseMediaType(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
|
|
|
headers.setContentType(type);
|
|
|
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
|
|
|
org.springframework.http.HttpEntity<MultiValueMap<String, String>> request = new org.springframework.http.HttpEntity<>(params, headers);
|
|
|
org.springframework.http.HttpEntity<JSONObject> response = restTemplate.exchange(url, method, request, JSONObject.class);
|
|
|
return response;
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
JSONObject responseBody = new JSONObject();
|
|
|
responseBody.put("code",-1);
|
|
|
responseBody.put("msg","请求失败");
|
|
|
org.springframework.http.HttpEntity<JSONObject> response = new org.springframework.http.HttpEntity<JSONObject>(responseBody);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|