GoodsCategoryController.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Http\Controllers\Admin;
  12. use App\Services\Common\GoodsCategoryService;
  13. /**
  14. * 商品分类管理-控制器
  15. * @author laravel开发员
  16. * @since 2020/11/11
  17. * @package App\Http\Controllers
  18. */
  19. class GoodsCategoryController extends Backend
  20. {
  21. /**
  22. * 构造函数
  23. * @author laravel开发员
  24. * @since 2020/11/11
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. $this->service = new GoodsCategoryService();
  30. }
  31. /**
  32. * 获取列表
  33. * @return array
  34. */
  35. public function index()
  36. {
  37. $pageSize = request()->get('limit', 15);
  38. $params = request()->all();
  39. return $this->service->getDataList($params, $pageSize);
  40. }
  41. /**
  42. * 获取详情
  43. * @return array
  44. */
  45. public function info()
  46. {
  47. return $this->service->info();
  48. }
  49. /**
  50. * 添加或编辑
  51. * @return array
  52. */
  53. public function edit()
  54. {
  55. $this->service->edit();
  56. }
  57. /**
  58. * 设置状态
  59. * @return array
  60. */
  61. public function status()
  62. {
  63. $params = request()->post();
  64. if ($this->service->setStatus($params)) {
  65. return message($this->service->getError(), true);
  66. } else {
  67. return message($this->service->getError(), false);
  68. }
  69. }
  70. /**
  71. * 删除
  72. * @return array
  73. */
  74. public function delete()
  75. {
  76. return $this->service->delete();
  77. }
  78. /**
  79. * 批量删除
  80. * @return array
  81. */
  82. public function deleteAll()
  83. {
  84. $params = request()->post();
  85. if ($this->service->deleteAll($params)) {
  86. return message($this->service->getError(), true);
  87. } else {
  88. return message($this->service->getError(), false);
  89. }
  90. }
  91. /**
  92. * 选项列表(用于下拉选择)
  93. * @return array
  94. */
  95. public function options()
  96. {
  97. return $this->service->options();
  98. }
  99. }