[ 'class' => QueryParamAuth::className(), 'tokenParam' => "token",//access-token修改为token 'optional' => [//不需要认证方法名 array ], ] ]); } /** * 商家回复留言 * @return array */ public function actionReply(){ $id = Yii::$app->request->post('id');//评论id $content = Yii::$app->request->post('content'); if(empty($content)) return Apireturn::sent(0,'评论内容不能为空',200); $comment = Comment::find()->where(['id'=>$id,'reply_uid'=>Yii::$app->user->id])->one(); if(empty($comment)) return Apireturn::sent(0,'找不到该评论',200); $model =new Reply(); $model->cid = $id; $model->from_userid=Yii::$app->user->id; $model->to_userid=$comment->uid; $model->created_at=time(); $model->content=$content; $model->status=Reply::STATUS_ACTIVE; if($model->save()){ return Apireturn::sent(1,'评论成功',200); } return Apireturn::sent(0,"评论失败",200); } /** * 用户回复留言 * @return array */ public function actionUserReply(){ $id = Yii::$app->request->post('id');//评论id $content = Yii::$app->request->post('content'); if(empty($content)) return Apireturn::sent(0,'评论内容不能为空',200); $comment = Comment::find()->where(['id'=>$id,'uid'=>Yii::$app->user->id])->one(); if(empty($comment)) return Apireturn::sent(0,'找不到该评论',200); $model =new Reply(); $model->cid = $id; $model->from_userid=Yii::$app->user->id; $model->to_userid=$comment->reply_uid; $model->created_at=time(); $model->content=$content; $model->status=Reply::STATUS_ACTIVE; if($model->save()){ return Apireturn::sent(1,'评论成功',200); } return Apireturn::sent(0,"评论失败",200); } }