This commit is contained in:
Liang Ding 2022-12-21 15:07:16 +08:00
parent 42c09e2fad
commit 29f73e1ef9
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
2 changed files with 24 additions and 10 deletions

View File

@ -17,13 +17,33 @@
package api package api
import ( import (
"net/http"
"github.com/88250/gulu" "github.com/88250/gulu"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/siyuan-note/siyuan/kernel/model" "github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/util" "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) { func createRiffDeck(c *gin.Context) {
ret := gulu.Ret.NewResult() ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret) defer c.JSON(http.StatusOK, ret)
@ -33,18 +53,11 @@ func createRiffDeck(c *gin.Context) {
return return
} }
id := arg["id"].(string) name := arg["name"].(string)
id, rootID, content, isLargeDoc, err := model.OpenRepoSnapshotDoc(id) err := model.CreateDeck(name)
if nil != err { if nil != err {
ret.Code = -1 ret.Code = -1
ret.Msg = err.Error() ret.Msg = err.Error()
return return
} }
ret.Data = map[string]interface{}{
"id": id,
"rootID": rootID,
"content": content,
"isLargeDoc": isLargeDoc,
}
} }

View File

@ -300,6 +300,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/repo/openRepoSnapshotDoc", model.CheckAuth, openRepoSnapshotDoc) ginServer.Handle("POST", "/api/repo/openRepoSnapshotDoc", model.CheckAuth, openRepoSnapshotDoc)
ginServer.Handle("POST", "/api/riff/createRiffDeck", model.CheckAuth, createRiffDeck) 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/pushMsg", model.CheckAuth, pushMsg)
ginServer.Handle("POST", "/api/notification/pushErrMsg", model.CheckAuth, pushErrMsg) ginServer.Handle("POST", "/api/notification/pushErrMsg", model.CheckAuth, pushErrMsg)