AdviceController.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace api\modules\v1\controllers;
  3. use common\models\Feedback;
  4. use yii\rest\ActiveController;
  5. use common\library\Apireturn;
  6. use yii\helpers\ArrayHelper;
  7. use yii\filters\auth\QueryParamAuth;
  8. use yii;
  9. class AdviceController extends ActiveController
  10. {
  11. const DISPLAY = 15;//显示条数
  12. public $modelClass = 'common\models';
  13. public function behaviors()
  14. {
  15. return ArrayHelper::merge(parent::behaviors(), [
  16. 'authenticator' => [
  17. 'class' => QueryParamAuth::className(),
  18. 'tokenParam' => "token",//access-token修改为token
  19. 'optional' => [//不需要认证方法名 array
  20. ],
  21. ]
  22. ]);
  23. }
  24. /**
  25. * 反馈意见
  26. * @return array
  27. */
  28. public function actionAdvice(){
  29. $advice =new Feedback();
  30. if( $advice->load(Yii::$app->request->post(),'') && $advice->save()){
  31. return Apireturn::sent(0,'意见保存成功',200);
  32. }
  33. return Apireturn::sent(1,'意见保存失败',200);
  34. }
  35. }