| 1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace addons\Community\api\modules\v1\controllers;
- use addons\Community\common\service\GoodsService;
- use api\controllers\OnAuthController;
- use Yii;
- class GoodsController extends OnAuthController
- {
- public $modelClass = '';
- /**
- * 不用进行登录验证的方法
- *
- * 例如: ['index', 'update', 'create', 'view', 'delete']
- * 默认全部需要验证
- *
- * @var array
- */
- protected $authOptional = [];
- public function actionIndex()
- {
- $data = \Yii::$app->request->get();
- $valid = Yii::$app->services->validate->validate($data, [
- [['page', 'limit', 'cate_id'], 'integer'],
- [['type'], 'safe']
- ]);
- if ($valid === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $ret = (new GoodsService())->page($this->mall_id, $data, $this->user_id);
- return is_string($ret) ? $this->error($ret) : $this->success('获取成功', $ret);
- }
- }
|