abiao 4 lat temu
rodzic
commit
9fa7269e3b

+ 30 - 30
go/gopath/src/fohow.com/apps/controllers/article_controller/article_controller.go

@@ -27,39 +27,39 @@ import (
 )
 
 //文章列表
-// func (self *ArticleController) GetList() {
-// 	_catId := self.Ctx.Input.Param(":cat_id")
-// 	catId, _ := strconv.ParseInt(_catId, 10, 64)
-// 	// cat_id, _ := self.GetInt64("cat_id", 12)
-// 	page, _ := self.GetInt64("page", 1)
-// 	perPage, _ := self.GetInt64("per_page", 20)
-// 	if perPage <= 0 || perPage > 100 {
-// 		perPage = 20
-// 	}
-// 	type ArticlesWithCat struct {
-// 		Articles     []*article_model.Article  `orm:"-"         json:"articles"`
-// 		ArticleCat   *article_model.ArticleCat `orm:"-"         json:"article_cat"`
-// 		ArticleCount int64                     `orm:"-"         json:"article_count"`
-// 	}
-// 	articleList := article_model.GetListByCatId(catId, page, perPage, (true && !self.IsDev()))
-// 	articleCat := article_model.GetArticleCatById(catId, true)
-// 	articleCount := article_model.GetListCountByCatId(catId)
+func (self *ArticleController) GetList() {
+	_catId := self.Ctx.Input.Param(":cat_id")
+	catId, _ := strconv.ParseInt(_catId, 10, 64)
+	// cat_id, _ := self.GetInt64("cat_id", 12)
+	page, _ := self.GetInt64("page", 1)
+	perPage, _ := self.GetInt64("per_page", 20)
+	if perPage <= 0 || perPage > 100 {
+		perPage = 20
+	}
+	type ArticlesWithCat struct {
+		Articles     []*article_model.Article  `orm:"-"         json:"articles"`
+		ArticleCat   *article_model.ArticleCat `orm:"-"         json:"article_cat"`
+		ArticleCount int64                     `orm:"-"         json:"article_count"`
+	}
+	articleList := article_model.GetListByCatId(catId, page, perPage, (true && !self.IsDev()))
+	articleCat := article_model.GetArticleCatById(catId, true)
+	articleCount := article_model.GetListCountByCatId(catId)
 
-// 	list := new(ArticlesWithCat)
-// 	list.Articles = articleList
-// 	list.ArticleCat = articleCat
-// 	list.ArticleCount = articleCount
-// 	self.Data["json"] = list
-// 	self.ServeJSON()
-// }
+	list := new(ArticlesWithCat)
+	list.Articles = articleList
+	list.ArticleCat = articleCat
+	list.ArticleCount = articleCount
+	self.Data["json"] = list
+	self.ServeJSON()
+}
 
 // //热门新闻
-// func (self *ArticleController) GetHotest() {
-// 	useCache, _ := self.GetBool("cache", true)
-// 	list := article_model.Hotest(useCache)
-// 	self.Data["json"] = list
-// 	self.ServeJSON()
-// }
+func (self *ArticleController) GetHotest() {
+	useCache, _ := self.GetBool("cache", true)
+	list := article_model.Hotest(useCache)
+	self.Data["json"] = list
+	self.ServeJSON()
+}
 
 //文章详情
 func (self *ArticleController) GetDetail() {

+ 6 - 0
go/gopath/src/fohow.com/routers/routes.go

@@ -116,7 +116,13 @@ func init() {
 	beego.Router("/v1/balance_order/generate", &pay_controller.PayController{}, "post:CreateBalanceOrder")
 	//生成充值余额订单
 	beego.Router("/v1/recas_order/generate", &pay_controller.PayController{}, "post:CreateRechargeCashOrder")
+	//----------- 文章相关 -----------
+	//新闻列表
+	beego.Router("/v1/artcat/:cat_id/articles", &article_controller.ArticleController{}, "get:GetList")
+	//热门新闻
+	beego.Router("/v1/article/hotest", &article_controller.ArticleController{}, "get:GetHotest")
 
+	//文章详细
 	beego.Router("/v1/article/:article_id([0-9]+)", &article_controller.ArticleController{}, "get:GetDetail")
 
 	//----------- 广告相关 -----------