From 7cabc478863314e649ab222a4e531ef3cdc09268 Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Fri, 11 Nov 2022 00:10:58 +0800 Subject: [PATCH] no message --- controller/blog.go | 2 ++ main.go | 1 + model/blog.go | 24 +++++++++++++++++------- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/controller/blog.go b/controller/blog.go index 6166ba4..50d8513 100644 --- a/controller/blog.go +++ b/controller/blog.go @@ -254,6 +254,8 @@ func GetArticle(c *gin.Context) { query := fmt.Sprintf("select * from doc_copy1 where doc_copy1.id = '%d'", id) docs := []model.Doc{} e := db.GetMysqlClient().Query2(query, &docs) + fmt.Print(query,docs) + if nil != e { log.Print(e.Error()) return diff --git a/main.go b/main.go index 41520dc..03447f6 100644 --- a/main.go +++ b/main.go @@ -163,6 +163,7 @@ func main() { api.PUT("/article", controller.AddArticle) // 添加文章 api.PUT("/article_tree", controller.AddArticleTree) // 添加文章 + api.PUT("/article_tree_history", controller.AddArticleTree) // 添加文章 api.PUT("/article_search", controller.SearchArticles) // 添加文章 api.GET("/article_type", controller.ArticlesType) //获取所有文章分类 diff --git a/model/blog.go b/model/blog.go index 6640206..50625db 100644 --- a/model/blog.go +++ b/model/blog.go @@ -177,6 +177,16 @@ func UpdateDoc(doc Doc) error { return nil } +func InsertDocHistory(doc DocTree) error{ + sql := fmt.Sprintf(`insert into doc_history(title,doc_id,content,edit_time) values('%s',%d,'%s','%s');`, + doc.Title,doc.ID,strings.Replace(doc.Content, "'", "\\'", -1), time.Now().Format("2006-01-02 15:04:05")) + _, er := db.GetMysqlClient().Query(sql) + if nil != er { + logs.Error(er.Error()) + return er + } + return nil +} /* UpdateDoc 更新文档 @@ -192,13 +202,13 @@ func UpdateDocTree(doc DocTree) error { logs.Error(e.Error()) return e } - sql = fmt.Sprintf(`insert into doc_history(title,doc_id,content,edit_time) values('%s',%d,'%s','%s');`, - doc.Title,doc.ID,strings.Replace(doc.Content, "'", "\\'", -1), time.Now().Format("2006-01-02 15:04:05")) - _, er := db.GetMysqlClient().Query(sql) - if nil != er { - logs.Error(e.Error()) - return e - } + // sql = fmt.Sprintf(`insert into doc_history(title,doc_id,content,edit_time) values('%s',%d,'%s','%s');`, + // doc.Title,doc.ID,strings.Replace(doc.Content, "'", "\\'", -1), time.Now().Format("2006-01-02 15:04:05")) + // _, er := db.GetMysqlClient().Query(sql) + // if nil != er { + // logs.Error(e.Error()) + // return e + // } return nil }