| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace addons\OperationCenter\backend\controllers;
- use addons\OperationCenter\common\services\SettingService;
- /**
- * 设置控制器
- *
- * Class SettingController
- * @package addons\OperationCenter\backend\controllers
- */
- class SettingController extends BaseController
- {
- /**
- * @var boolean
- */
- public $enableCsrfValidation = false;
- /**
- * @var SettingService
- */
- protected $service;
- public function init()
- {
- parent::init();
- $this->service = new SettingService(['mall_id' => $this->mall_id]);
- }
- /**
- * 首页
- *
- * @return string
- */
- public function actionIndex()
- {
- if ($this->request->isAjax) {
- return $this->success('ok', ['setting' => $this->service->getSetting()]);
- }
- return $this->render($this->action->id);
- }
- /**
- * 保存设置
- *
- * @return string
- */
- public function actionSave()
- {
- if ($this->request->isPost) {
- $data = $this->request->post();
- unset($data['_csrf']);
- return $this->service->setSetting($data)
- ? $this->success('ok')
- : $this->error('设置失败');
- }
- }
- }
|