GoodsCategoryController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. if ($this->service->edit()) {
  56. return message($this->service->getError() ?: '操作成功', true);
  57. } else {
  58. return message($this->service->getError() ?: '操作失败', false);
  59. }
  60. }
  61. /**
  62. * 设置状态
  63. * @return array
  64. */
  65. public function status()
  66. {
  67. $params = request()->post();
  68. if ($this->service->setStatus($params)) {
  69. return message($this->service->getError(), true);
  70. } else {
  71. return message($this->service->getError(), false);
  72. }
  73. }
  74. /**
  75. * 删除
  76. * @return array
  77. */
  78. public function delete()
  79. {
  80. return $this->service->delete();
  81. }
  82. /**
  83. * 批量删除
  84. * @return array
  85. */
  86. public function deleteAll()
  87. {
  88. $params = request()->post();
  89. if ($this->service->deleteAll($params)) {
  90. return message($this->service->getError(), true);
  91. } else {
  92. return message($this->service->getError(), false);
  93. }
  94. }
  95. /**
  96. * 选项列表(用于下拉选择)
  97. * @return array
  98. */
  99. public function options()
  100. {
  101. return $this->service->options();
  102. }
  103. }