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