| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace api\controllers\v1;
- use yii\rest\ActiveController;
- use yii\filters\auth\QueryParamAuth;
- /**
- * 这里注意是继承 yii\rest\ActiveController 因为源码中已经帮我们实现了index/update等方法
- * 以及其访问规则verbs()等,
- * 其他可参考:http://www.yiichina.com/doc/guide/2.0/rest-controllers
- *
- * 权限采用最简单的QueryParamAuth方式
- * 用户角色权限比较复杂,这里没有做
- *
- * @package api\modules\v1\controllers
- */
- class UserController extends ActiveController
- {
- public $modelClass = 'common\models\xhUser';
- public function behaviors()
- {
- $behaviors = parent::behaviors();
- /* 设置认证方式 */
- /*$behaviors['authenticator'] = [
- 'class' => QueryParamAuth::className(),
- ];*/
- return $behaviors;
- }
- public function actions()
- {
- $action= parent::actions(); // TODO: Change the autogenerated stub
- unset($action['index']);
- unset($action['create']);
- unset($action['update']);
- unset($action['delete']);
- }
- public function actionIndex()
- {
- return ['status'=>201, 'msg'=>'success'];
- }
- }
|