Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
38bb1a6507
3 changed files with 78 additions and 0 deletions
|
@ -26,6 +26,42 @@ import (
|
|||
"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) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
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/searchAttributeView", model.CheckAuth, model.CheckReadonly, searchAttributeView)
|
||||
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/chatGPTWithAction", model.CheckAuth, chatGPTWithAction)
|
||||
|
|
|
@ -38,6 +38,46 @@ import (
|
|||
"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) {
|
||||
waitForSyncingStorages()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue