From 3c821b3c5469ac5fc4660d33c3b998fb9005e889 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 19 十月 2021 11:08:03 +0800
Subject: [PATCH] 优化代码
---
service-job/src/main/java/com/java110/job/adapt/hcIot/GetToken.java | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/service-job/src/main/java/com/java110/job/adapt/hcIot/GetToken.java b/service-job/src/main/java/com/java110/job/adapt/hcIot/GetToken.java
old mode 100644
new mode 100755
index eb4f90e..78829bc
--- a/service-job/src/main/java/com/java110/job/adapt/hcIot/GetToken.java
+++ b/service-job/src/main/java/com/java110/job/adapt/hcIot/GetToken.java
@@ -35,14 +35,15 @@
@Java110Synchronized(value = "hc_get_token")
- public static String get(RestTemplate restTemplate) {
+ public static String get(RestTemplate restTemplate,boolean refreshAccessToken) {
String token = CommonCache.getValue(IotConstant.HC_TOKEN);
- if (!StringUtil.isEmpty(token)) {
+ if (!StringUtil.isEmpty(token) && !refreshAccessToken) {
return token;
}
HttpHeaders headers = new HttpHeaders();
HttpEntity httpEntity = new HttpEntity(headers);
- ResponseEntity<String> tokenRes = restTemplate.exchange(IotConstant.GET_TOKEN_URL, HttpMethod.GET, httpEntity, String.class);
+ String url = IotConstant.getUrl(IotConstant.GET_TOKEN_URL.replace("APP_ID", IotConstant.getAppId()).replace("APP_SECRET", IotConstant.getAppSecret()));
+ ResponseEntity<String> tokenRes = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class);
if (tokenRes.getStatusCode() != HttpStatus.OK) {
throw new IllegalArgumentException("鑾峰彇token澶辫触" + tokenRes.getBody());
--
Gitblit v1.8.0