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
|
* `fromIDs`: Source docs' IDs
|
||||||
* `toID`: Target parent ID
|
* `toID`: Target parent doc's ID or notebook ID
|
||||||
* Return value
|
* Return value
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
|
|
@ -478,7 +478,7 @@
|
||||||
```
|
```
|
||||||
|
|
||||||
* `fromIDs`:源文档 ID
|
* `fromIDs`:源文档 ID
|
||||||
* `toID`:目标父文档 ID
|
* `toID`:目标父文档 ID 或笔记本 ID
|
||||||
* 返回值
|
* 返回值
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue