Beispiel #1
0
 public function actionEditSubmit($id)
 {
     $params = Yii::$app->request->post();
     $userDto = new UserDto();
     $userDto->setScenario('admin-update');
     if ($userDto->load(['UserDto' => $params]) && $userDto->validate()) {
         try {
             $this->userService->save($userDto);
             return $this->retMsg(200, '更新成功!', 'user_index');
         } catch (Exception $e) {
             return $this->retMsg(300, '更新失败!', 'user_index');
         }
     } else {
         return $this->retMsg(300, array_values($userDto->getFirstErrors()));
     }
 }