| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace addons\Printer\backend\controllers;
- use addons\Printer\common\services\SettingService;
- use Yii;
- /**
- * 设置控制器
- *
- * Class SettingController
- * @package addons\Printer\backend\controllers
- */
- class SettingController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * 设置
- *
- * @return mixed
- */
- public function actionIndex()
- {
- if ($this->request->isAjax) {
- $service = new SettingService(['mall_id' => $this->mall_id]);
- return $this->success('ok', $service->getSetting());
- }
- return $this->render($this->action->id);
- }
- /**
- * 保存设置
- *
- * @return mixed
- */
- public function actionSave()
- {
- $service = new SettingService(['mall_id' => $this->mall_id]);
- $params = $this->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['pickup_code_name'], 'required'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- return $service->setSetting($params)
- ? $this->success('ok')
- : $this->error($service->getError());
- }
- }
|