管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-01-07 9413b280aa5e84bc6176b492fddc1e0aa8ccc6e4
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);
        }
@@ -178,48 +178,37 @@
            return EntityUtils.toString(entity, StaticData.TEXT_ENCODER);
        } catch (Exception ex) {
            log.error(ex);
            log.error(ex.getMessage(), ex);
            return getErrorInfo(uri, ex);
        }
    }
    /**
     * Get请求-RestTemplate
     *
     * @param uri Uri地址
     * @return 响应字符串
     * GET请求(REST)
     */
    public static String getForRest(String uri) {
        try {
            RestTemplate rest = getRestTemplate();
        RestTemplate rest = getRestTemplate();
            return rest.getForObject(uri, String.class);
        } catch (Exception ex) {
            log.error(ex);
            return getErrorInfo(uri, ex);
        }
        return rest.getForObject(uri, String.class);
    }
    /**
     * Post请求-RestTemplate
     *
     * @param uri      Uri地址
     * @param postData 待发送数据
     * @return 响应字符串
     * POST请求(REST)
     */
    public static String postForRest(String uri, List<NameValuePair> postData) {
        try {
            RestTemplate rest = getRestTemplate();
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(postData, StaticData.TEXT_ENCODER);
    public static String postForRest(String uri, Map<String, Object> map) {
        RestTemplate rest = getRestTemplate();
            return rest.postForObject(uri, entity, String.class);
        } catch (Exception ex) {
            log.error(ex);
        return rest.postForObject(uri, map, String.class);
    }
            return getErrorInfo(uri, ex);
        }
    /**
     * POST请求(REST)
     */
    public static <T> String postForRest(String uri, List<T> list) {
        RestTemplate rest = getRestTemplate();
        return rest.postForObject(uri, list, String.class);
    }
    /**