ArticleCategoryController.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Services\Common\ArticleCategoryService;
  4. /**
  5. * 文章分类管理-控制器
  6. * @author laravel开发员
  7. * @since 2020/11/11
  8. * Class ArticleCategoryController
  9. * @package App\Http\Controllers\Admin
  10. */
  11. class ArticleCategoryController extends Backend
  12. {
  13. /**
  14. * 构造函数
  15. * @author laravel开发员
  16. * @since 2020/11/11
  17. * ArticleCategoryController constructor.
  18. */
  19. public function __construct()
  20. {
  21. parent::__construct();
  22. $this->service = new ArticleCategoryService();
  23. }
  24. /**
  25. * 获取分类列表
  26. */
  27. public function index()
  28. {
  29. $pageSize = request()->get('limit', 10);
  30. $list = $this->service->getDataList(request()->all(), $pageSize);
  31. $message = array(
  32. "msg" => '操作成功',
  33. "code" => 0,
  34. "data" => isset($list['list']) ? $list['list'] : [],
  35. "count" => isset($list['total']) ? $list['total'] : 0,
  36. );
  37. return $message;
  38. }
  39. /**
  40. * 获取分类选项
  41. */
  42. public function options()
  43. {
  44. $list = $this->service->getOptions();
  45. return response()->json(['code' => 0, 'msg' => '操作成功', 'data' => $list]);
  46. }
  47. /**
  48. * 获取父级分类选项
  49. */
  50. public function parentOptions()
  51. {
  52. $list = $this->service->getParentOptions();
  53. return response()->json(['code' => 0, 'msg' => '操作成功', 'data' => $list]);
  54. }
  55. /**
  56. * 获取分类详情
  57. */
  58. public function info()
  59. {
  60. return $this->service->info();
  61. }
  62. /**
  63. * 添加或编辑分类
  64. */
  65. public function edit()
  66. {
  67. return $this->service->edit();
  68. }
  69. /**
  70. * 删除分类
  71. */
  72. public function delete()
  73. {
  74. return $this->service->delete();
  75. }
  76. /**
  77. * 设置分类状态
  78. */
  79. public function status()
  80. {
  81. return $this->service->status();
  82. }
  83. }