API pom完善

This commit is contained in:
huzhengkao 2025-05-22 16:17:07 +08:00
parent 73a6924eef
commit 4a77e8e9cb
3 changed files with 56 additions and 8 deletions

View File

@ -68,6 +68,13 @@
<artifactId>tcctyn-common-core</artifactId>
</dependency>
<!--Artemis HTTP Client 海康OpenAPI 安全认证库-->
<dependency>
<groupId>com.hikvision.ga</groupId>
<artifactId>artemis-http-client</artifactId>
<version>1.1.3</version>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,49 @@
package com.tcctyn.iot.hk;
import com.alibaba.fastjson.JSON;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import java.util.HashMap;
import java.util.Map;
/**
* @author Jason
* @date 2025年05月22日 15:13:09
*/
public class TestApi {
private static final String ARTEMIS_PATH = "/artemis";
/**
* 调用POST请求类型接口这里以获取组织列表为例
* 接口实际url:https://ip:port/artemis/api/resource/v1/org/orgList
* @return
*/
public static String callPostApiGetOrgList() throws Exception {
/**
* https://ip:port/artemis/api/resource/v1/org/orgList
* 通过查阅AI Cloud开放平台文档或网关门户的文档可以看到获取组织列表的接口定义,该接口为POST请求的Rest接口, 入参为JSON字符串接口协议为https
* ArtemisHttpUtil工具类提供了doPostStringArtemis调用POST请求的方法入参可传JSON字符串, 请阅读开发指南了解方法入参没有的参数可传null
*/
ArtemisConfig config = new ArtemisConfig();
config.setHost("116.53.205.228:14443"); // 代理API网关nginx服务器ip端口
config.setAppKey("21887937"); // 秘钥appkey
config.setAppSecret("lofnD6DbnBllHmk5YOyx");// 秘钥appSecret
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/orgList";
Map<String, String> paramMap = new HashMap<String, String>();// post请求Form表单参数
paramMap.put("pageNo", "1");
paramMap.put("pageSize", "2");
String body = JSON.toJSON(paramMap).toString();
Map<String, String> path = new HashMap<String, String>(2) {
{
put("https://", getCamsApi);
}
};
return ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json");
}
public static void main(String[] args) throws Exception {
callPostApiGetOrgList();
}
}

View File

@ -1,8 +0,0 @@
package com.tcctyn.iot.hk;
/**
* @author Jason
* @date 2025年05月22日 15:13:09
*/
public class test {
}