添加版本号

master
DESKTOP-4RNDQIC\29019 2021-03-04 21:46:04 +08:00
parent cb2534a3cd
commit 88b9cd5a9d
2 changed files with 13 additions and 12 deletions

View File

@ -173,6 +173,17 @@ func UpdateArtilce(c *gin.Context) {
c.JSON(200, rsp) c.JSON(200, rsp)
}() }()
er := c.BindJSON(&req)
if nil != er {
logs.Error(er.Error())
return
}
if req.Title == "" {
rsp.Msg = "title required"
return
}
query := fmt.Sprintf("select * from doc where doc.id = '%d'", req.ID) query := fmt.Sprintf("select * from doc where doc.id = '%d'", req.ID)
docs := []model.Doc{} docs := []model.Doc{}
e := db.GetMysqlClient().Query2(query, &docs) e := db.GetMysqlClient().Query2(query, &docs)
@ -184,16 +195,6 @@ func UpdateArtilce(c *gin.Context) {
rsp.Msg = "不存在该" rsp.Msg = "不存在该"
return return
} }
er := c.BindJSON(&req)
if nil != er {
logs.Error(er.Error())
return
}
if req.Title == "" {
rsp.Msg = "title required"
return
}
e = model.UpdateDoc( e = model.UpdateDoc(
model.Doc{ model.Doc{
Type: int32(req.Type), Type: int32(req.Type),

View File

@ -88,9 +88,9 @@ func CreateDoc(doc Doc) error {
UpdateDoc UpdateDoc
*/ */
func UpdateDoc(doc Doc) error { func UpdateDoc(doc Doc) error {
sql := fmt.Sprintf(`update doc set doc.author = '%s' ,doc.title = '%s',doc.type = '%d',doc.content = '%s' ,doc.update_time = '%s' where doc.id = '%d'; `, sql := fmt.Sprintf(`update doc set doc.author = '%s' ,doc.title = '%s',doc.type = '%d',doc.content = '%s' ,doc.update_time = '%s' ,doc.version = '%d' where doc.id = '%d'; `,
doc.Author, doc.Title, doc.Type, doc.Author, doc.Title, doc.Type,
strings.Replace(doc.Content, "'", "\\'", -1), time.Now().Format("2006-01-02 15:04:05"), doc.ID) strings.Replace(doc.Content, "'", "\\'", -1), time.Now().Format("2006-01-02 15:04:05"),doc.Version, doc.ID)
_, e := db.GetMysqlClient().Query(sql) _, e := db.GetMysqlClient().Query(sql)
if nil != e { if nil != e {
logs.Error(e.Error()) logs.Error(e.Error())