public function actionUpdate()
 {
     $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
     $postModel = \app\models\WPost::findOne($id);
     if ($postModel) {
         if (Yii::$app->request->isPost) {
             $getPost = isset($_POST['WPost']) ? $_POST['WPost'] : '';
             $getPost['id'] = $id;
             $postModel->attributes = $getPost;
             if ($postModel->save()) {
                 exit(json_encode(['status' => 1, 'msg' => '修改成功']));
             } else {
                 exit(json_encode(['status' => -1, 'msg' => $postModel->getErrors()]));
             }
         }
         return $this->render('update', ['model' => $postModel, 'id' => $id]);
     } else {
         exit('此记录不存在');
     }
 }
 public function createIndex($index, $type)
 {
     $res = \app\models\WPost::find()->all();
     foreach ($res as $key => $value) {
         $params = array();
         $params['body'] = ['id' => $value->id, 'subject' => $value->subject, 'keywords' => $value->keywords, 'url_code' => $value->url_code];
         $params['index'] = $index;
         $params['type'] = $type;
         $params['id'] = $key;
         $this->esClient->index($params);
     }
     echo 'create index done';
 }