| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\webApp;
- use App\Services\Api\ArticleService;
- /**
- * 文章管理
- * 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 datas()
- {
- $datas = [
- 'hotList' => ArticleService::make()->getHotList($this->userId),
- 'recList' => ArticleService::make()->getRecommendList(),
- ];
- return message(1010, true, $datas);
- }
- /**
- * 资料分类
- * @return array
- */
- public function cates()
- {
- $params = request()->all();
- $type = isset($params['type'])? $params['type'] : 2;
- $sc = isset($params['sc'])? $params['sc'] : 0;
- $datas = ArticleService::make()->getCateList($type, $sc);
- return message(1010, true, $datas);
- }
- /**
- * 热门咨询
- * @return array
- */
- public function hots()
- {
- $params = request()->all();
- $refresh = isset($params['refresh'])? $params['refresh'] : false;
- $datas = ArticleService::make()->getHotList($this->userId, $refresh);
- return message(1010, true, $datas);
- }
- /**
- * 详情
- */
- 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 search()
- {
- $params = request()->all();
- if ($info = ArticleService::make()->search($params)) {
- return message(1010, true, $info);
- } else {
- return message('抱歉,没有找到您要的答案', 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);
- }
- }
- }
|