mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-02 20:11:53 +08:00
This commit is contained in:
parent
42c09e2fad
commit
29f73e1ef9
@ -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,
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user