🧑‍💻 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 * `fromIDs`: Source docs' IDs
* `toID`: Target parent ID * `toID`: Target parent doc's ID or notebook ID
* Return value * Return value
```json ```json

View file

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

View file

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