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