ArticleController.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Services\Common\ArticleService;
  4. /**
  5. * 文章
  6. * Class ArticleController
  7. * @package App\Http\Controllers\Api
  8. */
  9. class ArticleController extends webApp
  10. {
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. $this->service = new ArticleService();
  15. }
  16. /**
  17. * 获取列表
  18. * @return array|mixed
  19. */
  20. public function help()
  21. {
  22. $pageSize = request()->post('limit', 15);
  23. $params = request()->all();
  24. $params['status'] = 1;
  25. $params['time_type'] = 1;
  26. $params['type'] = 1;
  27. $list = ArticleService::make()->getDataList($params, $pageSize);
  28. return message(1002, true, $list);
  29. }
  30. /**
  31. * 详情
  32. * @return array|mixed
  33. */
  34. public function info()
  35. {
  36. $id = request()->post('id', 0);
  37. if($id<=0){
  38. return message(1003, false);
  39. }
  40. $info = ArticleService::make()->getInfo(['id'=> $id,'mark'=> 1]);
  41. if($info){
  42. ArticleService::make()->updateViews($id);
  43. }
  44. return message(1002, true, $info);
  45. }
  46. /**
  47. * 单页数据
  48. * @return array
  49. */
  50. public function page()
  51. {
  52. $type = request()->post('type', 0);
  53. if($type<=0){
  54. return message(1003, false);
  55. }
  56. $info = ArticleService::make()->getInfo(['type'=> $type,'mark'=> 1]);
  57. return message(1002, true, $info);
  58. }
  59. }