ArticleController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\webApp;
  4. use App\Services\Api\ArticleService;
  5. use App\Services\ConfigService;
  6. /**
  7. * 文章
  8. * Class ArticleController
  9. * @package App\Http\Controllers\Api
  10. */
  11. class ArticleController extends webApp
  12. {
  13. /**
  14. * 列表
  15. * @return array
  16. */
  17. public function index()
  18. {
  19. $params =request()->post();
  20. $pageSize = request()->post('pageSize', 15);
  21. $datas = ArticleService::make()->getDataList($params, $pageSize, $this->userId);
  22. return showJson(1010, true, $datas);
  23. }
  24. /**
  25. * 详情
  26. */
  27. public function info()
  28. {
  29. $id = request()->post('id',0);
  30. if(empty($id)){
  31. return showJson(2501, false);
  32. }
  33. if($info = ArticleService::make()->getInfo($id, $this->userId)){
  34. return showJson(1010, true, $info);
  35. }else{
  36. return showJson(1009, false);
  37. }
  38. }
  39. /**
  40. * 单页数据
  41. */
  42. public function page()
  43. {
  44. $type = request()->post('type','');
  45. if(empty($type)){
  46. return showJson(2501, false);
  47. }
  48. $pageId = ConfigService::make()->getConfigByCode("page_{$type}");
  49. if($pageId<=0){
  50. return showJson(1032, false);
  51. }
  52. if($info = ArticleService::make()->getInfo($pageId)){
  53. return showJson(1010, true, $info);
  54. }else{
  55. return showJson(1009, false);
  56. }
  57. }
  58. }