| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\webApp;
- use App\Services\Api\ArticleService;
- use App\Services\ConfigService;
- /**
- * 文章
- * Class ArticleController
- * @package App\Http\Controllers\Api
- */
- class ArticleController extends webApp
- {
- /**
- * 列表
- * @return array
- */
- public function index()
- {
- $params =request()->post();
- $pageSize = request()->post('pageSize', 15);
- $datas = ArticleService::make()->getDataList($params, $pageSize);
- return showJson(1010, true, $datas);
- }
- /**
- * 分类
- * @return array
- */
- public function category()
- {
- $datas = ArticleService::make()->getCategory();
- return showJson(1010, true, $datas);
- }
- /**
- * 分类
- * @return array
- */
- public function cates()
- {
- $type = request()->post('type', 0);
- $datas = ArticleService::make()->getCateList($type);
- return showJson(1010, true, $datas);
- }
- /**
- * 详情
- */
- public function info()
- {
- $id = request()->post('id',0);
- if(empty($id)){
- return showJson(2501, false);
- }
- if($info = ArticleService::make()->getInfo($id, $this->userId)){
- return showJson(1010, true, $info);
- }else{
- return showJson(1009, false);
- }
- }
- /**
- * 单页数据
- */
- public function page()
- {
- $type = request()->post('type','');
- if(empty($type)){
- return showJson(2501, false);
- }
- $pageId = ConfigService::make()->getConfigByCode("page_{$type}");
- if($pageId<=0){
- return showJson(1032, false);
- }
- if($info = ArticleService::make()->getInfo($pageId)){
- return showJson(1010, true, $info);
- }else{
- return showJson(1009, false);
- }
- }
- }
|