Forráskód Böngészése

Merge remote-tracking branch 'origin/master'

zhaoyan 3 éve
szülő
commit
5a2f87519a

+ 1 - 1
api-common/src/main/java/api/common/util/JsonUtil.java

@@ -75,7 +75,7 @@ public class JsonUtil {
 
     public static JsonNode readTree(String json) {
         try {
-            JsonNode jsonNode = mapper.readTree(json);
+            return mapper.readTree(json);
         } catch (JsonProcessingException e) {
             e.printStackTrace();
         }

+ 7 - 5
simulation-resource-common/src/main/java/com/css/simulation/resource/common/controller/AlgPlatformCtrl.java

@@ -32,9 +32,12 @@ public class AlgPlatformCtrl {
     public ResponseBodyVO getAlgorithmList(@RequestBody String param) throws Exception {
         //取得token
         String token = getToken();
+        if(ObjectUtil.isNull(token)){
+           return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "获取算法平台token失败!");
+        }
         String algorithmListUri = clientDetail.getAlgorithmListUri() + "?access_token=" + token + param;
         String result = HttpUtil.get(HttpUtil.getHttpClient(), HttpUtil.getRequestConfig(), algorithmListUri);
-        ResponseBodyVO responseBodyVO= new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, "请求成功!", result);
+        ResponseBodyVO responseBodyVO = new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, "请求成功!", result);
         return responseBodyVO;
     }
 
@@ -47,14 +50,13 @@ public class AlgPlatformCtrl {
             String tokenUri = clientDetail.getTokenUri();
             String appid = clientDetail.getAppid();
             String secret = clientDetail.getSecret();
-            String URI = tokenUri + "?grant_type=client_credentials&appid=" + appid + "&secret=" + secret;
+            String URI = tokenUri + "?grant_type=client_credential&appid=" + appid + "&secret=" + secret;
             String result = HttpUtil.get(HttpUtil.getHttpClient(), HttpUtil.getRequestConfig(), URI);
             JsonNode jsonNode = JsonUtil.readTree(result);
             JsonNode dataNode = jsonNode.path("data");
             if(ObjectUtil.isNotNull(dataNode)){
-                JsonNode tokenNode  = dataNode.path("access_token");
-                if(ObjectUtil.isNotNull(tokenNode)){
-                    token = tokenNode.toString();
+                token = dataNode.path("access_token").asText();
+                if(ObjectUtil.isNotNull(token)){
                     int expiresSec = dataNode.path("expires_in_sec").asInt();
                     redisParameter.setMinutes(expiresSec / 60);
                     redisParameter.setValue(token);