mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🧑💻 Improve kernel API /api/filetree/moveDocsByID
https://github.com/siyuan-note/siyuan/issues/15616
This commit is contained in:
parent
29ac895046
commit
0a729d7c1b
3 changed files with 19 additions and 8 deletions
2
API.md
2
API.md
|
@ -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
|
||||
|
|
|
@ -478,7 +478,7 @@
|
|||
```
|
||||
|
||||
* `fromIDs`:源文档 ID
|
||||
* `toID`:目标父文档 ID
|
||||
* `toID`:目标父文档 ID 或笔记本 ID
|
||||
* 返回值
|
||||
|
||||
```json
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue