Skip to main content
Version: 2.2.1

SDK下载配置API

页面展示

img_19.png

介绍

  • 快速调用由DBAPI项目生成的http接口服务。

引入方式

  • 第一种方式:Maven 依赖方式(暂未上传私服);
<dependency>
<artifactId>dbapi-client</artifactId>
<name>dbapi</name>
<version>1.0.0</version>
<dependency>
  • 第二种方式,下载引入jar客户端,引入项目。

调用方式

1.1、创建RestClient(后台无需登录)

RestClient restClient =new RestClient("http://192.168.120.61:8882/");

1.2、创建RestClient(需要登录)

RestClient restClient =new RestClient("http://192.168.120.61:8882/","admin","password");

2.1、设置请求数据格式application/json;charset=utf-8 或 application/x-www-form-urlencoded(默认)

restClient.setContentType("application/json;charset=utf-8");

3.1、设置入参并调用示例(application/x-www-form-urlencoded格式)

 Map<String,Object> map=new HashMap<>();
map.put("pageNum",1);
map.put("pageSize",10);
String result=restClient.post("dataservice/api/paint/test",map)
System.out.println(result);

3.1、设置入参并调用示例(application/json格式,同时兼容map 方式传入,内部自动转换为json)

String body="{\"pageNum\":1,\"pageSize\":10}"
String result=restClient.post("dataservice/test/paint/test",body)
System.out.println(result);

4、完整示例

RestClient restClient =new RestClient("http://192.168.120.61:8882/");
Map<String,Object> map=new HashMap<>();
restClient.setContentType("application/json;charset=utf-8");
restClient.setAuthorization("10fd02d6167e4d440ec0b26a25391f74");
map.put("pageNum",1);
map.put("pageSize",10);
String body=JSONUtil.parse(map).toString();
System.out.println(restClient.post("dataservice/api/ces_jh_zwj001/test",body));

补充说明

以上接口入参信息用于示例说明,线上环境不一定能调用成功,实际接口需DBAPI提供且发布,具体URL、入参等信息已实际接口为准。