refactor: 一点点修改

This commit is contained in:
曹鹏飞 2024-03-29 16:42:08 +08:00
parent 01e40439c7
commit 4815b5d1c4
1 changed files with 3 additions and 7 deletions

View File

@ -6,8 +6,6 @@ import com.nflg.product.base.core.exception.NflgBusinessException;
import lombok.extern.slf4j.Slf4j;
import nflg.product.common.constant.STATE;
import okhttp3.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import java.io.File;
@ -26,8 +24,6 @@ public class HttpUtils {
//请求类
private OkHttpClient okHttpClient;
private static final Logger LOGGER = LoggerFactory.getLogger(HttpUtils.class);
//请求头类型
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 {
String ret = null;
String traceId = IdWorker.getIdStr();
LOGGER.info(traceId + "http请求地址" + url + ",参数:" + json);
log.info(traceId + "http请求地址" + url + ",参数:" + json);
long start = System.currentTimeMillis();
try (Response response = doPostRtnRsp(url, json)) {
if (response == null || response.body() == null) {
@ -225,10 +221,10 @@ public class HttpUtils {
}
ret = response.body().string();
} catch (Exception ex) {
LOGGER.error(traceId + "http请求出错", ex);
log.error(traceId + "http请求出错", ex);
} finally {
long end = System.currentTimeMillis();
LOGGER.info(traceId + "http请求耗时" + (end - start) + "毫秒,返回:" + ret);
log.info(traceId + "http请求耗时" + (end - start) + "毫秒,返回:" + ret);
}
return ret;
}