|
@ -140,15 +140,15 @@ class FileManager |
|
|
public static function saveFileInModel($dataModel, $fileIdStrName, $fileOldIdStr, $fileType, $fileNameInModel = '') |
|
|
public static function saveFileInModel($dataModel, $fileIdStrName, $fileOldIdStr, $fileType, $fileNameInModel = '') |
|
|
{ |
|
|
{ |
|
|
if (is_array($dataModel)) { |
|
|
if (is_array($dataModel)) { |
|
|
Yii::$app->session->setFlash('error', '数据模型不得为数组'); |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
throw new ServerErrorHttpException('数据模型不得为数组'); |
|
|
} |
|
|
} |
|
|
$fileNewIdStr = $dataModel->$fileIdStrName; |
|
|
|
|
|
$dataModel->save(); |
|
|
$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->$fileNameInModel = $saveFileRes['first_file_id']; |
|
|
$dataModel->save(); |
|
|
|
|
|
|
|
|
if (!$dataModel->save()) { |
|
|
|
|
|
throw new ServerErrorHttpException('dataModel保存失败'); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|