QueryParamAuth::className(), 'tokenParam' => 'token', ] ]); } /** * @return array|string[] * @throws \yii\db\Exception * @author jiang */ public function actionCreate() { $transaction = Yii::$app->db->beginTransaction(); try { $model = new Suggest(); $model->load(request()->post(), ''); $model->save(); if ($model->hasErrors()) { throw new Exception(current($model->getErrors())[0]); } $transaction->commit(); } catch (\Exception $e) { $transaction->rollBack(); return ['errcode' => CodeEnum::CODE_ERROR, 'errmsg' => '提交失败:' . $e->getMessage()]; } return ['errmsg' => '提交成功']; } }