From 8d39cc14c8cdaa707f67247a5222e09744cd218a Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Thu, 12 Dec 2019 17:29:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E4=BF=9D=E5=AD=98=E6=96=87=E4=BB=B6=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E5=88=A0=E9=99=A4=E5=9B=BE=E7=89=87=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/modules/file/logic/file/FileManager.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/modules/file/logic/file/FileManager.php b/backend/modules/file/logic/file/FileManager.php index ecc934c..4563bc0 100755 --- a/backend/modules/file/logic/file/FileManager.php +++ b/backend/modules/file/logic/file/FileManager.php @@ -140,15 +140,15 @@ class FileManager public static function saveFileInModel($dataModel, $fileIdStrName, $fileOldIdStr, $fileType, $fileNameInModel = '') { if (is_array($dataModel)) { - Yii::$app->session->setFlash('error', '数据模型不得为数组'); - return false; + throw new ServerErrorHttpException('数据模型不得为数组'); } - $fileNewIdStr = $dataModel->$fileIdStrName; $dataModel->save(); - $saveFileRes = GoodsManager::saveFile(explode(',', $fileNewIdStr), $dataModel, explode(',', $fileOldIdStr), $fileType); - if ($fileNameInModel && $saveFileRes['status'] && $saveFileRes['first_file_id']) { + $saveFileRes = GoodsManager::saveFile(explode(',', $dataModel->$fileIdStrName), $dataModel, explode(',', $fileOldIdStr), $fileType); + if ($fileNameInModel && $saveFileRes['status'] && $saveFileRes['first_file_id'] !== 0) { $dataModel->$fileNameInModel = $saveFileRes['first_file_id']; - $dataModel->save(); + if (!$dataModel->save()) { + throw new ServerErrorHttpException('dataModel保存失败'); + } } return true; }