no message

master
DESKTOP-4RNDQIC\29019 2021-01-09 22:55:22 +08:00
parent 32bc2f6c5e
commit de99a24d46
5 changed files with 58 additions and 2 deletions

View File

@ -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() {

View File

@ -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 {

View File

@ -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")

20
model/book.go Normal file
View File

@ -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"`
}

View File

@ -3,7 +3,6 @@ package test
import (
"log"
"testing"
"github.com/sergi/go-diff/diffmatchpatch"
)