/** * Creates a new DcmdServicePool model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($app_id, $svr_id) { ///仅仅用户与该应用在同一个系统组才可以操作 $temp = DcmdApp::findOne($app_id); $query = DcmdUserGroup::findOne(['uid' => Yii::$app->user->getId(), 'gid' => $temp['sa_gid']]); if ($query == NULL) { Yii::$app->getSession()->setFlash('success', NULL); Yii::$app->getSession()->setFlash('error', "对不起, 你没有权限!"); return $this->redirect(array('dcmd-service/view', 'id' => $svr_id)); } $model = new DcmdServicePool(); if (Yii::$app->request->post() && $model->load(Yii::$app->request->post())) { $model->utime = date('Y-m-d H:i:s'); $model->ctime = $model->utime; $model->opr_uid = Yii::$app->user->getId(); if ($model->save()) { $this->oprlog(1, "insert service pool:" . $model->svr_pool); Yii::$app->getSession()->setFlash('success', "添加成功"); return $this->redirect(['view', 'id' => $model->svr_pool_id]); } $err_str = ""; foreach ($model->getErrors() as $k => $v) { $err_str .= $k . ":" . $v[0] . "<br>"; } Yii::$app->getSession()->setFlash('error', "添加失败:" . $err_str); return $this->redirect(array('dcmd-service/view', 'id' => $svr_id)); } $model = new DcmdServicePool(); $model->app_id = $app_id; $model->svr_id = $svr_id; return $this->render('create', ['model' => $model]); }