diff --git a/controller/blog.go b/controller/blog.go index 322fd9e..5f1facb 100644 --- a/controller/blog.go +++ b/controller/blog.go @@ -56,6 +56,29 @@ func GetArticles(c *gin.Context) { rsp.Msg = "OK" } +func GetArticleCount(c *gin.Context) { + resp := RespBase{Msg:"FAIL",Status: 211} + + defer func() { + c.JSON(200,resp) + }() + + query := fmt.Sprintf("select count(*) as cnt from doc") + type Cnt struct { + Cnt int64 `sql:"cnt" json:"cnt"` + } + cnt := []Cnt{}; + + e := db.GetMysqlClient().Query2(query,&cnt) + if nil != e{ + log.Print(e.Error()) + return + } + resp.Data = cnt[0] + resp.Status = 0 + resp.Msg = "OK" +} + func GetArticle(c *gin.Context) { resp := RespBase{Msg:"FAIL",Status: 211} sid := c.Param("id") diff --git a/main.go b/main.go index 71f1c52..3ee1451 100644 --- a/main.go +++ b/main.go @@ -102,6 +102,7 @@ func main() { api.PUT("/article",controller.AddArticle) // 添加文章 api.GET("article_type",controller.ArticlesType) //获取所有文章分类 api.POST("/article_update",controller.UpdateArtilce) + api.GET("/articleCount",controller.GetArticleCount) api.POST("/image_upload",fileController.OnUpload) api.GET("/image_download/:file",fileController.OnDownLoad)