管道基础大数据平台系统开发-【后端】-Server
13693261870
2023-01-07 c60203f88a3eed9c0233a0e48719a4b9df4e6762
src/main/java/com/lf/server/helper/RestHelper.java
@@ -185,12 +185,39 @@
    }
    /**
     * 获取错误信息
     *
     * @param uri Uri地址
     * @param ex  异常
     * @return 错误信息
     */
    public static String getErrorInfo(String uri, Exception ex) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("result", null);
        map.put("message", ex.getMessage());
        map.put("code", 400);
        map.put("uri", uri);
        //map.put("tag", StaticData.CACHE_PREFIX)
        return map.toString();
    }
    /**
     * GET请求(REST)
     */
    public static String getForRest(String uri) {
        RestTemplate rest = getRestTemplate();
        return rest.getForObject(uri, String.class);
    }
    /**
     * GET请求(REST)
     */
    public static <T> T getForRest(String uri, Class<T> clazz) {
        RestTemplate rest = getRestTemplate();
        return rest.getForObject(uri, clazz);
    }
    /**
@@ -209,23 +236,5 @@
        RestTemplate rest = getRestTemplate();
        return rest.postForObject(uri, list, String.class);
    }
    /**
     * 获取错误信息
     *
     * @param uri Uri地址
     * @param ex  异常
     * @return 错误信息
     */
    public static String getErrorInfo(String uri, Exception ex) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("result", null);
        map.put("message", ex.getMessage());
        map.put("code", 400);
        map.put("uri", uri);
        //map.put("tag", StaticData.CACHE_PREFIX)
        return map.toString();
    }
}