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

This commit is contained in:
Daniel 2025-03-04 20:22:48 +08:00
parent 2d2420794c
commit f8e6f02df8
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017
4 changed files with 17 additions and 7 deletions

7
API.md
View File

@ -544,7 +544,7 @@ Move documents by `id`:
```json ```json
{ {
"id": "20210917220056-yxtyl7i" "id": "20210808180320-fqgskfj"
} }
``` ```
@ -555,7 +555,10 @@ Move documents by `id`:
{ {
"code": 0, "code": 0,
"msg": "", "msg": "",
"data": "/20210828150719-r8edxl2/20210917220056-yxtyl7i.sy" "data": {
"notebook": "20210808180117-czj9bvb",
"path": "/20200812220555-lj3enxa/20210808180320-fqgskfj.sy"
}
} }
``` ```

View File

@ -542,7 +542,7 @@
```json ```json
{ {
"id": "20210917220056-yxtyl7i" "id": "20210808180320-fqgskfj"
} }
``` ```
@ -553,7 +553,10 @@
{ {
"code": 0, "code": 0,
"msg": "", "msg": "",
"data": "/20210828150719-r8edxl2/20210917220056-yxtyl7i.sy" "data": {
"notebook": "20210808180117-czj9bvb",
"path": "/20200812220555-lj3enxa/20210808180320-fqgskfj.sy"
}
} }
``` ```

View File

@ -368,13 +368,16 @@ func getPathByID(c *gin.Context) {
return return
} }
_path, err := model.GetPathByID(id) p, notebook, err := model.GetPathByID(id)
if err != nil { if err != nil {
ret.Code = -1 ret.Code = -1
ret.Msg = err.Error() ret.Msg = err.Error()
return return
} }
ret.Data = _path ret.Data = map[string]interface{}{
"path": p,
"notebook": notebook,
}
} }
func getFullHPathByID(c *gin.Context) { func getFullHPathByID(c *gin.Context) {

View File

@ -1213,13 +1213,14 @@ func GetHPathByID(id string) (hPath string, err error) {
return return
} }
func GetPathByID(id string) (path string, err error) { func GetPathByID(id string) (path, boxID string, err error) {
tree, err := LoadTreeByBlockID(id) tree, err := LoadTreeByBlockID(id)
if err != nil { if err != nil {
return return
} }
path = tree.Path path = tree.Path
boxID = tree.Box
return return
} }