DefaultController.php 1007 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace api\modules\v1\controllers;
  3. use api\controllers\OnAuthController;
  4. /**
  5. * 默认控制器
  6. *
  7. * Class DefaultController
  8. * @package api\modules\v1\controllers
  9. * @property \yii\db\ActiveRecord $modelClass
  10. * @author jianyan74 <751393839@qq.com>
  11. */
  12. class DefaultController extends OnAuthController
  13. {
  14. public $modelClass = '';
  15. /**
  16. * 不用进行登录验证的方法
  17. * 例如: ['index', 'update', 'create', 'view', 'delete']
  18. * 默认全部需要验证
  19. *
  20. * @var array
  21. */
  22. protected $authOptional = ['index', 'search'];
  23. /**
  24. * @return string|\yii\data\ActiveDataProvider
  25. */
  26. public function actionIndex()
  27. {
  28. return 'index';
  29. }
  30. /**
  31. * 测试查询方法
  32. *
  33. * 注意:该方法在 main.php 文件里面的 extraPatterns 单独配置过才正常访问
  34. *
  35. * @return array
  36. */
  37. public function actionSearch()
  38. {
  39. return [
  40. 'test' => '测试查询'
  41. ];
  42. }
  43. }
粤ICP备19079148号