From 27e913d6d28a9cfa0785d15453a4de10fd36ce6d Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期一, 10 二月 2025 11:17:59 +0800 Subject: [PATCH] 首页录像统计加上间歇 --- ycl-server/src/main/java/com/ycl/utils/http/SelfHttpUtil.java | 25 +++++++++++++++++++------ 1 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ycl-server/src/main/java/com/ycl/utils/http/SelfHttpUtil.java b/ycl-server/src/main/java/com/ycl/utils/http/SelfHttpUtil.java index c83336f..d51198d 100644 --- a/ycl-server/src/main/java/com/ycl/utils/http/SelfHttpUtil.java +++ b/ycl-server/src/main/java/com/ycl/utils/http/SelfHttpUtil.java @@ -1,14 +1,23 @@ package com.ycl.utils.http; import lombok.RequiredArgsConstructor; +import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.lang.Nullable; import org.springframework.stereotype.Component; import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; + +import java.util.Collections; +import java.util.Map; /** * @author xp @@ -18,7 +27,8 @@ @RequiredArgsConstructor public class SelfHttpUtil { - private final RestTemplate httpClient; + private final RestTemplate restTemplate; + /** * post @@ -29,7 +39,7 @@ * @return */ public Object post(String url, @Nullable Object data, @Nullable MultiValueMap header) { - ResponseEntity<Object> response = httpClient.exchange( + ResponseEntity<Object> response = restTemplate.exchange( url, HttpMethod.POST, getHttpEntity(data, header), @@ -45,7 +55,7 @@ * @return */ public Object post(String url, String token, @Nullable Object data) { - ResponseEntity<Object> response = httpClient.exchange( + ResponseEntity<Object> response = restTemplate.exchange( url, HttpMethod.POST, getHttpEntity(data, token), @@ -81,12 +91,15 @@ * @param params * @return */ - public ResponseEntity<Object> get(String url, @Nullable MultiValueMap header, @Nullable Object... params) { - ResponseEntity<Object> response = httpClient.exchange( + public ResponseEntity<String> get(String url, @Nullable MultiValueMap header, @Nullable Map<String, Object> params) { + if (params == null) { + params = Collections.emptyMap(); + } + ResponseEntity<String> response = restTemplate.exchange( url, HttpMethod.GET, getHttpEntity(null, header), - Object.class, + String.class, params ); return response; -- Gitblit v1.8.0