diff --git a/controller/blog.go b/controller/blog.go index 2f30301..36c9abe 100644 --- a/controller/blog.go +++ b/controller/blog.go @@ -161,7 +161,7 @@ func GetArticle(c *gin.Context) { func UpdateArtilce(c *gin.Context) { rsp := RespBase{Msg: "FAIL", Status: 210} type ReqUpdateArticle struct { - Id int64 `json:"id"` + ID int64 `json:"id"` Title string `json:"title"` Content string `json:"content"` author string `json:"author"` @@ -173,7 +173,7 @@ func UpdateArtilce(c *gin.Context) { c.JSON(200, rsp) }() - query := fmt.Sprintf("select * from doc where doc.id = '%d'", id) + query := fmt.Sprintf("select * from doc where doc.id = '%d'", req.ID) docs := []model.Doc{} e := db.GetMysqlClient().Query2(query, &docs) if nil != e { @@ -200,7 +200,7 @@ func UpdateArtilce(c *gin.Context) { Title: req.Title, Content: req.Content, Author: req.author, - ID: req.Id, + ID: req.ID, IsPublic: int32(req.IsPublic), Version: (docs[0].Version + 1), }, @@ -244,11 +244,11 @@ func AddArticle(c *gin.Context) { } e := model.CreateDoc( model.Doc{ - Type: req.Type, + Type: int32(req.Type), Title: req.Title, Content: req.Content, Author: req.Author, - IsPublic: req.Ispublic, + IsPublic: int32(req.Ispublic), }, ) if nil != e {