增加文章总数接口

master
a74589669 2019-09-05 00:32:39 +08:00
parent 2d78c86879
commit 6109f974a6
2 changed files with 24 additions and 0 deletions

View File

@ -56,6 +56,29 @@ func GetArticles(c *gin.Context) {
rsp.Msg = "OK" 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) { func GetArticle(c *gin.Context) {
resp := RespBase{Msg:"FAIL",Status: 211} resp := RespBase{Msg:"FAIL",Status: 211}
sid := c.Param("id") sid := c.Param("id")

View File

@ -102,6 +102,7 @@ func main() {
api.PUT("/article",controller.AddArticle) // 添加文章 api.PUT("/article",controller.AddArticle) // 添加文章
api.GET("article_type",controller.ArticlesType) //获取所有文章分类 api.GET("article_type",controller.ArticlesType) //获取所有文章分类
api.POST("/article_update",controller.UpdateArtilce) api.POST("/article_update",controller.UpdateArtilce)
api.GET("/articleCount",controller.GetArticleCount)
api.POST("/image_upload",fileController.OnUpload) api.POST("/image_upload",fileController.OnUpload)
api.GET("/image_download/:file",fileController.OnDownLoad) api.GET("/image_download/:file",fileController.OnDownLoad)