mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Add Relation and Rollup column to database table view https://github.com/siyuan-note/siyuan/issues/9888
This commit is contained in:
parent
62e92c0e6b
commit
c916cd0c23
3 changed files with 27 additions and 3 deletions
|
|
@ -26,6 +26,22 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func getAttributeView(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, _ := util.JsonArg(c, ret)
|
||||
if nil == arg {
|
||||
return
|
||||
}
|
||||
|
||||
id := arg["id"].(string)
|
||||
av := model.GetAttributeView(id)
|
||||
ret.Data = map[string]interface{}{
|
||||
"av": av,
|
||||
}
|
||||
}
|
||||
|
||||
func searchAttributeView(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
|
|||
|
|
@ -387,6 +387,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/av/getAttributeViewKeys", model.CheckAuth, getAttributeViewKeys)
|
||||
ginServer.Handle("POST", "/api/av/setAttributeViewBlockAttr", model.CheckAuth, model.CheckReadonly, setAttributeViewBlockAttr)
|
||||
ginServer.Handle("POST", "/api/av/searchAttributeView", model.CheckAuth, model.CheckReadonly, searchAttributeView)
|
||||
ginServer.Handle("POST", "/api/av/getAttributeView", model.CheckAuth, model.CheckReadonly, getAttributeView)
|
||||
|
||||
ginServer.Handle("POST", "/api/ai/chatGPT", model.CheckAuth, chatGPT)
|
||||
ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, chatGPTWithAction)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,13 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func GetAttributeView(avID string) (ret *av.AttributeView) {
|
||||
waitForSyncingStorages()
|
||||
|
||||
ret, _ = av.ParseAttributeView(avID)
|
||||
return
|
||||
}
|
||||
|
||||
type SearchAttributeViewResult struct {
|
||||
AvID string `json:"avID"`
|
||||
AvName string `json:"avName"`
|
||||
|
|
@ -721,18 +728,18 @@ func (tx *Transaction) doUpdateAttrViewColRelation(operation *Operation) (ret *T
|
|||
}
|
||||
|
||||
func updateAttributeViewColRelation(operation *Operation) (err error) {
|
||||
err = updateAttributeViewColRelation0(operation.AvID, operation.KeyID, operation.ID, operation.IsBiRelation, operation.BackRelationKeyID)
|
||||
err = updateAttributeViewColRelation0(operation.AvID, operation.KeyID, operation.ID, operation.IsBiRelation, operation.BackRelationKeyID, operation.Name)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
if operation.IsBiRelation {
|
||||
err = updateAttributeViewColRelation0(operation.ID, operation.BackRelationKeyID, operation.AvID, operation.IsBiRelation, operation.KeyID)
|
||||
err = updateAttributeViewColRelation0(operation.ID, operation.BackRelationKeyID, operation.AvID, operation.IsBiRelation, operation.KeyID, operation.Name)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func updateAttributeViewColRelation0(avID, relKeyID, destAvID string, isBiRel bool, backRelKeyID string) (err error) {
|
||||
func updateAttributeViewColRelation0(avID, relKeyID, destAvID string, isBiRel bool, backRelKeyID, backRelKeyName string) (err error) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if nil != err {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue