ArticleController.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Services\Common\ArticleService;
  4. /**
  5. * 文章
  6. * Class ArticleController
  7. * @package App\Http\Controllers\Admin
  8. */
  9. class ArticleController extends Backend
  10. {
  11. /**
  12. * 构造函数
  13. * @author laravel开发员
  14. * @since 2020/11/11
  15. * ArticleController constructor.
  16. */
  17. public function __construct()
  18. {
  19. parent::__construct();
  20. $this->service = new ArticleService();
  21. }
  22. /**
  23. * 列表
  24. * @return array
  25. */
  26. public function index()
  27. {
  28. $pageSize = request()->get('limit', 15);
  29. $list = $this->service->getDataList(request()->all(), $pageSize);
  30. $message = array(
  31. "msg" => '操作成功',
  32. "code" => 0,
  33. "data" => isset($list['list']) ? $list['list'] : [],
  34. "count" => isset($list['total']) ? $list['total'] : 0,
  35. );
  36. return $message;
  37. }
  38. /**
  39. * 列表
  40. * @return array
  41. */
  42. public function import()
  43. {
  44. $data = request()->input('data');
  45. $result = $this->service->importArticles($data);
  46. return response()->json($result);
  47. }
  48. }