ArticleController.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\webApp;
  4. use App\Services\Api\ArticleService;
  5. /**
  6. * 文章资讯
  7. * @package App\Http\Controllers\Api\v1
  8. */
  9. class ArticleController extends webApp
  10. {
  11. /**
  12. * 信息
  13. * @return array
  14. */
  15. public function info()
  16. {
  17. $id = request()->post('id', 0);
  18. try {
  19. if($info = ArticleService::make()->getInfo($id, $this->userId)){
  20. return showJson(1010, true, $info);
  21. }else{
  22. return showJson(1009,false,'',403);
  23. }
  24. } catch (\Exception $exception){
  25. return showJson(1036,false,['error'=>$exception->getMessage()]);
  26. }
  27. }
  28. /**
  29. * 列表
  30. * @return array|mixed
  31. */
  32. public function index()
  33. {
  34. $params = request()->post();
  35. try {
  36. if($datas = ArticleService::make()->getDataList($params, $this->userId)){
  37. return showJson(1010, true, $datas);
  38. }else{
  39. return showJson(1009,false,'',403);
  40. }
  41. } catch (\Exception $exception){
  42. return showJson(1041,false,['error'=>$exception->getMessage()]);
  43. }
  44. }
  45. }