mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
🎨 Add an internal kernel API /api/av/appendAttributeViewDetachedBlocksWithValues https://github.com/siyuan-note/siyuan/issues/11608
This commit is contained in:
parent
672eae0574
commit
4e2de612d7
4 changed files with 121 additions and 15 deletions
|
|
@ -135,7 +135,49 @@ func getAttributeViewPrimaryKeyValues(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func addAttributeViewValues(c *gin.Context) {
|
||||
func appendAttributeViewDetachedBlocksWithValues(c *gin.Context) {
|
||||
// Add an internal kernel API `/api/av/appendAttributeViewDetachedBlocksWithValues` https://github.com/siyuan-note/siyuan/issues/11608
|
||||
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, _ := util.JsonArg(c, ret)
|
||||
if nil == arg {
|
||||
return
|
||||
}
|
||||
|
||||
avID := arg["avID"].(string)
|
||||
var values [][]*av.Value
|
||||
for _, blocksVals := range arg["blocksValues"].([]interface{}) {
|
||||
vals := blocksVals.([]interface{})
|
||||
var rowValues []*av.Value
|
||||
for _, val := range vals {
|
||||
data, marshalErr := gulu.JSON.MarshalJSON(val)
|
||||
if nil != marshalErr {
|
||||
ret.Code = -1
|
||||
ret.Msg = marshalErr.Error()
|
||||
return
|
||||
}
|
||||
value := av.Value{}
|
||||
if unmarshalErr := gulu.JSON.UnmarshalJSON(data, &value); nil != unmarshalErr {
|
||||
ret.Code = -1
|
||||
ret.Msg = unmarshalErr.Error()
|
||||
return
|
||||
}
|
||||
rowValues = append(rowValues, &value)
|
||||
}
|
||||
values = append(values, rowValues)
|
||||
}
|
||||
|
||||
err := model.AppendAttributeViewDetachedBlocksWithValues(avID, values)
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func addAttributeViewBlocks(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
|
|
@ -173,7 +215,7 @@ func addAttributeViewValues(c *gin.Context) {
|
|||
util.PushReloadAttrView(avID)
|
||||
}
|
||||
|
||||
func removeAttributeViewValues(c *gin.Context) {
|
||||
func removeAttributeViewBlocks(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
|
|
|
|||
|
|
@ -419,13 +419,14 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/av/removeAttributeViewKey", model.CheckAuth, model.CheckReadonly, removeAttributeViewKey)
|
||||
ginServer.Handle("POST", "/api/av/sortAttributeViewViewKey", model.CheckAuth, model.CheckReadonly, sortAttributeViewViewKey)
|
||||
ginServer.Handle("POST", "/api/av/sortAttributeViewKey", model.CheckAuth, model.CheckReadonly, sortAttributeViewKey)
|
||||
ginServer.Handle("POST", "/api/av/addAttributeViewValues", model.CheckAuth, model.CheckReadonly, addAttributeViewValues)
|
||||
ginServer.Handle("POST", "/api/av/removeAttributeViewValues", model.CheckAuth, model.CheckReadonly, removeAttributeViewValues)
|
||||
ginServer.Handle("POST", "/api/av/addAttributeViewBlocks", model.CheckAuth, model.CheckReadonly, addAttributeViewBlocks)
|
||||
ginServer.Handle("POST", "/api/av/removeAttributeViewBlocks", model.CheckAuth, model.CheckReadonly, removeAttributeViewBlocks)
|
||||
ginServer.Handle("POST", "/api/av/getAttributeViewPrimaryKeyValues", model.CheckAuth, model.CheckReadonly, getAttributeViewPrimaryKeyValues)
|
||||
ginServer.Handle("POST", "/api/av/setDatabaseBlockView", model.CheckAuth, model.CheckReadonly, setDatabaseBlockView)
|
||||
ginServer.Handle("POST", "/api/av/getMirrorDatabaseBlocks", model.CheckAuth, model.CheckReadonly, getMirrorDatabaseBlocks)
|
||||
ginServer.Handle("POST", "/api/av/getAttributeViewKeysByAvID", model.CheckAuth, model.CheckReadonly, getAttributeViewKeysByAvID)
|
||||
ginServer.Handle("POST", "/api/av/duplicateAttributeViewBlock", model.CheckAuth, model.CheckReadonly, duplicateAttributeViewBlock)
|
||||
ginServer.Handle("POST", "/api/av/appendAttributeViewDetachedBlocksWithValues", model.CheckAuth, model.CheckReadonly, appendAttributeViewDetachedBlocksWithValues)
|
||||
|
||||
ginServer.Handle("POST", "/api/ai/chatGPT", model.CheckAuth, chatGPT)
|
||||
ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, chatGPTWithAction)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue