From 6109f974a64eb9623f5feb553f38a82a8085f17a Mon Sep 17 00:00:00 2001 From: a74589669 <290198252@qq.com> Date: Thu, 5 Sep 2019 00:32:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=87=E7=AB=A0=E6=80=BB?= =?UTF-8?q?=E6=95=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/blog.go | 23 +++++++++++++++++++++++ main.go | 1 + 2 files changed, 24 insertions(+) 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)