管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-12-29 1d53dd8f501a98ddcce8146443b51b357ef5f9b1
src/main/java/com/lf/server/helper/RestHelper.java
@@ -150,7 +150,7 @@
            return EntityUtils.toString(entity, StaticData.TEXT_ENCODER);
        } catch (Exception ex) {
            log.error(ex);
            log.error(ex.getMessage(), ex);
            return getErrorInfo(uri, ex);
        }
@@ -172,12 +172,13 @@
            httpPost.setEntity(postEntity);
            CloseableHttpResponse closeResponse = httpClient.execute(httpPost);
            // 取出返回体
            HttpEntity entity = closeResponse.getEntity();
            return EntityUtils.toString(entity, StaticData.TEXT_ENCODER);
        } catch (Exception ex) {
            log.error(ex);
            log.error(ex.getMessage(), ex);
            return getErrorInfo(uri, ex);
        }
@@ -195,7 +196,7 @@
            return rest.getForObject(uri, String.class);
        } catch (Exception ex) {
            log.error(ex);
            log.error(ex.getMessage(), ex);
            return getErrorInfo(uri, ex);
        }
@@ -215,7 +216,19 @@
            return rest.postForObject(uri, entity, String.class);
        } catch (Exception ex) {
            log.error(ex);
            log.error(ex.getMessage(), ex);
            return getErrorInfo(uri, ex);
        }
    }
    public static String postForRest(String uri, Map<String, Object> map) {
        try {
            RestTemplate rest = getRestTemplate();
            return rest.postForObject(uri, map, String.class);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return getErrorInfo(uri, ex);
        }