|
@ -2,16 +2,13 @@ |
|
|
|
|
|
|
|
|
namespace antgoods\goods\controllers; |
|
|
namespace antgoods\goods\controllers; |
|
|
|
|
|
|
|
|
|
|
|
use common\models\ars\TemFile; |
|
|
use Yii; |
|
|
use Yii; |
|
|
use antgoods\goods\models\ars\Goods; |
|
|
use antgoods\goods\models\ars\Goods; |
|
|
use antgoods\goods\models\searchs\GoodsSearch; |
|
|
use antgoods\goods\models\searchs\GoodsSearch; |
|
|
use yii\web\Controller; |
|
|
use yii\web\Controller; |
|
|
use yii\web\NotFoundHttpException; |
|
|
use yii\web\NotFoundHttpException; |
|
|
use yii\filters\VerbFilter; |
|
|
use yii\filters\VerbFilter; |
|
|
use common\models\ars\TemFile; |
|
|
|
|
|
use common\models\ars\File; |
|
|
|
|
|
use backend\logic\file\FileManager; |
|
|
|
|
|
use antgoods\goods\logic\goods\GoodsManager; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* GoodsController implements the CRUD actions for Goods model. |
|
|
* GoodsController implements the CRUD actions for Goods model. |
|
@ -82,7 +79,8 @@ class GoodsController extends Controller |
|
|
{ |
|
|
{ |
|
|
$model = new Goods(); |
|
|
$model = new Goods(); |
|
|
|
|
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->save()) { |
|
|
|
|
|
|
|
|
if ($model->load(Yii::$app->request->post())) { |
|
|
|
|
|
$model->save(); |
|
|
return $this->redirect('index'); |
|
|
return $this->redirect('index'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -167,14 +165,19 @@ class GoodsController extends Controller |
|
|
*/ |
|
|
*/ |
|
|
public function actionSaveFile() |
|
|
public function actionSaveFile() |
|
|
{ |
|
|
{ |
|
|
|
|
|
if(!class_exists('\common\models\ars\TemFile') || !class_exists('\backend\logic\file\FileManager')){ |
|
|
|
|
|
return ''; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$data = Yii::$app->request->get('data'); |
|
|
$data = Yii::$app->request->get('data'); |
|
|
$file_name = Yii::$app->request->get('fileName')[0]; |
|
|
$file_name = Yii::$app->request->get('fileName')[0]; |
|
|
|
|
|
|
|
|
if ($data['status'] == true) { |
|
|
if ($data['status'] == true) { |
|
|
$model = new TemFile(); |
|
|
|
|
|
|
|
|
$model = new \common\models\ars\TemFile(); |
|
|
$model->user_id = Yii::$app->user->identity->id; |
|
|
$model->user_id = Yii::$app->user->identity->id; |
|
|
$model->name = $file_name; |
|
|
$model->name = $file_name; |
|
|
$type = Yii::$app->file->searchType(FileManager::$extension, pathinfo($data['path'])['extension']); |
|
|
|
|
|
|
|
|
$file_manager = new \backend\logic\file\FileManager(); |
|
|
|
|
|
$type = $file_manager->searchType(\backend\logic\file\FileManager::$extension, pathinfo($data['path'])['extension']); |
|
|
if ($type != -1) { |
|
|
if ($type != -1) { |
|
|
$model->type = $type; |
|
|
$model->type = $type; |
|
|
} |
|
|
} |
|
@ -191,10 +194,15 @@ class GoodsController extends Controller |
|
|
*/ |
|
|
*/ |
|
|
public function actionImgIdDel() |
|
|
public function actionImgIdDel() |
|
|
{ |
|
|
{ |
|
|
|
|
|
//判断该类是否存在
|
|
|
|
|
|
if(!class_exists('\common\models\ars\TemFile')){ |
|
|
|
|
|
return ''; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$alias = Yii::$app->request->get('data')['alias']; |
|
|
$alias = Yii::$app->request->get('data')['alias']; |
|
|
$img_id = Yii::$app->request->get('imgid'); |
|
|
$img_id = Yii::$app->request->get('imgid'); |
|
|
$img_id_arr = explode(',', $img_id); |
|
|
$img_id_arr = explode(',', $img_id); |
|
|
$tem_file = TemFile::findOne(['alias' => $alias]); |
|
|
|
|
|
|
|
|
$tem_file = \common\models\ars\TemFile::findOne(['alias' => $alias]); |
|
|
if ($tem_file) { |
|
|
if ($tem_file) { |
|
|
$img_id_arr = array_diff($img_id_arr, [$tem_file->id]); |
|
|
$img_id_arr = array_diff($img_id_arr, [$tem_file->id]); |
|
|
} |
|
|
} |
|
|