🧑‍💻 Add a kernel API /api/filetree/removeDocByID

This commit is contained in:
Daniel 2024-11-27 09:35:07 +08:00
parent 30ea789fd3
commit 2fb42c5b8c
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 74 additions and 0 deletions

View file

@ -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)