mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-02 23:08:49 +01:00
🎨 Kernel API transferBlockRef https://github.com/siyuan-note/siyuan/issues/8522
This commit is contained in:
parent
4153d22acb
commit
eda8da1bbe
4 changed files with 67 additions and 3 deletions
|
|
@ -47,7 +47,14 @@ func transferBlockRef(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
err := model.TransferBlockRef(fromID, toID)
|
||||
var refIDs []string
|
||||
if nil != arg["refIDs"] {
|
||||
for _, refID := range arg["refIDs"].([]interface{}) {
|
||||
refIDs = append(refIDs, refID.(string))
|
||||
}
|
||||
}
|
||||
|
||||
err := model.TransferBlockRef(fromID, toID, refIDs)
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ func RecentUpdatedBlocks() (ret []*Block) {
|
|||
return
|
||||
}
|
||||
|
||||
func TransferBlockRef(fromID, toID string) (err error) {
|
||||
func TransferBlockRef(fromID, toID string, refIDs []string) (err error) {
|
||||
toTree, _ := loadTreeByBlockID(toID)
|
||||
if nil == toTree {
|
||||
err = ErrBlockNotFound
|
||||
|
|
@ -132,7 +132,9 @@ func TransferBlockRef(fromID, toID string) (err error) {
|
|||
|
||||
util.PushMsg(Conf.Language(116), 7000)
|
||||
|
||||
refIDs, _ := sql.QueryRefIDsByDefID(fromID, false)
|
||||
if 1 > len(refIDs) { // 如果不指定 refIDs,则转移所有引用了 fromID 的块
|
||||
refIDs, _ = sql.QueryRefIDsByDefID(fromID, false)
|
||||
}
|
||||
for _, refID := range refIDs {
|
||||
tree, _ := loadTreeByBlockID(refID)
|
||||
if nil == tree {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue