請求的類型要對應起來
httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
log.info("*****************進入方法,入參爲:" + gson.toJson(map));
long start = System.currentTimeMillis();
ReturnInfo info = new ReturnInfo();
try {
log.info(">>>>>>>>>>>>>>>>>>>>>>進入方法getList 接口>>>>>>>>>>>>>>>>>>>>>>");
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add("token", request.getHeader("token"));
httpHeaders.add("orgId", request.getHeader("orgId"));
httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> body = new LinkedMultiValueMap<>();
body.add("page", map.get("page").toString());
body.add("size", map.get("size").toString());
body.add("userId", map.get("userId").toString());
HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(body, httpHeaders);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<ReturnInfo> response = restTemplate.exchange(listUrl, HttpMethod.POST, entity, ReturnInfo.class, Collections.singletonMap("path", "home"));
info = response.getBody();
} catch (HttpClientErrorException e) {
throw e;
} catch (Exception e) {
e.printStackTrace();
log.info(e.getMessage(), e);
info.setStatus("0");
info.setNote("系統繁忙,請稍後再試!");
}
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>查詢接口用時:" + (System.currentTimeMillis() - start) + "ms");
log.info("*****************查詢調用返回參數:" + gson.toJson(info) + "\n\n\n");
return info;