CategoryController.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace addons\QiJuhe\backend\controllers;
  3. use addons\QiJuhe\common\service\ApiService;
  4. use addons\QiJuhe\common\service\CategoryService;
  5. use phpDocumentor\Reflection\Types\This;
  6. /**
  7. * 分类控制器
  8. *
  9. * Class CategorysController
  10. * @package addons\QiJuhe\backend\controllers
  11. */
  12. class CategoryController extends BaseController
  13. {
  14. /**
  15. * 导入分类
  16. *
  17. * @return void
  18. */
  19. public function actionIndex()
  20. {
  21. return $this->render('index');
  22. }
  23. /**
  24. * 导入分类
  25. *
  26. * @return void
  27. */
  28. public function actionImport()
  29. {
  30. $supply_id = $this->request->get('supply_id');
  31. $service = new CategoryService(['mall_id'=>$this->mall_id,'supply_id'=>$supply_id]);
  32. $res = $service->import($this->mall_id,$supply_id,0);
  33. return $res ? $this->success('导入成功,后台执行中...') : $this->error($service->error);
  34. }
  35. public function actionList(){
  36. if (!$this->request->isAjax) {
  37. return;
  38. }
  39. $param = $this->request->getQueryParams();
  40. $parent_id = $param['parent_id'] ?? 0;
  41. $supply_id = $param['supply_id'] ?? 0;
  42. // 获取分类
  43. $service = new CategoryService([
  44. 'mall_id'=>$this->mall_id,
  45. 'supply_id'=>$supply_id,
  46. ]);
  47. $list = $service->getCategory($parent_id,false);
  48. return $this->success('ok', $list);
  49. }
  50. }