From de99a24d46591370082f11eef30f7a692756aae7 Mon Sep 17 00:00:00 2001 From: "DESKTOP-4RNDQIC\\29019" <290198252@qq.com> Date: Sat, 9 Jan 2021 22:55:22 +0800 Subject: [PATCH] no message --- controller/blog.go | 22 ++++++++++++++++++++++ controller/user.go | 9 +++++++++ main.go | 8 +++++++- model/book.go | 20 ++++++++++++++++++++ test/git_test.go | 1 - 5 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 model/book.go diff --git a/controller/blog.go b/controller/blog.go index e05c6b0..c1af37d 100644 --- a/controller/blog.go +++ b/controller/blog.go @@ -374,6 +374,28 @@ func CreateMemo(c *gin.Context) { resp.Status = 0 } +func CreateBook(c *gin.Context) { + resp := RespBase{"unkown error", -231, nil} + defer func() { + c.JSON(200, resp) + }() + var req model.Memo + e := c.BindJSON(&req) + if nil != e { + logs.Error(e.Error()) + resp.Msg = "wrong input" + return + } + e = model.CreateMemo(req) + if nil != e { + logs.Error(e.Error()) + return + } + resp.Data = nil + resp.Msg = "OK" + resp.Status = 0 +} + func UpdateMemo(c *gin.Context) { resp := RespBase{"unkown error", -231, nil} defer func() { diff --git a/controller/user.go b/controller/user.go index 5b7fb41..20b47bb 100644 --- a/controller/user.go +++ b/controller/user.go @@ -228,6 +228,13 @@ func DefaultOption(c *gin.Context) { } func (this *UserController) Login(c *gin.Context) { + + defer func() { + if err := recover();err != nil{ + log.Printf("panic: v%",err) + } + }() + type LoginReq struct { RememberMe int32 `json:"remember_me"` UserName string `json:"user_name"` @@ -278,6 +285,8 @@ func (this *UserController) Login(c *gin.Context) { session := sessions.Get(c) log.Println("set session", string(sessionInfo)) session.Set("", string(sessionInfo)) + session.Clear() + //session. var Options *sessions.Options if req.RememberMe == 1 { diff --git a/main.go b/main.go index 0402d28..948e022 100644 --- a/main.go +++ b/main.go @@ -27,7 +27,6 @@ var ( userController = controller.UserController{} mailContoller = controller.MailController{} fileController = controller.FileController{} - webhookController = controller.WebHookController{} ) func CORSMiddleware(c *gin.Context) { @@ -171,6 +170,13 @@ func main() { api.GET("templates", controller.GetDocTemplate) // 获取所有文章的模板 api.GET("doc_versions", nil) // 获取文章的某个版本 + + + + api.PUT("/book", controller.CreateMemo) // 备忘录新建 + api.POST("/book", controller.UpdateMemo) // 备忘录更新 + api.POST("/books", controller.GetMemos) // 备忘录批量 + api.POST("/delbook", controller.DeleteMemos) //删除备忘录 } openapi := r.Group("openapi") diff --git a/model/book.go b/model/book.go new file mode 100644 index 0000000..6954aa2 --- /dev/null +++ b/model/book.go @@ -0,0 +1,20 @@ +package model + +import ( + "time" +) +// Book sss +type Book struct { + ID int64 `sql:"id" json:"id"` + BookName string `sql:"book_name" json:"book_name"` + Author string `sql:"size" json:"size"` + Title string `sql:"title" json:"title"` + Tag string `sql:"tag" json:"json"` + CreateTime time.Time `sql:"create_time" json:"create_time"` +} + +// ReadHistory sss +type ReadHistory struct { + ID int64 `sql:"id" json:"id"` + +} \ No newline at end of file diff --git a/test/git_test.go b/test/git_test.go index 1492b24..7489a9c 100644 --- a/test/git_test.go +++ b/test/git_test.go @@ -3,7 +3,6 @@ package test import ( "log" "testing" - "github.com/sergi/go-diff/diffmatchpatch" )