mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-09 18:28:50 +01:00
🎨 Add some database related internal kernel APIs https://github.com/siyuan-note/siyuan/issues/10201
This commit is contained in:
parent
e51fb3cde7
commit
43042e8dc2
3 changed files with 131 additions and 31 deletions
|
|
@ -26,6 +26,61 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func addAttributeViewValues(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, _ := util.JsonArg(c, ret)
|
||||
if nil == arg {
|
||||
return
|
||||
}
|
||||
|
||||
avID := arg["avID"].(string)
|
||||
var srcIDs []string
|
||||
for _, v := range arg["srcIDs"].([]interface{}) {
|
||||
srcIDs = append(srcIDs, v.(string))
|
||||
}
|
||||
var previousID string
|
||||
if nil != arg["previousID"] {
|
||||
previousID = arg["previousID"].(string)
|
||||
}
|
||||
isDetached := arg["isDetached"].(bool)
|
||||
|
||||
err := model.AddAttributeViewBlock(nil, srcIDs, avID, previousID, isDetached)
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
pushRefreshAttrView(avID)
|
||||
}
|
||||
|
||||
func removeAttributeViewValues(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, _ := util.JsonArg(c, ret)
|
||||
if nil == arg {
|
||||
return
|
||||
}
|
||||
|
||||
avID := arg["avID"].(string)
|
||||
var srcIDs []string
|
||||
for _, v := range arg["srcIDs"].([]interface{}) {
|
||||
srcIDs = append(srcIDs, v.(string))
|
||||
}
|
||||
|
||||
err := model.RemoveAttributeViewBlock(srcIDs, avID)
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
pushRefreshAttrView(avID)
|
||||
}
|
||||
|
||||
func addAttributeViewCol(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
@ -48,6 +103,8 @@ func addAttributeViewCol(c *gin.Context) {
|
|||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
pushRefreshAttrView(avID)
|
||||
}
|
||||
|
||||
func removeAttributeViewCol(c *gin.Context) {
|
||||
|
|
@ -68,6 +125,8 @@ func removeAttributeViewCol(c *gin.Context) {
|
|||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
pushRefreshAttrView(avID)
|
||||
}
|
||||
|
||||
func sortAttributeViewCol(c *gin.Context) {
|
||||
|
|
@ -89,6 +148,8 @@ func sortAttributeViewCol(c *gin.Context) {
|
|||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
pushRefreshAttrView(avID)
|
||||
}
|
||||
|
||||
func getAttributeViewFilterSort(c *gin.Context) {
|
||||
|
|
@ -357,6 +418,11 @@ func setAttributeViewBlockAttr(c *gin.Context) {
|
|||
cellID := arg["cellID"].(string)
|
||||
value := arg["value"].(interface{})
|
||||
blockAttributeViewKeys := model.UpdateAttributeViewCell(nil, avID, keyID, rowID, cellID, value)
|
||||
util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]interface{}{"id": avID})
|
||||
ret.Data = blockAttributeViewKeys
|
||||
|
||||
pushRefreshAttrView(avID)
|
||||
}
|
||||
|
||||
func pushRefreshAttrView(avID string) {
|
||||
util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]interface{}{"id": avID})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue