【安眼】添加日志

This commit is contained in:
2026-02-02 19:00:01 +08:00
parent e47a02f4cd
commit 46c0c15bf2
2 changed files with 7 additions and 2 deletions
@@ -299,7 +299,10 @@ public class AnYanClientExecutor implements AnYanClient {
public AnYanUserInfoResult getAnYanUserInfo(String token, String username) {
HttpHeaders headers = new HttpHeaders();
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);
long time2 = System.currentTimeMillis();
log.info("根据token获取用户信息耗时:" + (time2 - time1) + "ms");
redisClientUtil.set(new RedisKeyPrefix(-1, AnYanConstants.AN_YAN_API_USERINFO_PREFIX), username, exchange);
return BeanUtil.toBean(exchange.getBody(), AnYanUserInfoResult.class);
}
@@ -12,7 +12,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.util.Map;
import java.util.Objects;
/**
@@ -64,8 +63,11 @@ public class RestTemplateUtil {
String url = getProperties().getPublicHost() + api.getMethodPath();
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(formData, headers);
log.info("开始发送请求到: {},入参:{}", url, formData);
long time1 = System.currentTimeMillis();
ResponseEntity<T> response = getRestTemplate().exchange(url, api.getHttpMethod(), requestEntity, responseType);
log.info("收到响应: {}", response);
long time2 = System.currentTimeMillis();
log.info("获取token(密码模式) 耗时:" + (time2 - time1) + "ms");
return response;
}
@@ -110,7 +112,7 @@ public class RestTemplateUtil {
}
public static AnYanResult<Object> getExchange(AnYanApiEnum api, HttpHeaders headers, String id) {
String url = getProperties().getHost() +api.getMethodPath()+ "/"+id;
String url = getProperties().getHost() + api.getMethodPath() + "/" + id;
HttpEntity<Object> requestEntity = new HttpEntity<>(headers);
return responseHandler(getRestTemplate().exchange(url, api.getHttpMethod(), requestEntity, AnYanResult.class));
}