DefaultController.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace addons\QiJuhe\backend\controllers;
  3. use addons\QiJuhe\common\service\DebugService;
  4. use addons\QiJuhe\common\service\SettingService;
  5. use Yii;
  6. use common\controllers\AddonsController;
  7. /**
  8. * 默认控制器
  9. *
  10. * Class DefaultController
  11. * @package addons\QiJuhe\backend\controllers
  12. */
  13. class DefaultController extends BaseController
  14. {
  15. public $enableCsrfValidation = false;
  16. /**
  17. * 设置页面
  18. *
  19. * @return void
  20. */
  21. public function actionIndex()
  22. {
  23. if ($this->request->isAjax) {
  24. $service = new SettingService(['mall_id' => $this->mall_id]);
  25. $data = $service->getSetting();
  26. return $this->success('ok', $data);
  27. }
  28. return $this->render('index');
  29. }
  30. /**
  31. * 提交设置
  32. *
  33. * @return void
  34. */
  35. public function actionSubmit()
  36. {
  37. if ($this->request->isAjax) {
  38. $service = new SettingService(['mall_id' => $this->mall_id]);
  39. $data = $this->request->post();
  40. $service->attributes = $data;
  41. $service->setSetting();
  42. return $this->success();
  43. }
  44. }
  45. /**
  46. * 调试
  47. *
  48. * @return void
  49. */
  50. public function actionDebug()
  51. {
  52. if ($this->request->isPost) {
  53. $type = $this->request->post('type');
  54. return ($service = new DebugService(['mall_id' => $this->mall_id]))->hander($type)
  55. ? $this->success('ok', $service->getResult())
  56. : $this->error($service->getError());
  57. }
  58. return $this->render('debug');
  59. }
  60. }