🧑‍💻 Add a kernel API /api/filetree/renameDocByID https://github.com/siyuan-note/siyuan/issues/13105

This commit is contained in:
Daniel 2024-11-11 11:37:42 +08:00
parent 3922e48404
commit 7b9163d480
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 83 additions and 1 deletions

View file

@ -531,6 +531,37 @@ func renameDoc(c *gin.Context) {
return
}
func renameDocByID(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
if nil == arg["id"] {
return
}
id := arg["id"].(string)
title := arg["title"].(string)
tree, err := model.LoadTreeByBlockID(id)
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
ret.Data = map[string]interface{}{"closeTimeout": 7000}
return
}
err = model.RenameDoc(tree.Box, tree.Path, title)
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
return
}
}
func duplicateDoc(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)