|
|
@@ -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() {
|