增加文章总数接口
This commit is contained in:
parent
2d78c86879
commit
6109f974a6
@ -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")
|
||||||
|
1
main.go
1
main.go
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user