Browse Source

fix:新增导出接口

master
Morning.Chen 2 years ago
parent
commit
e9d87b5867
  1. 35
      src/main/java/com/fanruan/hihidata/datasource/server/DatasourceOperation.java

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

@ -8,6 +8,7 @@ import org.json.JSONObject;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -206,7 +207,39 @@ public class DatasourceOperation {
HttpEntity entity = new StringEntity(body.toString(), StandardCharsets.UTF_8);
HttpKits.post(String.format("%s/api/v1/datasource/table/delete", ProjectConstants.BASE_URI), headers(), entity);
}
/**
* 导出分析表csv文件
*
* @param tableId 数据源表Id
* @throws Exception 操作失败则抛出此异常
*/
public String exportTable(String tableId) throws Exception {
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/export", ProjectConstants.BASE_URI), headers(), entity);
JSONObject data = new JSONObject(res);
return data.getString("data");
}
/**
* 批量导出分析表csv文件
*
* @param tableIds 数据源表Ids
* @throws Exception 操作失败则抛出此异常
* @return
*/
public JSONArray exportTableBatch(List<String> tableIds) throws Exception {
JSONObject body = new JSONObject();
body.put("tableIds", tableIds);
HttpEntity entity = new StringEntity(body.toString(), StandardCharsets.UTF_8);
String res = HttpKits.post(String.format("%s/api/v1/export/batch", ProjectConstants.BASE_URI), headers(), entity);
JSONObject data = new JSONObject(res);
return data.getJSONArray("data");
}
/**
* 删除API数据源下的所有分组和表
* @throws Exception 操作失败则抛出此异常

Loading…
Cancel
Save