1、get请求
@GetMapping("/searchEntryRecordPageList")
public JSONObject searchEntryRecordPageList(@RequestParam Map<String,Object> params){
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.add("Authorization","Bearer "
+ String.valueOf(params.get("access_token")));
MultiValueMap<String, Object> entryRecordParam =
new LinkedMultiValueMap<String, Object>();
entryRecordParam.add("offset",params.get("offset"));
entryRecordParam.add("limit",params.get("limit"));
entryRecordParam.add("yzOpenId",params.get("yzOpenId"));
HttpEntity<MultiValueMap<String, Object>> requestEntity =
new HttpEntity<MultiValueMap<String, Object>>(entryRecordParam, requestHeaders);
ResponseEntity<Map> response = null;
try {
response = restTemplate.exchange(yzymUrl+"/app/entryRecord/searchEntryRecordPageList", HttpMethod.POST, requestEntity, Map.class);
}catch (Exception e){
return exceptionObj(e.getMessage());
}
logger.info(JSONObject.toJSONString(response.getBody()));
return (JSONObject) JSONObject.toJSON(response.getBody());
}
@GetMapping("/searchCheckResultByEntryRecordId")
public JSONObject searchCheckResultByEntryRecordId(@RequestParam
Map<String,Object> params){
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.add("Authorization","Bearer "
+ String.valueOf(params.get("access_token")));
MultiValueMap<String, Object> entryRecordParam =
new LinkedMultiValueMap<String, Object>();
HttpEntity<MultiValueMap<String, Object>> requestEntity =
new HttpEntity<MultiValueMap<String, Object>>(entryRecordParam, requestHeaders);
ResponseEntity<Map> response = null;
try {
response = restTemplate.exchange(yzymUrl+"/app/entryRecord/searchCheckResultByEntryRecordId?entryRecordId="+params.get("entryRecordId"),
HttpMethod.GET, requestEntity, Map.class);
}catch (Exception e){
return exceptionObj(e.getMessage());
}
logger.info(JSONObject.toJSONString(response.getBody()));
return (JSONObject) JSONObject.toJSON(response.getBody());
}
2、post请求
@PostMapping("/batchAddCart")
public JSONObject addCart(@RequestParam Map<String,Object> params){
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.add("Authorization","Bearer "
+ String.valueOf(params.get("access_token")));
MultiValueMap<String, Object> entryRecordParam =
new LinkedMultiValueMap<String, Object>();
entryRecordParam.add("yzOpenId",params.get("yzOpenId"));
entryRecordParam.add("cartParams",params.get("cartParams"));
HttpEntity<MultiValueMap<String, Object>> requestEntity =
new HttpEntity<MultiValueMap<String, Object>>(entryRecordParam, requestHeaders);
ResponseEntity<Map> response = null;
try {
response = restTemplate.exchange(yzymUrl+"/app/yzGoods/batchAddCart", HttpMethod.POST, requestEntity, Map.class);
}catch (Exception e){
return exceptionObj(e.getMessage());
}
logger.info(JSONObject.toJSONString(response.getBody()));
return (JSONObject) JSONObject.toJSON(response.getBody());
}