| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | 
							- <?php
 
- namespace app\api\controller;
 
- use app\common\model\content\Category;
 
- use app\common\model\content\Article as ArticleModel;
 
- /**
 
-  * 地址
 
-  */
 
- class Article extends Base
 
- {
 
-     protected $noNeedLogin = ['getCategoryList', 'getArticleList', 'getArticleInfo'];
 
-     /**
 
-      * 分类列表
 
-      */
 
-     public function getCategoryList()
 
-     {
 
-         $parentId = $this->request->param('parent_id', 0, 'intval');
 
-         $page = $this->request->param('page', 1, 'intval');
 
-         $pageSize = $this->request->param('page_size', 10, 'intval');
 
-         $list = Category::getCategoryList($parentId, $page, $pageSize);
 
-         // 处理图像的
 
-         $list->each(function ($item) {
 
-             $item['image'] = $item['image'] ? cdnurl($item['image']) : '';
 
-         });
 
-         $this->success('', $list);
 
-     }
 
-     /**
 
-      * 文章列表
 
-      */
 
-     public function getArticleList()
 
-     {
 
-         $categoryId = $this->request->param('category_id', 0, 'intval');
 
-         $page = $this->request->param('page', 1, 'intval');
 
-         $pageSize = $this->request->param('page_size', 10, 'intval');
 
-         $list = ArticleModel::getArticleList($categoryId, $page, $pageSize);
 
-         $list->each(function ($item) {
 
-             // 处理图像的
 
-             $item['image'] = $item['image'] ? cdnurl($item['image']) : '';
 
-         });
 
-         $this->success('获取成功', $list);
 
-     }
 
-     //文章详情
 
-     public function getArticleInfo()
 
-     {
 
-         $id = $this->request->param('id', 0, 'intval');
 
-         // 验证id是否为空
 
-         if (empty($id)) {
 
-             $this->error('id不能为空');
 
-         }
 
-         $info = ArticleModel::getArticleInfo($id);
 
-         //判断是否为空
 
-         if (!empty($info)) {
 
-             $info['image'] = $info['image'] ? cdnurl($info['image']) : '';
 
-         }
 
-         $this->success('获取成功', $info);
 
-     }
 
- }
 
 
  |