From b6b0cb226fcf184525ee7b36af3a09471e9c0057 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 25 三月 2024 11:29:33 +0800 Subject: [PATCH] 修改数据统计的查询条件 --- src/main/java/com/lf/server/helper/RestHelper.java | 97 ++++++++++++++++++++++++++++-------------------- 1 files changed, 57 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/lf/server/helper/RestHelper.java b/src/main/java/com/lf/server/helper/RestHelper.java index 385b3f3..d8e24d1 100644 --- a/src/main/java/com/lf/server/helper/RestHelper.java +++ b/src/main/java/com/lf/server/helper/RestHelper.java @@ -1,6 +1,7 @@ package com.lf.server.helper; import com.lf.server.entity.all.StaticData; +import io.swagger.models.HttpMethod; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpEntity; @@ -150,7 +151,7 @@ return EntityUtils.toString(entity, StaticData.TEXT_ENCODER); } catch (Exception ex) { - log.error(ex); + log.error(ex.getMessage(), ex); return getErrorInfo(uri, ex); } @@ -178,45 +179,7 @@ return EntityUtils.toString(entity, StaticData.TEXT_ENCODER); } catch (Exception ex) { - log.error(ex); - - return getErrorInfo(uri, ex); - } - } - - /** - * Get璇锋眰-RestTemplate - * - * @param uri Uri鍦板潃 - * @return 鍝嶅簲瀛楃涓� - */ - public static String getForRest(String uri) { - try { - RestTemplate rest = getRestTemplate(); - - return rest.getForObject(uri, String.class); - } catch (Exception ex) { - log.error(ex); - - return getErrorInfo(uri, ex); - } - } - - /** - * Post璇锋眰-RestTemplate - * - * @param uri Uri鍦板潃 - * @param postData 寰呭彂閫佹暟鎹� - * @return 鍝嶅簲瀛楃涓� - */ - public static String postForRest(String uri, List<NameValuePair> postData) { - try { - RestTemplate rest = getRestTemplate(); - UrlEncodedFormEntity entity = new UrlEncodedFormEntity(postData, StaticData.TEXT_ENCODER); - - return rest.postForObject(uri, entity, String.class); - } catch (Exception ex) { - log.error(ex); + log.error(ex.getMessage(), ex); return getErrorInfo(uri, ex); } @@ -239,4 +202,58 @@ return map.toString(); } + + /** + * GET璇锋眰锛圧EST锛� + */ + public static String getForRest(String uri) { + RestTemplate rest = getRestTemplate(); + + return rest.getForObject(uri, String.class); + } + + /** + * GET璇锋眰锛圧EST锛� + */ + public static <T> T getForRest(String uri, Class<T> clazz) { + RestTemplate rest = getRestTemplate(); + + return rest.getForObject(uri, clazz); + } + + /** + * POST璇锋眰锛圧EST锛� + */ + public static String postForRest(String uri, Map<String, Object> map) { + RestTemplate rest = getRestTemplate(); + + return rest.postForObject(uri, map, String.class); + } + + /** + * POST璇锋眰锛圧EST锛� + */ + public static <T> String postForRest(String uri, List<T> list) { + RestTemplate rest = getRestTemplate(); + + return rest.postForObject(uri, list, String.class); + } + + /** + * POST璇锋眰锛圧EST锛� + */ + public static <T> String postForRest(String uri, T t) { + RestTemplate rest = getRestTemplate(); + + return rest.postForObject(uri, t, String.class); + } + + /** + * DELETE璇锋眰锛圧EST锛� + */ + public static void deleteForRest(String uri) { + RestTemplate rest = getRestTemplate(); + + rest.delete(uri); + } } -- Gitblit v1.9.3