| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\webApp;
- use App\Services\Api\ArticleService;
- use App\Services\Api\SupervisorsService;
- use App\Services\Common\AdService;
- /**
- * 文章管理
- * 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 message(1010, true, $datas);
- }
- /**
- * 行业数据
- * @return array
- */
- public function industry()
- {
- try {
- $data = [
- // 轮播
- 'banners' => AdService::make()->getListByPosition(2), // 轮播
- 'supervisors' => SupervisorsService::make()->getRecommendList(), // 推荐导师
- 'articles' => ArticleService::make()->getListByType(2), // 行业政策资讯
- ];
- return showJson(1010, true, $data);
- } catch (\Exception $exception) {
- $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
- return showJson(1046, false, $error);
- }
- }
- /**
- * 详情
- */
- public function info()
- {
- $params = request()->all();
- $id = isset($params['id'])? intval($params['id']) : 0;
- if(empty($id)){
- return message(1036, false);
- }
- if($info = ArticleService::make()->getInfo($id)){
- return message(1010, true, $info);
- }else{
- return message(1009, false);
- }
- }
- /**
- * 单页数据
- */
- public function page()
- {
- $params = request()->all();
- $type = isset($params['type'])? intval($params['type']) : 0;
- if(empty($type)){
- return message(1031, false);
- }
- if($info = ArticleService::make()->getInfoByType($type)){
- return message(1010, true, $info);
- }else{
- return message(1009, false);
- }
- }
- }
|