| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace api\modules\v1\controllers;
- use api\controllers\OnAuthController;
- use services\common\ReportService;
- use Yii;
- /**
- * 举报
- * Class ReportController
- * @package api\modules\v1\controllers
- */
- class ReportController extends OnAuthController
- {
- /**
- * @var string
- */
- public $modelClass = '';
- /**
- * @var ReportService
- */
- protected $service;
- public function beforeAction($action)
- {
- parent::beforeAction($action);
- $this->service = new ReportService(['mall_id' => $this->mall_id]);
- return $action;
- }
- /**
- * 提交举报
- *
- * @return string
- */
- public function actionSubmit(int $id, string $from)
- {
- $post = $this->request->post();
- $validate = Yii::$app->services->validate->validate($post, [
- [['type', 'content'], 'required'],
- ]);
- if (!$validate) return $this->error(Yii::$app->services->validate->getErrorMessage());
- return $this->service->addReport($id, $from, $post)
- ? $this->success('举报成功')
- : $this->error($this->service->getError());
- }
- }
|