Browse Source

fix:修改了修改表的接口,修改文档描述

master
Morning.Chen 2 years ago
parent
commit
4c633494ba
  1. 2
      README.md
  2. 24
      src/main/java/com/fanruan/hihidata/datasource/server/DatasourceOperation.java

2
README.md

@ -55,7 +55,7 @@ String tableId = operation.createTable("HelloTable", "#分组Id(可选)");
**特别注意:csv文件需要使用utf-8编码,其他编码均无法正确解析**
**注意:** 当前暂时不支持追加数据,仅支持全部替换数据
**注意:** 当前默认为全量覆盖表数据,如需切换到增量更新,参考接口/api/v1/datasource/table/modify
```java
Authentication authentication = new Authentication("#key", "#secret");

24
src/main/java/com/fanruan/hihidata/datasource/server/DatasourceOperation.java

@ -134,18 +134,36 @@ public class DatasourceOperation {
return data.getString("data");
}
/**
* 在指定的分组下创建 一个增量更新的数据源表
* @param tableName 数据源表名
* @param groupId 分组Id
* @return 数据源表Id
* @throws Exception 操作失败则抛出此异常
*/
public String createTableIncreased(String tableName, String groupId) throws Exception {
JSONObject body = new JSONObject();
body.put("tableName", tableName);
body.put("groupId", groupId);
body.put("increase", true);
HttpEntity entity = new StringEntity(body.toString(), StandardCharsets.UTF_8);
String res = HttpKits.post(String.format("%s/api/v1/datasource/table/create", ProjectConstants.BASE_URI), headers(), entity);
JSONObject data = new JSONObject(res);
return data.getString("data");
}
/**
* 修改已有的数据源表的名字
* @param tableId 数据源表Id
* @param newTableName 新的数据源表名字
* @param replaceOldData 是否后续的数据是替换原数据的true表示替换原数据false表示在原数据之后追加
* @param replaceOldData 是否后续的数据是替换原数据的true表示在原数据之后追加false表示替换原数据
* @throws Exception 操作失败则抛出此异常
*/
public void modifyTable(String tableId, String newTableName, boolean replaceOldData) throws Exception {
JSONObject body = new JSONObject();
body.put("tableId", tableId);
body.put("tableName", newTableName);
body.put("increase", !replaceOldData);
body.put("increase", replaceOldData);
HttpEntity entity = new StringEntity(body.toString(), StandardCharsets.UTF_8);
HttpKits.post(String.format("%s/api/v1/datasource/table/modify", ProjectConstants.BASE_URI), headers(), entity);
}
@ -160,7 +178,7 @@ public class DatasourceOperation {
JSONObject body = new JSONObject();
body.put("tableId", tableId);
HttpEntity entity = new StringEntity(body.toString(), StandardCharsets.UTF_8);
String res = HttpKits.post(String.format("%s/api/v1/datasource/upload/url", ProjectConstants.BASE_URI), headers(), entity);
String res = HttpKits.post(String.format("%s/api/v1/datasource/table/upload/url", ProjectConstants.BASE_URI), headers(), entity);
JSONObject data = new JSONObject(res);
return data.getString("data");
}

Loading…
Cancel
Save