From fd01ab84e2f420a2b812cf455042fe243d39a5b1 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sat, 1 Oct 2022 16:01:34 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E5=BC=8F=E5=8F=8D=E9=93=BE=E9=9D=A2=E6=9D=BF=20https://github.?= =?UTF-8?q?com/siyuan-note/siyuan/issues/3565?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/api/ref.go | 17 +++++++++++++++++ kernel/api/router.go | 1 + 2 files changed, 18 insertions(+) diff --git a/kernel/api/ref.go b/kernel/api/ref.go index 53d9267a9..16dcaa86c 100644 --- a/kernel/api/ref.go +++ b/kernel/api/ref.go @@ -38,6 +38,23 @@ func refreshBacklink(c *gin.Context) { model.RefreshBacklink(id) } +func getBackmentionDoc(c *gin.Context) { + ret := gulu.Ret.NewResult() + defer c.JSON(http.StatusOK, ret) + + arg, ok := util.JsonArg(c, ret) + if !ok { + return + } + + defID := arg["defID"].(string) + keyword := "" + backlinks := model.GetBackmentionDoc(defID, keyword) + ret.Data = map[string]interface{}{ + "backmentions": backlinks, + } +} + func getBacklinkDoc(c *gin.Context) { ret := gulu.Ret.NewResult() defer c.JSON(http.StatusOK, ret) diff --git a/kernel/api/router.go b/kernel/api/router.go index 54e4c475a..666ec4333 100644 --- a/kernel/api/router.go +++ b/kernel/api/router.go @@ -157,6 +157,7 @@ func ServeAPI(ginServer *gin.Engine) { ginServer.Handle("POST", "/api/ref/refreshBacklink", model.CheckAuth, refreshBacklink) ginServer.Handle("POST", "/api/ref/getBacklink", model.CheckAuth, getBacklink) ginServer.Handle("POST", "/api/ref/getBacklinkDoc", model.CheckAuth, getBacklinkDoc) + ginServer.Handle("POST", "/api/ref/getBackmentionDoc", model.CheckAuth, getBackmentionDoc) ginServer.Handle("POST", "/api/ref/createBacklink", model.CheckAuth, model.CheckReadonly, createBacklink) ginServer.Handle("POST", "/api/attr/getBookmarkLabels", model.CheckAuth, getBookmarkLabels)