mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🎨 Add a kernel internal api /api/av/getAttributeViewKeysByID
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
01ed3fe4c4
commit
cf3e9ca081
3 changed files with 33 additions and 3 deletions
|
|
@ -225,7 +225,24 @@ func getAttributeViewKeysByAvID(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
avID := arg["avID"].(string)
|
||||
ret.Data = model.GetAttributeViewKeysByAvID(avID)
|
||||
ret.Data = model.GetAttributeViewKeysByID(avID)
|
||||
}
|
||||
|
||||
func getAttributeViewKeysByID(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
avID := arg["avID"].(string)
|
||||
keyIDsArg := arg["keyIDs"].([]interface{})
|
||||
var keyIDs []string
|
||||
for _, v := range keyIDsArg {
|
||||
keyIDs = append(keyIDs, v.(string
|
||||
}
|
||||
ret.Data = model.GetAttributeViewKeysByID(avID, keyIDs...)
|
||||
}
|
||||
|
||||
func getMirrorDatabaseBlocks(c *gin.Context) {
|
||||
|
|
|
|||
|
|
@ -461,6 +461,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/av/setDatabaseBlockView", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setDatabaseBlockView)
|
||||
ginServer.Handle("POST", "/api/av/getMirrorDatabaseBlocks", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, getMirrorDatabaseBlocks)
|
||||
ginServer.Handle("POST", "/api/av/getAttributeViewKeysByAvID", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, getAttributeViewKeysByAvID)
|
||||
ginServer.Handle("POST", "/api/av/getAttributeViewKeysByID", model.CheckAuth, getAttributeViewKeysByID)
|
||||
ginServer.Handle("POST", "/api/av/duplicateAttributeViewBlock", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, duplicateAttributeViewBlock)
|
||||
ginServer.Handle("POST", "/api/av/appendAttributeViewDetachedBlocksWithValues", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, appendAttributeViewDetachedBlocksWithValues)
|
||||
ginServer.Handle("POST", "/api/av/getCurrentAttrViewImages", model.CheckAuth, getCurrentAttrViewImages)
|
||||
|
|
|
|||
|
|
@ -1179,7 +1179,7 @@ func DuplicateDatabaseBlock(avID string) (newAvID, newBlockID string, err error)
|
|||
return
|
||||
}
|
||||
|
||||
func GetAttributeViewKeysByAvID(avID string) (ret []*av.Key) {
|
||||
func GetAttributeViewKeysByID(avID string, keyIDs ...string) (ret []*av.Key) {
|
||||
ret = []*av.Key{}
|
||||
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
|
|
@ -1188,9 +1188,21 @@ func GetAttributeViewKeysByAvID(avID string) (ret []*av.Key) {
|
|||
return
|
||||
}
|
||||
|
||||
if 1 > len(keyIDs) {
|
||||
for _, keyValues := range attrView.KeyValues {
|
||||
key := keyValues.Key
|
||||
ret = append(ret, key)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
for _, keyValues := range attrView.KeyValues {
|
||||
key := keyValues.Key
|
||||
ret = append(ret, key)
|
||||
for _, keyID := range keyIDs {
|
||||
if key.ID == keyID {
|
||||
ret = append(ret, key)
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue