mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-17 01:21:14 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
38bb1a6507
@ -26,6 +26,42 @@ import (
|
|||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func searchAttributeViewNonRelationKey(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)
|
||||||
|
keyword := arg["keyword"].(string)
|
||||||
|
|
||||||
|
nonRelationKeys := model.SearchAttributeViewNonRelationKey(avID, keyword)
|
||||||
|
ret.Data = map[string]interface{}{
|
||||||
|
"nonRelationKeys": nonRelationKeys,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func searchAttributeViewRelationKey(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)
|
||||||
|
keyword := arg["keyword"].(string)
|
||||||
|
|
||||||
|
relationKeys := model.SearchAttributeViewRelationKey(avID, keyword)
|
||||||
|
ret.Data = map[string]interface{}{
|
||||||
|
"relationKeys": relationKeys,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getAttributeView(c *gin.Context) {
|
func getAttributeView(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
@ -391,6 +391,8 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||||||
ginServer.Handle("POST", "/api/av/setAttributeViewBlockAttr", model.CheckAuth, model.CheckReadonly, setAttributeViewBlockAttr)
|
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/searchAttributeView", model.CheckAuth, model.CheckReadonly, searchAttributeView)
|
||||||
ginServer.Handle("POST", "/api/av/getAttributeView", model.CheckAuth, model.CheckReadonly, getAttributeView)
|
ginServer.Handle("POST", "/api/av/getAttributeView", model.CheckAuth, model.CheckReadonly, getAttributeView)
|
||||||
|
ginServer.Handle("POST", "/api/av/searchAttributeViewRelationKey", model.CheckAuth, model.CheckReadonly, searchAttributeViewRelationKey)
|
||||||
|
ginServer.Handle("POST", "/api/av/searchAttributeViewNonRelationKey", model.CheckAuth, model.CheckReadonly, searchAttributeViewNonRelationKey)
|
||||||
|
|
||||||
ginServer.Handle("POST", "/api/ai/chatGPT", model.CheckAuth, chatGPT)
|
ginServer.Handle("POST", "/api/ai/chatGPT", model.CheckAuth, chatGPT)
|
||||||
ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, chatGPTWithAction)
|
ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, chatGPTWithAction)
|
||||||
|
@ -38,6 +38,46 @@ import (
|
|||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func SearchAttributeViewNonRelationKey(avID, keyword string) (ret []*av.Key) {
|
||||||
|
waitForSyncingStorages()
|
||||||
|
|
||||||
|
ret = []*av.Key{}
|
||||||
|
attrView, err := av.ParseAttributeView(avID)
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, keyValues := range attrView.KeyValues {
|
||||||
|
if av.KeyTypeRelation != keyValues.Key.Type {
|
||||||
|
if strings.Contains(strings.ToLower(keyValues.Key.Name), strings.ToLower(keyword)) {
|
||||||
|
ret = append(ret, keyValues.Key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func SearchAttributeViewRelationKey(avID, keyword string) (ret []*av.Key) {
|
||||||
|
waitForSyncingStorages()
|
||||||
|
|
||||||
|
ret = []*av.Key{}
|
||||||
|
attrView, err := av.ParseAttributeView(avID)
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, keyValues := range attrView.KeyValues {
|
||||||
|
if av.KeyTypeRelation == keyValues.Key.Type && nil != keyValues.Key.Relation {
|
||||||
|
if strings.Contains(strings.ToLower(keyValues.Key.Name), strings.ToLower(keyword)) {
|
||||||
|
ret = append(ret, keyValues.Key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func GetAttributeView(avID string) (ret *av.AttributeView) {
|
func GetAttributeView(avID string) (ret *av.AttributeView) {
|
||||||
waitForSyncingStorages()
|
waitForSyncingStorages()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user