🧑💻 Add a kernel API /api/filetree/removeDocByID
This commit is contained in:
parent
30ea789fd3
commit
2fb42c5b8c
4 changed files with 74 additions and 0 deletions
22
API.md
22
API.md
|
@ -416,6 +416,28 @@ Rename a document by `id`:
|
|||
"data": null
|
||||
}
|
||||
```
|
||||
|
||||
Remove a document by `id`:
|
||||
|
||||
* `/api/filetree/removeDocByID`
|
||||
* Parameters
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "20210902210113-0avi12f"
|
||||
}
|
||||
```
|
||||
|
||||
* `id`: Document ID
|
||||
* Return value
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "",
|
||||
"data": null
|
||||
}
|
||||
```
|
||||
|
||||
### Move documents
|
||||
|
||||
|
|
22
API_zh_CN.md
22
API_zh_CN.md
|
@ -416,6 +416,28 @@
|
|||
"data": null
|
||||
}
|
||||
```
|
||||
|
||||
通过 `id` 删除文档:
|
||||
|
||||
* `/api/filetree/removeDocByID`
|
||||
* 参数
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "20210902210113-0avi12f"
|
||||
}
|
||||
```
|
||||
|
||||
* `id`:文档 ID
|
||||
* 返回值
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "",
|
||||
"data": null
|
||||
}
|
||||
```
|
||||
|
||||
### 移动文档
|
||||
|
||||
|
|
|
@ -502,6 +502,31 @@ func removeDoc(c *gin.Context) {
|
|||
model.RemoveDoc(notebook, p)
|
||||
}
|
||||
|
||||
func removeDocByID(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
id := arg["id"].(string)
|
||||
if util.InvalidIDPattern(id, ret) {
|
||||
return
|
||||
}
|
||||
|
||||
tree, err := model.LoadTreeByBlockID(id)
|
||||
if err != nil {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 7000}
|
||||
return
|
||||
}
|
||||
|
||||
model.RemoveDoc(tree.Box, tree.Path)
|
||||
}
|
||||
|
||||
func removeDocs(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
@ -558,6 +583,10 @@ func renameDocByID(c *gin.Context) {
|
|||
}
|
||||
|
||||
id := arg["id"].(string)
|
||||
if util.InvalidIDPattern(id, ret) {
|
||||
return
|
||||
}
|
||||
|
||||
title := arg["title"].(string)
|
||||
|
||||
tree, err := model.LoadTreeByBlockID(id)
|
||||
|
|
|
@ -105,6 +105,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/filetree/renameDoc", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, renameDoc)
|
||||
ginServer.Handle("POST", "/api/filetree/renameDocByID", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, renameDocByID)
|
||||
ginServer.Handle("POST", "/api/filetree/removeDoc", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, removeDoc)
|
||||
ginServer.Handle("POST", "/api/filetree/removeDocByID", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, removeDocByID)
|
||||
ginServer.Handle("POST", "/api/filetree/removeDocs", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, removeDocs)
|
||||
ginServer.Handle("POST", "/api/filetree/moveDocs", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, moveDocs)
|
||||
ginServer.Handle("POST", "/api/filetree/duplicateDoc", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, duplicateDoc)
|
||||
|
|
Loading…
Add table
Reference in a new issue