Browse Source

fix:新增数据源数据删除接口

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

59
README.md

@ -339,3 +339,62 @@ updateMode: 更新方式
}
```
#### 获取店铺信息
请求地址:```/api/v1/store/info```
请求类型:POST
请求参数: 无
返回值:
```json
{
"success": true,
"code": "200",
"message": "success",
"data": [
{
"id": "31ea502409f249cf95a361c17088a3ee",
"name": "店铺"
}
]
}
```
#### 申请删除数据源数据(防止误删除,您必须先获取令牌,然后使用令牌删除您的数据)
请求地址:```/api/v1/store/data/delete/apply```
请求类型:POST
请求参数: 无
返回值:
```json
{
"success": true,
"code": "200",
"message": "success",
"data": "7d08cb01"
}
```
#### 删除数据源数据
请求地址:```/api/v1/store/data/delete```
请求类型:POST
请求参数: ```{
"token": "7d08cb01",
"storeId": "31ea502409f249cf95a361c17088a3ee"
}```
返回值:
```json
{
"success": true,
"code": "200",
"message": "success",
"data": true
}
```

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

@ -240,6 +240,38 @@ public class DatasourceOperation {
return data.getJSONArray("data");
}
/**
* 获取删除数据源数据token
*/
public JSONArray storeInfo() throws Exception {
String res = HttpKits.post(String.format("%s/api/v1/store/info", ProjectConstants.BASE_URI), headers());
JSONObject data = new JSONObject(res);
return data.getJSONArray("data");
}
/**
* 获取删除数据源数据token
*/
public String dataDeleteApply() throws Exception {
String res = HttpKits.post(String.format("%s/api/v1/store/data/delete/apply", ProjectConstants.BASE_URI), headers());
JSONObject data = new JSONObject(res);
return data.getString("data");
}
/**
* 删除数据源数据
*/
public boolean dataDelete(String token, String storeId) throws Exception {
JSONObject body = new JSONObject();
body.put("token", token);
body.put("storeId", storeId);
HttpEntity entity = new StringEntity(body.toString(), StandardCharsets.UTF_8);
String res = HttpKits.post(String.format("%s/api/v1/store/data/delete", ProjectConstants.BASE_URI), headers(), entity);
JSONObject data = new JSONObject(res);
return data.getBoolean("data");
}
/**
* 删除API数据源下的所有分组和表
* @throws Exception 操作失败则抛出此异常

Loading…
Cancel
Save