|
...
|
...
|
@@ -6,6 +6,7 @@ use App\Enums\Common\Code; |
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Http\Controllers\type;
|
|
|
|
use App\Models\File\Image as ImageModel;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Services\CosService;
|
|
|
|
use App\Services\TencentCosService;
|
|
|
|
use Illuminate\Http\Exceptions\HttpResponseException;
|
|
...
|
...
|
@@ -27,8 +28,6 @@ class ImageController extends Controller |
|
|
|
'Content-Description' => 'File Transfer',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
const TYPE = 1;
|
|
|
|
|
|
|
|
public $path = '';//路径
|
|
|
|
|
|
|
|
public $config = '';//存储默认配置
|
|
...
|
...
|
@@ -41,6 +40,7 @@ class ImageController extends Controller |
|
|
|
|
|
|
|
public $cache = '';//缓存数据
|
|
|
|
|
|
|
|
public $upload_location = 1;
|
|
|
|
public $image_type = [
|
|
|
|
1 => 'image_product',
|
|
|
|
2 => 'image_news',
|
|
...
|
...
|
@@ -127,7 +127,7 @@ class ImageController extends Controller |
|
|
|
$this->setUrl();
|
|
|
|
if ($type == 'multi') {
|
|
|
|
return $this->multi($files);
|
|
|
|
} else {
|
|
|
|
}else{
|
|
|
|
return $this->single($files);
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -166,8 +166,11 @@ class ImageController extends Controller |
|
|
|
if ($rs === false) {
|
|
|
|
return $this->response('添加失败', Code::USER_ERROR);
|
|
|
|
}
|
|
|
|
$cosService = new CosService();
|
|
|
|
$cosService->uploadFile($this->path,$fileName);
|
|
|
|
//同步数据到cos
|
|
|
|
if($this->upload_location == 1){
|
|
|
|
$cosService = new CosService();
|
|
|
|
$cosService->uploadFile($this->path,$fileName);
|
|
|
|
}
|
|
|
|
return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -226,6 +229,11 @@ class ImageController extends Controller |
|
|
|
'refer'=>$this->param['refer'] ?? '',
|
|
|
|
];
|
|
|
|
$data[] = ['image'=>$hash];
|
|
|
|
//同步数据到cos
|
|
|
|
if($this->upload_location == 1){
|
|
|
|
$cosService = new CosService();
|
|
|
|
$cosService->uploadFile($this->path,$fileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$imageModel->insert($save_data);
|
|
|
|
return $this->response('图片资源',Code::SUCCESS,$data);
|
|
...
|
...
|
@@ -318,6 +326,11 @@ class ImageController extends Controller |
|
|
|
if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){
|
|
|
|
$this->path = $this->uploads['path_a'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m');
|
|
|
|
}else{
|
|
|
|
$projectModel = new Project();
|
|
|
|
$project_info = $projectModel->read(['id'=>$this->cache['project_id']],['upload_location']);
|
|
|
|
if($project_info['upload_location'] != 1){
|
|
|
|
$this->upload_location = 0;
|
|
|
|
}
|
|
|
|
$this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m');
|
|
|
|
}
|
|
|
|
}
|
...
|
...
|
|