Exemplo n.º 1
0
 /**
  * Displays a single DcmdApp model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $depart = $this->getDepart();
     $searchModel = new DcmdServiceSearch();
     $con = array();
     $con['DcmdServiceSearch'] = array('app_id' => $id);
     if (array_key_exists('DcmdServiceSearch', Yii::$app->request->queryParams)) {
         $con = array_merge($con, Yii::$app->request->queryParams);
     }
     $con['DcmdServiceSearch']['app_id'] = $id;
     $dataProvider = $searchModel->search($con);
     $model = $this->findModel($id);
     ///处理图片
     $base_path = dirname(__DIR__) . "/web/app_image/";
     $query = DcmdAppArchDiagram::find()->andWhere(['app_id' => $id])->asArray()->all();
     $app_images = array();
     foreach ($query as $item) {
         $img_path = $base_path . "app_" . $item['arch_name'] . '_' . $item['app_id'] . '.jpg';
         array_push($app_images, "/dcmd/app_image/app_" . $item['arch_name'] . '_' . $item['app_id'] . '.jpg');
         if (file_exists($img_path)) {
             continue;
         }
         $fp = fopen($img_path, 'wb') or die("Open file {$img_path} fail!");
         fwrite($fp, stripslashes($item['diagram']));
         fclose($fp);
     }
     $imageSearch = new DcmdAppArchDiagramSearch();
     $imageProvider = $imageSearch->search(array('DcmdAppArchDiagramSearch' => array('app_id' => $id)));
     return $this->render('view', ['model' => $this->findModel($id), 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'imageProvider' => $imageProvider]);
 }
 /**
  * Lists all DcmdService models.
  * @return mixed
  */
 public function actionIndex()
 {
     ///应用足用户只可查看所在组的应用
     $app_con = "";
     if (Yii::$app->user->getIdentity()->admin != 1) {
         $app_con = "svr_gid in (0";
         $query = DcmdUserGroup::find()->andWhere(['uid' => Yii::$app->user->getId()])->asArray()->all();
         if ($query) {
             foreach ($query as $item) {
                 $app_con .= "," . $item['gid'];
             }
         }
         $app_con .= ")";
     }
     $query = DcmdApp::find()->where($app_con)->orderBy('app_name')->asArray()->all();
     $app = array();
     foreach ($query as $item) {
         $app[$item['app_id']] = $item['app_name'];
     }
     $searchModel = new DcmdServiceSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'app' => $app]);
 }