StoreCategoryController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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\StoreCategoryService;
  13. /**
  14. * 商家分类管理-控制器
  15. * @author laravel开发员
  16. * @since 2020/11/11
  17. * @package App\Http\Controllers
  18. */
  19. class StoreCategoryController 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 StoreCategoryService();
  30. }
  31. /**
  32. * 获取列表
  33. * @return array
  34. */
  35. public function index()
  36. {
  37. $pageSize = request()->get('limit', 15);
  38. $params = request()->all();
  39. $params['store_id'] = $this->storeId;
  40. return $this->service->getDataList($params, $pageSize);
  41. }
  42. /**
  43. * 获取详情
  44. * @return array
  45. */
  46. public function info()
  47. {
  48. return $this->service->info();
  49. }
  50. /**
  51. * 添加或编辑
  52. * @return array
  53. */
  54. public function edit()
  55. {
  56. if ($this->service->edit()) {
  57. return message($this->service->getError() ?: '操作成功', true);
  58. } else {
  59. return message($this->service->getError() ?: '操作失败', false);
  60. }
  61. }
  62. /**
  63. * 设置状态
  64. * @return array
  65. */
  66. public function status()
  67. {
  68. $params = request()->post();
  69. if ($this->service->setStatus($params)) {
  70. return message($this->service->getError(), true);
  71. } else {
  72. return message($this->service->getError(), false);
  73. }
  74. }
  75. /**
  76. * 删除
  77. * @return array
  78. */
  79. public function delete()
  80. {
  81. return $this->service->delete();
  82. }
  83. /**
  84. * 批量删除
  85. * @return array
  86. */
  87. public function deleteAll()
  88. {
  89. $params = request()->post();
  90. if ($this->service->deleteAll($params)) {
  91. return message($this->service->getError(), true);
  92. } else {
  93. return message($this->service->getError(), false);
  94. }
  95. }
  96. /**
  97. * 选项列表(用于下拉选择)
  98. * @return array
  99. */
  100. public function options()
  101. {
  102. return $this->service->options();
  103. }
  104. }