From a5353feebdef3812ea7692603263fe0217d5bc15 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期四, 20 三月 2025 09:41:02 +0800 Subject: [PATCH] Merge branch 'master' of http://dlindusit.com:53929/r/iailab-plat-sdk-demo --- src/test/java/com/iailab/sdk/demo/HttpClientDemoTest.java | 23 +++-------------------- src/main/resources/application.yaml | 8 ++++---- README.md | 6 +++--- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 446a122..b2f1546 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ * `iailab-plat-sdk-1.0.0.jar`包内不包含依赖包,使用的时候需要引用其依赖;`iailab-plat-sdk-1.0.0-jar-with-dependencies.jar`内已经包含依赖,二者用其一 * 获取平台授权token后可以自行存储封装`accessToken`和`refreshToken`,在请求平台接口时,将`accessToken`和`tenantId`按照下图添加到请求headers中  -* 鉴权token `accessToken`和刷新token `refreshToken`有效期都是在平台配置配置的,当鉴权token过期后,使用`refreshToken`重新刷新accessToken并存储使用(IailabAuthClient.refreshToken()); - 当刷新`refreshToken`也过期后,需要重新请求授权接口授权(`IailabAuthClient.authenticate()`) -* 租户id:`tenant-id`、租户OAuth2客户端id:`client-id`、租户OAuth2客户端密钥:`client-secret`、租户登录账号:`username`、租户登录密码:`password`都是在平台事先配置好的 +* 鉴权token `accessToken`和刷新token `refreshToken`有效期都是在平台配置配置的,当鉴权token过期后,使用`refreshToken`重新刷新accessToken并存储使用(IailabClient.refreshToken()); + 当刷新`refreshToken`也过期后,需要重新请求授权接口授权(`IailabClient.authenticate()`) +* 租户id:`tenant-id`、租户OAuth2客户端id:`client-id`、租户OAuth2客户端密钥:`client-secret`、租户登录账号:`username`是在平台事先配置好的 * 此demo使用`HttpClientDemoTest`进行的测试  diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index aa2df5c..62d4de5 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -12,9 +12,9 @@ iailab: token: base-url: http://172.16.8.100/admin-api #平台接口url,使用时需修改成真实的ip和端口 - tenant-id: 176 #租户id - client-id: ansteel #租户OAuth2客户端id - client-secret: ansteel111111111111111 #租户OAuth2客户端密钥 - username: ansteel #租户登录账号 + tenant-id: 172 #租户id + client-id: shasteel #租户OAuth2客户端id + client-secret: S3mYv7LkF1xJtQqWp9rZ2cVb8N6hT0D #租户OAuth2客户端密钥 + username: shasteel debug: true diff --git a/src/test/java/com/iailab/sdk/demo/HttpClientDemoTest.java b/src/test/java/com/iailab/sdk/demo/HttpClientDemoTest.java index c2b6895..7a62ee0 100644 --- a/src/test/java/com/iailab/sdk/demo/HttpClientDemoTest.java +++ b/src/test/java/com/iailab/sdk/demo/HttpClientDemoTest.java @@ -1,6 +1,5 @@ package com.iailab.sdk.demo; -import com.alibaba.fastjson.JSONObject; import com.iailab.sdk.auth.client.common.pojo.CommonResult; import org.junit.Test; import org.junit.runner.RunWith; @@ -8,8 +7,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -import java.util.ArrayList; -import java.util.List; import java.util.Map; @@ -21,7 +18,7 @@ private HttpClientDemo httpClientDemo; - /*@Test + @Test public void authenticate() { httpClientDemo.authenticate(); } @@ -31,16 +28,11 @@ httpClientDemo.refreshToken(); } - @Test - public void testQueryPlanChart() throws Exception { - Map<String, Object> stringObjectMap = httpClientDemo.queryPlanChart(); - System.out.println(stringObjectMap); - } @Test public void testQueryPointsRealValue() throws Exception { - Map<String, Object> stringObjectMap = httpClientDemo.queryPointsRealValue(); - System.out.println(stringObjectMap); + CommonResult<Map<String, Object>> mapCommonResult = httpClientDemo.queryPointsRealValue(); + System.out.println(mapCommonResult.getData()); } @Test @@ -53,14 +45,5 @@ public void testDoHttpGet() throws Exception { // 准备参数 httpClientDemo.doHttpGet(); - }*/ - - @Test - public void testDoHttpGet() throws Exception { - // 准备参数 - List<String> params = new ArrayList<String>(); - params.add("M0000101153"); - CommonResult<Map<String, Object>> mapCommonResult = httpClientDemo.queryPointsRealValue(params); - System.out.println(JSONObject.toJSONString(mapCommonResult)); } } -- Gitblit v1.9.3