From 29f73e1ef9a02ab6eadb1ca7c6a89dc0bc685de2 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 21 Dec 2022 15:07:16 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=94=AF=E6=8C=81=E9=97=B4=E9=9A=94?= =?UTF-8?q?=E5=A4=8D=E4=B9=A0=20https://github.com/siyuan-note/siyuan/issu?= =?UTF-8?q?es/6710?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/api/riff.go | 33 +++++++++++++++++++++++---------- kernel/api/router.go | 1 + 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/kernel/api/riff.go b/kernel/api/riff.go index 2f5d4b82c..6acb1a130 100644 --- a/kernel/api/riff.go +++ b/kernel/api/riff.go @@ -17,13 +17,33 @@ package api import ( + "net/http" + "github.com/88250/gulu" "github.com/gin-gonic/gin" "github.com/siyuan-note/siyuan/kernel/model" "github.com/siyuan-note/siyuan/kernel/util" - "net/http" ) +func addRiffCard(c *gin.Context) { + ret := gulu.Ret.NewResult() + defer c.JSON(http.StatusOK, ret) + + arg, ok := util.JsonArg(c, ret) + if !ok { + return + } + + deckName := arg["deck"].(string) + blockID := arg["blockID"].(string) + err := model.AddFlashcard(blockID, deckName) + if nil != err { + ret.Code = -1 + ret.Msg = err.Error() + return + } +} + func createRiffDeck(c *gin.Context) { ret := gulu.Ret.NewResult() defer c.JSON(http.StatusOK, ret) @@ -33,18 +53,11 @@ func createRiffDeck(c *gin.Context) { return } - id := arg["id"].(string) - id, rootID, content, isLargeDoc, err := model.OpenRepoSnapshotDoc(id) + name := arg["name"].(string) + err := model.CreateDeck(name) if nil != err { ret.Code = -1 ret.Msg = err.Error() return } - - ret.Data = map[string]interface{}{ - "id": id, - "rootID": rootID, - "content": content, - "isLargeDoc": isLargeDoc, - } } diff --git a/kernel/api/router.go b/kernel/api/router.go index 62fb8b8e1..3234aac24 100644 --- a/kernel/api/router.go +++ b/kernel/api/router.go @@ -300,6 +300,7 @@ func ServeAPI(ginServer *gin.Engine) { ginServer.Handle("POST", "/api/repo/openRepoSnapshotDoc", model.CheckAuth, openRepoSnapshotDoc) ginServer.Handle("POST", "/api/riff/createRiffDeck", model.CheckAuth, createRiffDeck) + ginServer.Handle("POST", "/api/riff/addRiffCard", model.CheckAuth, addRiffCard) ginServer.Handle("POST", "/api/notification/pushMsg", model.CheckAuth, pushMsg) ginServer.Handle("POST", "/api/notification/pushErrMsg", model.CheckAuth, pushErrMsg)