refactor: 一点点修改
This commit is contained in:
parent
01e40439c7
commit
4815b5d1c4
|
|
@ -6,8 +6,6 @@ import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import nflg.product.common.constant.STATE;
|
import nflg.product.common.constant.STATE;
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -26,8 +24,6 @@ public class HttpUtils {
|
||||||
//请求类
|
//请求类
|
||||||
private OkHttpClient okHttpClient;
|
private OkHttpClient okHttpClient;
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(HttpUtils.class);
|
|
||||||
|
|
||||||
//请求头类型
|
//请求头类型
|
||||||
private final MediaType jsonMediaType = MediaType.parse("application/json;charset=utf-8");
|
private final MediaType jsonMediaType = MediaType.parse("application/json;charset=utf-8");
|
||||||
|
|
||||||
|
|
@ -217,7 +213,7 @@ public class HttpUtils {
|
||||||
public String doPost(String url, String json) throws IOException {
|
public String doPost(String url, String json) throws IOException {
|
||||||
String ret = null;
|
String ret = null;
|
||||||
String traceId = IdWorker.getIdStr();
|
String traceId = IdWorker.getIdStr();
|
||||||
LOGGER.info(traceId + ",http请求,地址:" + url + ",参数:" + json);
|
log.info(traceId + ",http请求,地址:" + url + ",参数:" + json);
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
try (Response response = doPostRtnRsp(url, json)) {
|
try (Response response = doPostRtnRsp(url, json)) {
|
||||||
if (response == null || response.body() == null) {
|
if (response == null || response.body() == null) {
|
||||||
|
|
@ -225,10 +221,10 @@ public class HttpUtils {
|
||||||
}
|
}
|
||||||
ret = response.body().string();
|
ret = response.body().string();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOGGER.error(traceId + ",http请求,出错", ex);
|
log.error(traceId + ",http请求,出错", ex);
|
||||||
} finally {
|
} finally {
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
LOGGER.info(traceId + ",http请求,耗时:" + (end - start) + "毫秒,返回:" + ret);
|
log.info(traceId + ",http请求,耗时:" + (end - start) + "毫秒,返回:" + ret);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue