public UidPlatformAuditResDto queryCertificationStatistics(UidPlatformAuditReqDto uidPlatformAudit) {
ResponseEntity<UidPlatformAuditResDto> uidPlatformAuditResDtoResponseEntity = null;
try {
uidPlatformAuditResDtoResponseEntity = restTemplate.postForEntity(url + UID_PLATFORM_AUDIT, uidPlatformAudit, UidPlatformAuditResDto.class);
} catch (RestClientException e) {
log.error(e.getMessage(), e);
throw new BusinessException(ResultCode.UID_AUTHORIZED_ERROR);
}
UidPlatformAuditResDto body = uidPlatformAuditResDtoResponseEntity.getBody();
log.info(JSON.toJSONString(body));
if (!body.getSuccess()){
throw new BusinessException(ResultCode.UID_AUTHORIZED_ERROR.getCode(),body.getMsg());
}
return body;
}
传对象时可以直接将对象放进去,然后返回时用对应的对象体接受。
如果要传带参数的如下写。
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
MultiValueMap<String, Object> map= new LinkedMultiValueMap<String, String>();
map.add("email", "taoge@xttblog.com");
map.add("url", "www.xttblog.com");
map.add("name", "业余草");
HttpEntity<MultiValueMap<String, Object>> multiValueMapHttpEntity = new HttpEntity<MultiValueMap<String, Object>>(map, headers);
restTemplate.postForEntity(url + UID_PLATFORM_AUDIT, multiValueMapHttpEntity, String.class);
作为一个笔记记录下,因为这个弄了好久才出来。