|
@@ -5,6 +5,9 @@ namespace App\Listeners; |
|
@@ -5,6 +5,9 @@ namespace App\Listeners; |
|
5
|
use App\Events\CopyImageFile;
|
5
|
use App\Events\CopyImageFile;
|
|
6
|
use App\Events\UpdateHtml;
|
6
|
use App\Events\UpdateHtml;
|
|
7
|
use App\Jobs\updateHtmlJob;
|
7
|
use App\Jobs\updateHtmlJob;
|
|
|
|
8
|
+use App\Models\File\File as FileModel;
|
|
|
|
9
|
+use App\Models\File\Image as ImageModel;
|
|
|
|
10
|
+use App\Services\AmazonS3Service;
|
|
8
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
11
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
9
|
|
12
|
|
|
10
|
class CopyImageFileListener implements ShouldQueue
|
13
|
class CopyImageFileListener implements ShouldQueue
|
|
@@ -23,16 +26,28 @@ class CopyImageFileListener implements ShouldQueue |
|
@@ -23,16 +26,28 @@ class CopyImageFileListener implements ShouldQueue |
|
23
|
public function handle(CopyImageFile $event)
|
26
|
public function handle(CopyImageFile $event)
|
|
24
|
{
|
27
|
{
|
|
25
|
$this->param = $event->data;
|
28
|
$this->param = $event->data;
|
|
|
|
29
|
+ $imageModel = new ImageModel();
|
|
|
|
30
|
+ //获取当前项目的所有图片
|
|
|
|
31
|
+ $imageList = $imageModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos']);
|
|
|
|
32
|
+ if(!empty($imageList)){
|
|
|
|
33
|
+ $amazonS3Service = new AmazonS3Service();
|
|
|
|
34
|
+ foreach ($imageList as $k => $v){
|
|
|
|
35
|
+ $amazonS3Service->syncImageFiles(getImageUrl($v['path']));
|
|
|
|
36
|
+ $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);
|
|
26
|
}
|
37
|
}
|
|
27
|
-
|
|
|
|
28
|
- /**
|
|
|
|
29
|
- * @remark :同步图片文件到亚马逊
|
|
|
|
30
|
- * @name :uploadImageFile
|
|
|
|
31
|
- * @author :lyh
|
|
|
|
32
|
- * @method :post
|
|
|
|
33
|
- * @time :2024/1/26 10:15
|
|
|
|
34
|
- */
|
|
|
|
35
|
- public function uploadImageFile(){
|
|
|
|
36
|
-
|
38
|
+ }
|
|
|
|
39
|
+ @file_put_contents(storage_path('logs/lyh_error.log'), var_export('图片:'.$v['id'], true) . PHP_EOL, FILE_APPEND);
|
|
|
|
40
|
+ sleep(2);
|
|
|
|
41
|
+ $fileModel = new FileModel();
|
|
|
|
42
|
+ $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos']);
|
|
|
|
43
|
+ if(!empty($fileList)){
|
|
|
|
44
|
+ $amazonS3Service = new AmazonS3Service();
|
|
|
|
45
|
+ foreach ($fileList as $k => $v){
|
|
|
|
46
|
+ $amazonS3Service->syncImageFiles(getImageUrl($v['path']));
|
|
|
|
47
|
+ $fileList->edit(['is_cos'=>0],['id'=>$v['id']]);
|
|
|
|
48
|
+ }
|
|
|
|
49
|
+ }
|
|
|
|
50
|
+ @file_put_contents(storage_path('logs/lyh_error.log'), var_export('文件:'.$v['id'], true) . PHP_EOL, FILE_APPEND);
|
|
|
|
51
|
+ return true;
|
|
37
|
}
|
52
|
}
|
|
38
|
} |
53
|
} |