| | |
| | | package com.lf.server.helper; |
| | | |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.entity.ctrl.NameValueEntity; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.apache.http.HttpEntity; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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.getMessage(), ex); |
| | | |
| | | return getErrorInfo(uri, ex); |
| | | } |
| | | return rest.getForObject(uri, String.class); |
| | | } |
| | | |
| | | /** |
| | | * POST请求(REST) |
| | | */ |
| | | public static String postForRest(String uri, Map<String, Object> map) { |
| | | try { |
| | | RestTemplate rest = getRestTemplate(); |
| | | RestTemplate rest = getRestTemplate(); |
| | | |
| | | return rest.postForObject(uri, map, String.class); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | |
| | | return getErrorInfo(uri, ex); |
| | | } |
| | | return rest.postForObject(uri, map, String.class); |
| | | } |
| | | |
| | | /** |
| | | * POST请求(REST) |
| | | */ |
| | | public static <T> String postForRest(String uri, List<T> list) { |
| | | try { |
| | | RestTemplate rest = getRestTemplate(); |
| | | RestTemplate rest = getRestTemplate(); |
| | | |
| | | return rest.postForObject(uri, list, String.class); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | |
| | | return getErrorInfo(uri, ex); |
| | | } |
| | | return rest.postForObject(uri, list, String.class); |
| | | } |
| | | |
| | | /** |