| | |
| | | package com.doumee.core.jiandaoyun.model.http; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.core.jiandaoyun.util.LimitUtil; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | */ |
| | | public Map<String, Object> sendPostRequest(HttpRequestParam param) throws Exception { |
| | | if (param == null || StringUtils.isBlank(param.getPath())) { |
| | | throw new RuntimeException("缺失参数!"); |
| | | throw new Exception("缺失参数!"); |
| | | } |
| | | HttpClient client = getSSLHttpClient(); |
| | | Header[] headers = getHttpHeaders(this.getApiKey()); |
| | | String url = this.host + param.getPath(); |
| | | log.error("===简道云接口url:"+url); |
| | | HttpRequestBase request = new HttpPost(url); |
| | | |
| | | // 请求参数 |
| | |
| | | result = (Map<String, Object>) mapper.readValue(response.getEntity().getContent(), Object.class); |
| | | } |
| | | if (statusCode >= 400) { |
| | | throw new RuntimeException("请求错误,statusCode:" + statusCode + ",Error Code: " + result.get("code") + ", Error Msg: " + result.get("msg")); |
| | | log.error("===简道云接口:请求错误,statusCode:" + statusCode + ",Error Code: " + result.get("code") + ", Error Msg: " + result.get("msg")); |
| | | throw new Exception("请求错误,statusCode:" + statusCode + ",Error Code: " + result.get("code") + ", Error Msg: " + result.get("msg")); |
| | | } else { |
| | | // 处理返回结果 |
| | | log.error("===简道云接口:请求成功result:" + JSONObject.toJSONString(result)); |
| | | return result; |
| | | } |
| | | } |