no message

master
zcy 2022-11-11 00:10:58 +08:00
parent 4e2e728f5a
commit 7cabc47886
3 changed files with 20 additions and 7 deletions

View File

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

View File

@ -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) //获取所有文章分类

View File

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