【安眼】添加日志
This commit is contained in:
+3
@@ -299,7 +299,10 @@ public class AnYanClientExecutor implements AnYanClient {
|
|||||||
public AnYanUserInfoResult getAnYanUserInfo(String token, String username) {
|
public AnYanUserInfoResult getAnYanUserInfo(String token, String username) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add(AnYanConstants.AUTHORIZATION, AnYanConstants.TOKEN_TYPE + token);
|
headers.add(AnYanConstants.AUTHORIZATION, AnYanConstants.TOKEN_TYPE + token);
|
||||||
|
long time1 = System.currentTimeMillis();
|
||||||
ResponseEntity<AnYanUserInfoResult> exchange = RestTemplateUtil.getExchange(AnYanApiEnum.USER_INFO_UNIT_V2, headers, AnYanUserInfoResult.class);
|
ResponseEntity<AnYanUserInfoResult> exchange = RestTemplateUtil.getExchange(AnYanApiEnum.USER_INFO_UNIT_V2, headers, AnYanUserInfoResult.class);
|
||||||
|
long time2 = System.currentTimeMillis();
|
||||||
|
log.info("根据token获取用户信息耗时:" + (time2 - time1) + "ms");
|
||||||
redisClientUtil.set(new RedisKeyPrefix(-1, AnYanConstants.AN_YAN_API_USERINFO_PREFIX), username, exchange);
|
redisClientUtil.set(new RedisKeyPrefix(-1, AnYanConstants.AN_YAN_API_USERINFO_PREFIX), username, exchange);
|
||||||
return BeanUtil.toBean(exchange.getBody(), AnYanUserInfoResult.class);
|
return BeanUtil.toBean(exchange.getBody(), AnYanUserInfoResult.class);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -12,7 +12,6 @@ import org.springframework.http.ResponseEntity;
|
|||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,8 +63,11 @@ public class RestTemplateUtil {
|
|||||||
String url = getProperties().getPublicHost() + api.getMethodPath();
|
String url = getProperties().getPublicHost() + api.getMethodPath();
|
||||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(formData, headers);
|
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(formData, headers);
|
||||||
log.info("开始发送请求到: {},入参:{}", url, formData);
|
log.info("开始发送请求到: {},入参:{}", url, formData);
|
||||||
|
long time1 = System.currentTimeMillis();
|
||||||
ResponseEntity<T> response = getRestTemplate().exchange(url, api.getHttpMethod(), requestEntity, responseType);
|
ResponseEntity<T> response = getRestTemplate().exchange(url, api.getHttpMethod(), requestEntity, responseType);
|
||||||
log.info("收到响应: {}", response);
|
log.info("收到响应: {}", response);
|
||||||
|
long time2 = System.currentTimeMillis();
|
||||||
|
log.info("获取token(密码模式) 耗时:" + (time2 - time1) + "ms");
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user