🧑‍💻 Improve kernel API /api/filetree/moveDocsByID https://github.com/siyuan-note/siyuan/issues/15616

This commit is contained in:
Daniel 2025-08-25 16:33:38 +08:00
parent 29ac895046
commit 0a729d7c1b
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 19 additions and 8 deletions

2
API.md
View file

@ -480,7 +480,7 @@ Move documents by `id`:
```
* `fromIDs`: Source docs' IDs
* `toID`: Target parent ID
* `toID`: Target parent doc's ID or notebook ID
* Return value
```json

View file

@ -478,7 +478,7 @@
```
* `fromIDs`:源文档 ID
* `toID`:目标父文档 ID
* `toID`:目标父文档 ID 或笔记本 ID
* 返回值
```json

View file

@ -541,15 +541,26 @@ func moveDocsByID(c *gin.Context) {
}
fromPaths = gulu.Str.RemoveDuplicatedElem(fromPaths)
var box *model.Box
toTree, err := model.LoadTreeByBlockID(toID)
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
ret.Data = map[string]interface{}{"closeTimeout": 7000}
return
box = model.Conf.Box(toID)
if nil == box {
ret.Code = -1
ret.Msg = "can't found box or tree by id [" + toID + "]"
ret.Data = map[string]interface{}{"closeTimeout": 7000}
return
}
}
var toNotebook, toPath string
if nil != toTree {
toNotebook = toTree.Box
toPath = toTree.Path
} else if nil != box {
toNotebook = box.ID
toPath = "/"
}
toNotebook := toTree.Box
toPath := toTree.Path
callback := arg["callback"]
err = model.MoveDocs(fromPaths, toNotebook, toPath, callback)
if err != nil {