File was renamed from pipIrr-platform/pipIrr-web/pipIrr-web-webchat/src/main/java/com/dy/pipirrWebChat/util/RestTemplateUtil.java |
| | |
| | | package com.dy.pipirrWebChat.util; |
| | | package com.dy.pipIrrSell.util; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-02-23 15:42 |
| | | * @LastEditTime 2024-02-23 15:42 |
| | | * @date 2024-03-06 13:47 |
| | | * @LastEditTime 2024-03-06 13:47 |
| | | * @Description |
| | | */ |
| | | |
| | |
| | | HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(null, headers); |
| | | ResponseEntity<String> response = restTemplate.exchange(tempUrl, HttpMethod.GET, httpEntity, String.class); |
| | | return JSONObject.parseObject(response.getBody()); |
| | | } |
| | | |
| | | public JSONObject getHeaders(String url, Map<String, Object> queryParams, Map<String, String> headerParams) throws IOException { |
| | | String tempUrl = setParamsByAppendUrl(queryParams, url); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headerParams.forEach(headers::add); |
| | | HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(null, headers); |
| | | ResponseEntity<String> response = restTemplate.exchange(tempUrl, HttpMethod.GET, httpEntity, String.class); |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("headers", response.getHeaders()); |
| | | jsonObject.put("body", response.getBody()); |
| | | return jsonObject; |
| | | } |
| | | |
| | | public JSONObject get2(String url, Map<String, Object> queryParams, Map<String, String> headerParams) throws IOException { |
| | |
| | | return url + sb; |
| | | } |
| | | |
| | | } |
| | | } |