作者 lyh

gx

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CopyProject.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/1/9 16:01
  8 + */
  9 +
  10 +namespace App\Events;
  11 +
  12 +use Illuminate\Broadcasting\InteractsWithSockets;
  13 +use Illuminate\Foundation\Events\Dispatchable;
  14 +use Illuminate\Queue\SerializesModels;
  15 +class CopyImageFile
  16 +{
  17 + use Dispatchable, InteractsWithSockets, SerializesModels;
  18 + public $data;
  19 + /**
  20 + * 监听更新HTML静态页
  21 + */
  22 + public function __construct($data)
  23 + {
  24 + $this->data = $data;
  25 + }
  26 +}
@@ -471,11 +471,6 @@ if (!function_exists('getImageUrl')) { @@ -471,11 +471,6 @@ if (!function_exists('getImageUrl')) {
471 if(substr($path,0,2) == '//'){ 471 if(substr($path,0,2) == '//'){
472 return 'https:'.$path; 472 return 'https:'.$path;
473 } 473 }
474 -// $imageModel = new Image();  
475 -// $imageInfo = $imageModel->read(['path'=>$path],['is_cos']);  
476 -// if($imageInfo === false){  
477 -// return '';  
478 -// }  
479 if($location == 0){ 474 if($location == 0){
480 $cos = config('filesystems.disks.cos'); 475 $cos = config('filesystems.disks.cos');
481 $cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1']; 476 $cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
@@ -514,11 +509,6 @@ if (!function_exists('getFileUrl')) { @@ -514,11 +509,6 @@ if (!function_exists('getFileUrl')) {
514 if(substr($path,0,2) == '//'){ 509 if(substr($path,0,2) == '//'){
515 return 'https:'.$path; 510 return 'https:'.$path;
516 } 511 }
517 -// $fileModel = new FileModel();  
518 -// $fileInfo = $fileModel->read(['path'=>$path],['is_cos']);  
519 -// if($fileInfo === false){  
520 -// return '';  
521 -// }  
522 if($location == 0){ 512 if($location == 0){
523 $cos = config('filesystems.disks.cos'); 513 $cos = config('filesystems.disks.cos');
524 $cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1']; 514 $cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
@@ -38,7 +38,7 @@ class BlogController extends BaseController @@ -38,7 +38,7 @@ class BlogController extends BaseController
38 foreach ($lists['list'] as $k => $v){ 38 foreach ($lists['list'] as $k => $v){
39 $v['category_name'] = $this->categoryName($v['category_id'],$data); 39 $v['category_name'] = $this->categoryName($v['category_id'],$data);
40 $v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG,$v['id']); 40 $v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG,$v['id']);
41 - $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']); 41 + $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
42 $v['operator_name'] = $user->getName($v['operator_id']); 42 $v['operator_name'] = $user->getName($v['operator_id']);
43 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL,$template_id,$v['id']); 43 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL,$template_id,$v['id']);
44 $lists['list'][$k] = $v; 44 $lists['list'][$k] = $v;
@@ -37,7 +37,7 @@ class CustomModuleContentController extends BaseController @@ -37,7 +37,7 @@ class CustomModuleContentController extends BaseController
37 $data = $this->getAllCategoryName(); 37 $data = $this->getAllCategoryName();
38 foreach ($lists['list'] as $k=>$v){ 38 foreach ($lists['list'] as $k=>$v){
39 $v['category_name'] = $this->categoryName($v['category_id'],$data); 39 $v['category_name'] = $this->categoryName($v['category_id'],$data);
40 - $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']); 40 + $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
41 $v['operator_name'] = (new User())->getName($v['operator_id']); 41 $v['operator_name'] = (new User())->getName($v['operator_id']);
42 $lists['list'][$k] = $v; 42 $lists['list'][$k] = $v;
43 } 43 }
@@ -35,6 +35,7 @@ class NavController extends BaseController @@ -35,6 +35,7 @@ class NavController extends BaseController
35 if(!empty($lists)){ 35 if(!empty($lists)){
36 foreach ($lists as $v){ 36 foreach ($lists as $v){
37 $v = (array)$v; 37 $v = (array)$v;
  38 + $v = $this->handleReturnInfo($v);
38 if ($v['pid'] == 0) { 39 if ($v['pid'] == 0) {
39 $v['sub'] = _get_child($v['id'], $lists); 40 $v['sub'] = _get_child($v['id'], $lists);
40 $data[] = $v; 41 $data[] = $v;
@@ -52,6 +53,23 @@ class NavController extends BaseController @@ -52,6 +53,23 @@ class NavController extends BaseController
52 } 53 }
53 54
54 /** 55 /**
  56 + * @remark :单独处理图片文件
  57 + * @name :HandleReturnInfo
  58 + * @author :lyh
  59 + * @method :post
  60 + * @time :2024/1/26 9:44
  61 + */
  62 + public function handleReturnInfo($param){
  63 + if(isset($param['image']) && !empty($param['image'])){
  64 + $param['image'] = getImageUrl($param['image'],$this->user['storage_type'],$this->user['project_location']);
  65 + }
  66 + if(isset($param['remark_image']) && !empty($param['remark_image'])){
  67 + $param['remark_image'] = getImageUrl($param['image'],$this->user['storage_type'],$this->user['project_location']);
  68 + }
  69 + return $this->success($param);
  70 + }
  71 +
  72 + /**
55 * @remark :根据固定的数组排序 73 * @remark :根据固定的数组排序
56 * @name :findDetailsInList 74 * @name :findDetailsInList
57 * @author :lyh 75 * @author :lyh
@@ -41,7 +41,7 @@ class NewsController extends BaseController @@ -41,7 +41,7 @@ class NewsController extends BaseController
41 foreach ($lists['list'] as $k => $v){ 41 foreach ($lists['list'] as $k => $v){
42 $v['category_name'] = $this->categoryName($v['category_id'],$data); 42 $v['category_name'] = $this->categoryName($v['category_id'],$data);
43 $v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS,$v['id']); 43 $v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS,$v['id']);
44 - $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']); 44 + $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
45 $v['operator_name'] = $user->getName($v['operator_id']); 45 $v['operator_name'] = $user->getName($v['operator_id']);
46 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL,$template_id,$v['id']); 46 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL,$template_id,$v['id']);
47 $lists['list'][$k] = $v; 47 $lists['list'][$k] = $v;
@@ -43,6 +43,7 @@ class KeywordController extends BaseController @@ -43,6 +43,7 @@ class KeywordController extends BaseController
43 }else{ 43 }else{
44 $v['tdk'] = 0; 44 $v['tdk'] = 0;
45 } 45 }
  46 + $v = $this->handleReturnInfo($v);
46 $v['url'] = $this->user['domain'] . $v['route'].'/'; 47 $v['url'] = $this->user['domain'] . $v['route'].'/';
47 } 48 }
48 } 49 }
@@ -50,6 +51,23 @@ class KeywordController extends BaseController @@ -50,6 +51,23 @@ class KeywordController extends BaseController
50 } 51 }
51 52
52 /** 53 /**
  54 + * @remark :单独处理图片文件
  55 + * @name :HandleReturnInfo
  56 + * @author :lyh
  57 + * @method :post
  58 + * @time :2024/1/26 9:44
  59 + */
  60 + public function handleReturnInfo($param){
  61 + if(isset($param['keyword_top_banner']) && !empty($param['keyword_top_banner'])){
  62 + $param['keyword_top_banner'] = getImageUrl($param['keyword_top_banner'],$this->user['storage_type'],$this->user['project_location']);
  63 + }
  64 + if(isset($param['keyword_foot_banner']) && !empty($param['keyword_foot_banner'])){
  65 + $param['keyword_foot_banner'] = getImageUrl($param['keyword_foot_banner'],$this->user['storage_type'],$this->user['project_location']);
  66 + }
  67 + return $this->success($param);
  68 + }
  69 +
  70 + /**
53 * @remark :搜索 71 * @remark :搜索
54 * @name :searchParam 72 * @name :searchParam
55 * @author :lyh 73 * @author :lyh
@@ -82,6 +100,9 @@ class KeywordController extends BaseController @@ -82,6 +100,9 @@ class KeywordController extends BaseController
82 'id.required' => 'ID不能为空' 100 'id.required' => 'ID不能为空'
83 ]); 101 ]);
84 $data = $logic->getKeywordInfo(); 102 $data = $logic->getKeywordInfo();
  103 + if($data !== false){
  104 + $data = $this->handleReturnInfo($data);
  105 + }
85 $this->response('success',Code::SUCCESS,$data); 106 $this->response('success',Code::SUCCESS,$data);
86 } 107 }
87 108
@@ -330,7 +330,7 @@ class ProductController extends BaseController @@ -330,7 +330,7 @@ class ProductController extends BaseController
330 $arr = json_decode($info['values']); 330 $arr = json_decode($info['values']);
331 foreach ($arr as $k1=>$v1){ 331 foreach ($arr as $k1=>$v1){
332 $v1 = (array)$v1; 332 $v1 = (array)$v1;
333 - $v1['url'] = getImageUrl($v1['url'],$this->user['storage_type']); 333 + $v1['url'] = getImageUrl($v1['url'],$this->user['storage_type'],$this->user['project_location']);
334 $arr[$k1] = $v1; 334 $arr[$k1] = $v1;
335 } 335 }
336 $v['values'] = $arr; 336 $v['values'] = $arr;
@@ -339,9 +339,9 @@ class ProductController extends BaseController @@ -339,9 +339,9 @@ class ProductController extends BaseController
339 foreach ($arr1 as $k1=>$v1){ 339 foreach ($arr1 as $k1=>$v1){
340 $v1 = (array)$v1; 340 $v1 = (array)$v1;
341 if(isset($v1['url'])){ 341 if(isset($v1['url'])){
342 - $v1['url'] = getFileUrl($v1['url'],$this->user['storage_type']); 342 + $v1['url'] = getFileUrl($v1['url'],$this->user['storage_type'],$this->user['project_location']);
343 }else{ 343 }else{
344 - $v1 = getFileUrl($v1,$this->user['storage_type']); 344 + $v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location']);
345 } 345 }
346 $arr1[$k1] = $v1; 346 $arr1[$k1] = $v1;
347 } 347 }
@@ -25,7 +25,7 @@ class WebSettingImageController extends BaseController @@ -25,7 +25,7 @@ class WebSettingImageController extends BaseController
25 public function lists(WebSettingImage $webSettingImage){ 25 public function lists(WebSettingImage $webSettingImage){
26 $list = $webSettingImage->list([],'id',['id','image','type']); 26 $list = $webSettingImage->list([],'id',['id','image','type']);
27 foreach ($list as $k=>$v){ 27 foreach ($list as $k=>$v){
28 - $v['image'] = getImageUrl($v['image'],$this->user['storage_type']); 28 + $v['image'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
29 $list[$k] = $v; 29 $list[$k] = $v;
30 } 30 }
31 $this->response('success',Code::SUCCESS,$list); 31 $this->response('success',Code::SUCCESS,$list);
@@ -22,7 +22,7 @@ class WebSettingServiceController extends BaseController @@ -22,7 +22,7 @@ class WebSettingServiceController extends BaseController
22 $lists = $webSettingServiceLogic->setting_service_list(); 22 $lists = $webSettingServiceLogic->setting_service_list();
23 foreach ($lists as $k => $v){ 23 foreach ($lists as $k => $v){
24 if($v['type'] == self::TYPE_CODE){ 24 if($v['type'] == self::TYPE_CODE){
25 - $v['values_link'] = getImageUrl($v['values']); 25 + $v['values_link'] = getImageUrl($v['values'],$this->user['storage_type'],$this->user['project_location']);
26 $lists[$k] = $v; 26 $lists[$k] = $v;
27 } 27 }
28 } 28 }
@@ -22,7 +22,7 @@ class BTemplateController extends BaseController @@ -22,7 +22,7 @@ class BTemplateController extends BaseController
22 $lists = $BTemplateLogic->publicTemplateLists($this->map,$this->page,$this->row,$this->order); 22 $lists = $BTemplateLogic->publicTemplateLists($this->map,$this->page,$this->row,$this->order);
23 if(!empty($lists) && !empty($lists['list'])){ 23 if(!empty($lists) && !empty($lists['list'])){
24 foreach ($lists['list'] as $k => &$v){ 24 foreach ($lists['list'] as $k => &$v){
25 - $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']); 25 + $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
26 $lists['list'][$k] = $v; 26 $lists['list'][$k] = $v;
27 } 27 }
28 } 28 }
@@ -363,7 +363,7 @@ class ImageController extends Controller @@ -363,7 +363,7 @@ class ImageController extends Controller
363 $lists = $imageModel->lists($this->map,$this->page,$this->row); 363 $lists = $imageModel->lists($this->map,$this->page,$this->row);
364 if(!empty($lists) && !empty($lists['list'])){ 364 if(!empty($lists) && !empty($lists['list'])){
365 foreach ($lists['list'] as $k => $v){ 365 foreach ($lists['list'] as $k => $v){
366 - $v['image_link'] = getImageUrl($v['path'],$this->cache['storage_type'] ?? 0); 366 + $v['image_link'] = getImageUrl($v['path'],$this->cache['storage_type'] ?? 0,$this->cache['project_location']);
367 $lists['list'][$k] = $v; 367 $lists['list'][$k] = $v;
368 } 368 }
369 } 369 }
@@ -429,7 +429,7 @@ class ImageController extends Controller @@ -429,7 +429,7 @@ class ImageController extends Controller
429 public function responseData($path = '', $name = ''){ 429 public function responseData($path = '', $name = ''){
430 $data = [ 430 $data = [
431 'image'=>$path, 431 'image'=>$path,
432 - 'image_link'=>getImageUrl($path,$this->cache['storage_type'] ?? 0), 432 + 'image_link'=>getImageUrl($path,$this->cache['storage_type'] ?? 0,$this->cache['project_location']),
433 'name'=>$name, 433 'name'=>$name,
434 'image_download'=>url('a/download_images?path='.$path) 434 'image_download'=>url('a/download_images?path='.$path)
435 ]; 435 ];
@@ -64,12 +64,12 @@ class AyrReleaseLogic extends BaseLogic @@ -64,12 +64,12 @@ class AyrReleaseLogic extends BaseLogic
64 $imageModel = new Image(); 64 $imageModel = new Image();
65 $list = $imageModel->list(['path'=>['in',$images]],'id'); 65 $list = $imageModel->list(['path'=>['in',$images]],'id');
66 foreach ($list as $v1){ 66 foreach ($list as $v1){
67 - $arr[] = getImageUrl($v1['path']); 67 + $arr[] = getImageUrl($v1['path'],$this->user['storage_type'],$this->user['project_location']);
68 } 68 }
69 }else{ 69 }else{
70 $fileModel = new File(); 70 $fileModel = new File();
71 $info = $fileModel->read(['path'=>$v]); 71 $info = $fileModel->read(['path'=>$v]);
72 - $arr[] = getFileUrl($info['path']); 72 + $arr[] = getFileUrl($info['path'],$this->user['storage_type'],$this->user['project_location']);
73 } 73 }
74 } 74 }
75 return $this->success($arr); 75 return $this->success($arr);
@@ -101,7 +101,7 @@ class BlogLogic extends BaseLogic @@ -101,7 +101,7 @@ class BlogLogic extends BaseLogic
101 //获取标签名称 101 //获取标签名称
102 $blogLabelLogic = new BlogLabelLogic(); 102 $blogLabelLogic = new BlogLabelLogic();
103 $info['label_name'] = $blogLabelLogic->getLabelName($info['label_id']); 103 $info['label_name'] = $blogLabelLogic->getLabelName($info['label_id']);
104 - $info['image_link'] = getImageUrl($info['image'],$this->user['storage_type']); 104 + $info['image_link'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
105 return $this->success($info); 105 return $this->success($info);
106 } 106 }
107 107
@@ -82,7 +82,7 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -82,7 +82,7 @@ class CustomModuleCategoryLogic extends BaseLogic
82 if($info === false){ 82 if($info === false){
83 $this->fail('当前数据不存在或已被删除'); 83 $this->fail('当前数据不存在或已被删除');
84 } 84 }
85 - $info['image'] = getImageUrl($info['image']); 85 + $info['image'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
86 return $this->success($info); 86 return $this->success($info);
87 } 87 }
88 88
@@ -39,7 +39,7 @@ class CustomModuleContentLogic extends BaseLogic @@ -39,7 +39,7 @@ class CustomModuleContentLogic extends BaseLogic
39 if($info === false){ 39 if($info === false){
40 $this->fail('当前数据不存在或已被删除'); 40 $this->fail('当前数据不存在或已被删除');
41 } 41 }
42 - $info['image'] = getImageUrl($info['image'],$this->user['storage_type']); 42 + $info['image'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
43 $info['extend'] = $this->getExtendInfo($info['module_id'],$info['id']); 43 $info['extend'] = $this->getExtendInfo($info['module_id'],$info['id']);
44 return $this->success($info); 44 return $this->success($info);
45 } 45 }
@@ -86,14 +86,14 @@ class CustomModuleContentLogic extends BaseLogic @@ -86,14 +86,14 @@ class CustomModuleContentLogic extends BaseLogic
86 $arr = json_decode($info['values']); 86 $arr = json_decode($info['values']);
87 foreach ($arr as $k1=>$v1){ 87 foreach ($arr as $k1=>$v1){
88 $v1 = (array)$v1; 88 $v1 = (array)$v1;
89 - $v1['url'] = getImageUrl($v1['url'],$this->user['storage_type']); 89 + $v1['url'] = getImageUrl($v1['url'],$this->user['storage_type'],$this->user['project_location']);
90 $arr[$k1] = $v1; 90 $arr[$k1] = $v1;
91 } 91 }
92 $v['values'] = $arr; 92 $v['values'] = $arr;
93 }elseif($v['type'] == 4){ 93 }elseif($v['type'] == 4){
94 $arr1 = json_decode($info['values']); 94 $arr1 = json_decode($info['values']);
95 foreach ($arr1 as $k1=>$v1){ 95 foreach ($arr1 as $k1=>$v1){
96 - $v1 = getFileUrl($v1,$this->user['storage_type']); 96 + $v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location']);
97 $arr1[$k1] = $v1; 97 $arr1[$k1] = $v1;
98 } 98 }
99 $v['values'] = $arr1; 99 $v['values'] = $arr1;
@@ -97,7 +97,7 @@ class InquiryLogic extends BaseLogic @@ -97,7 +97,7 @@ class InquiryLogic extends BaseLogic
97 foreach ($data['list'] as &$v){ 97 foreach ($data['list'] as &$v){
98 foreach ($v['data'] as &$field){ 98 foreach ($v['data'] as &$field){
99 if(is_array($field) && !empty($field['path'])){ 99 if(is_array($field) && !empty($field['path'])){
100 - $field['path'] = getImageUrl($field['path']); 100 + $field['path'] = getImageUrl($field['path'],$this->user['storage_type'],$this->user['project_location']);
101 } 101 }
102 } 102 }
103 $v = array_merge($v, $v['data']); 103 $v = array_merge($v, $v['data']);
@@ -147,7 +147,7 @@ class NewsLogic extends BaseLogic @@ -147,7 +147,7 @@ class NewsLogic extends BaseLogic
147 $this->fail('error'); 147 $this->fail('error');
148 } 148 }
149 $info['category_id'] = explode(',',trim($info['category_id'],',')); 149 $info['category_id'] = explode(',',trim($info['category_id'],','));
150 - $info['image_link'] = getImageUrl($info['image'],$this->user['storage_type']); 150 + $info['image_link'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
151 return $this->success($info); 151 return $this->success($info);
152 } 152 }
153 153
@@ -32,7 +32,7 @@ class CategoryLogic extends BaseLogic @@ -32,7 +32,7 @@ class CategoryLogic extends BaseLogic
32 foreach ($data as &$v){ 32 foreach ($data as &$v){
33 $v['url'] = $this->user['domain'] . $v['route'] ; 33 $v['url'] = $this->user['domain'] . $v['route'] ;
34 $v['product_num'] = Category::getProductNum($v['id']); 34 $v['product_num'] = Category::getProductNum($v['id']);
35 - $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']); 35 + $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
36 } 36 }
37 if(!$map){ 37 if(!$map){
38 $data = Arr::listToTree($data); 38 $data = Arr::listToTree($data);
@@ -100,8 +100,8 @@ class CategoryLogic extends BaseLogic @@ -100,8 +100,8 @@ class CategoryLogic extends BaseLogic
100 if($info === false){ 100 if($info === false){
101 $this->fail('当前数据不存在或者已被删除'); 101 $this->fail('当前数据不存在或者已被删除');
102 } 102 }
103 - $info['image_link'] = getImageUrl($info['image']);  
104 - $info['describe_image'] = !empty($info['describe_image']) ? getImageUrl(json_decode($info['describe_image'])) : []; 103 + $info['image_link'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
  104 + $info['describe_image'] = !empty($info['describe_image']) ? getImageUrl(json_decode($info['describe_image']),$this->user['storage_type'],$this->user['project_location']) : [];
105 return $this->success($info); 105 return $this->success($info);
106 } 106 }
107 107
@@ -40,8 +40,10 @@ class KeywordLogic extends BaseLogic @@ -40,8 +40,10 @@ class KeywordLogic extends BaseLogic
40 public function getKeywordInfo() 40 public function getKeywordInfo()
41 { 41 {
42 $info = $this->model->read($this->param); 42 $info = $this->model->read($this->param);
  43 + if($info !== false){
43 $info['url'] = $this->user['domain'] . $info['route']; 44 $info['url'] = $this->user['domain'] . $info['route'];
44 $info['related_news_info'] = News::whereIn('id', $info['related_news_ids'])->select(['id', 'name'])->get(); 45 $info['related_news_info'] = News::whereIn('id', $info['related_news_ids'])->select(['id', 'name'])->get();
  46 + }
45 return $this->success($info); 47 return $this->success($info);
46 } 48 }
47 49
@@ -103,30 +105,20 @@ class KeywordLogic extends BaseLogic @@ -103,30 +105,20 @@ class KeywordLogic extends BaseLogic
103 * @time :2023/10/23 14:47 105 * @time :2023/10/23 14:47
104 */ 106 */
105 public function handleSaveParam($param){ 107 public function handleSaveParam($param){
106 - if(isset($param['keyword_top_banner']) && !empty($param['keyword_top_banner'])){  
107 - $param['keyword_top_banner'] = str_replace_url($param['keyword_top_banner']);  
108 - }else{  
109 - unset($param['keyword_top_banner']); 108 + if(isset($param['keyword_top_banner'])){
  109 + $param['keyword_top_banner'] = str_replace_url($param['keyword_top_banner'] ?? []);
110 } 110 }
111 - if(isset($param['keyword_foot_banner']) && !empty($param['keyword_foot_banner'])){  
112 - $param['keyword_foot_banner'] = str_replace_url($param['keyword_foot_banner']);  
113 - }else{  
114 - unset($param['keyword_foot_banner']); 111 + if(isset($param['keyword_foot_banner'])){
  112 + $param['keyword_foot_banner'] = str_replace_url($param['keyword_foot_banner'] ?? []);
115 } 113 }
116 - if(isset($param['keyword_video']) && !empty($param['keyword_video'])){  
117 - $param['keyword_video'] = Arr::a2s($param['keyword_video']);  
118 - }else{  
119 - unset($param['keyword_video']); 114 + if(isset($param['keyword_video'])){
  115 + $param['keyword_video'] = Arr::a2s($param['keyword_video'] ?? []);
120 } 116 }
121 if(!empty($param['related_news_ids'])){ 117 if(!empty($param['related_news_ids'])){
122 - $param['related_news_ids'] = Arr::arrToSet($param['related_news_ids']);  
123 - }else{  
124 - unset($param['related_news_ids']); 118 + $param['related_news_ids'] = Arr::arrToSet($param['related_news_ids'] ?? []);
125 } 119 }
126 if(!empty($param['related_blog_ids'])){ 120 if(!empty($param['related_blog_ids'])){
127 - $param['related_blog_ids'] = Arr::arrToSet($param['related_blog_ids']);  
128 - }else{  
129 - unset($param['related_blog_ids']); 121 + $param['related_blog_ids'] = Arr::arrToSet($param['related_blog_ids'] ?? []);
130 } 122 }
131 return $param; 123 return $param;
132 } 124 }
@@ -28,11 +28,11 @@ class WebSettingAmpLogic extends BaseLogic @@ -28,11 +28,11 @@ class WebSettingAmpLogic extends BaseLogic
28 return $this->success(); 28 return $this->success();
29 } 29 }
30 //log图处理 30 //log图处理
31 - $info['top_logo'] = getImageUrl($info['top_logo'], $this->user['storage_type'] ?? 0); 31 + $info['top_logo'] = getImageUrl($info['top_logo'],$this->user['storage_type'],$this->user['project_location']);
32 //banner处理 32 //banner处理
33 if (!empty($info['index_banner'])) { 33 if (!empty($info['index_banner'])) {
34 foreach ($info['index_banner'] as &$v) { 34 foreach ($info['index_banner'] as &$v) {
35 - $v = getImageUrl($v, $this->user['storage_type'] ?? 0); 35 + $v = getImageUrl($v,$this->user['storage_type'],$this->user['project_location']);
36 } 36 }
37 } 37 }
38 return $this->success($info); 38 return $this->success($info);
  1 +<?php
  2 +
  3 +namespace App\Listeners;
  4 +
  5 +use App\Events\CopyImageFile;
  6 +use App\Events\UpdateHtml;
  7 +use App\Jobs\updateHtmlJob;
  8 +use Illuminate\Contracts\Queue\ShouldQueue;
  9 +
  10 +class CopyImageFileListener implements ShouldQueue
  11 +{
  12 + public function __construct()
  13 + {
  14 + //
  15 + }
  16 +
  17 + /**
  18 + * Handle the event.
  19 + *
  20 + * @param UpdateHtml $event
  21 + * @return void
  22 + */
  23 + public function handle(CopyImageFile $event)
  24 + {
  25 + $this->param = $event->data;
  26 + }
  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 +
  37 + }
  38 +}
@@ -65,31 +65,31 @@ class BNav extends Base @@ -65,31 +65,31 @@ class BNav extends Base
65 return static::where(['pid'=>$id,'project_id'=>$project_id])->limit(1)->count(); 65 return static::where(['pid'=>$id,'project_id'=>$project_id])->limit(1)->count();
66 } 66 }
67 67
68 - /**  
69 - * @remark :获取图片  
70 - * @name :getImageAttribute  
71 - * @author :lyh  
72 - * @method :post  
73 - * @time :2023/9/18 16:20  
74 - */  
75 - public function getImageAttribute($value)  
76 - {  
77 - $value = getImageUrl($value);  
78 - return $value;  
79 - }  
80 -  
81 - /**  
82 - * @remark :获取图片  
83 - * @name :getImageAttribute  
84 - * @author :lyh  
85 - * @method :post  
86 - * @time :2023/9/18 16:20  
87 - */  
88 - public function getRemarkImageAttribute($value)  
89 - {  
90 - $value = getImageUrl($value);  
91 - return $value;  
92 - } 68 +// /**
  69 +// * @remark :获取图片
  70 +// * @name :getImageAttribute
  71 +// * @author :lyh
  72 +// * @method :post
  73 +// * @time :2023/9/18 16:20
  74 +// */
  75 +// public function getImageAttribute($value)
  76 +// {
  77 +// $value = getImageUrl($value);
  78 +// return $value;
  79 +// }
  80 +//
  81 +// /**
  82 +// * @remark :获取图片
  83 +// * @name :getImageAttribute
  84 +// * @author :lyh
  85 +// * @method :post
  86 +// * @time :2023/9/18 16:20
  87 +// */
  88 +// public function getRemarkImageAttribute($value)
  89 +// {
  90 +// $value = getImageUrl($value);
  91 +// return $value;
  92 +// }
93 93
94 /** 94 /**
95 * 是否支持一键导入 95 * 是否支持一键导入
@@ -13,35 +13,8 @@ class Keyword extends Base @@ -13,35 +13,8 @@ class Keyword extends Base
13 //设置关联表名 13 //设置关联表名
14 protected $table = 'gl_product_keyword'; 14 protected $table = 'gl_product_keyword';
15 15
16 -// protected $appends = ['route'];  
17 -  
18 //连接数据库 16 //连接数据库
19 protected $connection = 'custom_mysql'; 17 protected $connection = 'custom_mysql';
20 -// public function getRouteAttribute(){  
21 -// return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $this->id, $this->project_id);  
22 -// }  
23 -  
24 - /**  
25 - * @remark :图  
26 - * @name :getKeywordTopBannerAttribute  
27 - * @author :lyh  
28 - * @method :post  
29 - * @time :2023/7/21 11:11  
30 - */  
31 - public function getKeywordTopBannerAttribute($value){  
32 - return getImageUrl($value);  
33 - }  
34 -  
35 - /**  
36 - * @remark :图  
37 - * @name :getKeywordTopBannerAttribute  
38 - * @author :lyh  
39 - * @method :post  
40 - * @time :2023/7/21 11:11  
41 - */  
42 - public function getKeywordFootBannerAttribute($value){  
43 - return getImageUrl($value);  
44 - }  
45 18
46 /** 19 /**
47 * @remark :视频 20 * @remark :视频
@@ -2,12 +2,13 @@ @@ -2,12 +2,13 @@
2 2
3 namespace App\Providers; 3 namespace App\Providers;
4 4
  5 +use App\Events\CopyImageFile;
5 use App\Events\CopyProject; 6 use App\Events\CopyProject;
  7 +use App\Listeners\CopyImageFileListener;
6 use App\Listeners\CopyProjectListener; 8 use App\Listeners\CopyProjectListener;
7 use Illuminate\Auth\Events\Registered; 9 use Illuminate\Auth\Events\Registered;
8 use Illuminate\Auth\Listeners\SendEmailVerificationNotification; 10 use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
9 use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; 11 use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
10 -use Illuminate\Support\Facades\Event;  
11 12
12 class EventServiceProvider extends ServiceProvider 13 class EventServiceProvider extends ServiceProvider
13 { 14 {
@@ -25,6 +26,7 @@ class EventServiceProvider extends ServiceProvider @@ -25,6 +26,7 @@ class EventServiceProvider extends ServiceProvider
25 'App\Listeners\QueryListener', 26 'App\Listeners\QueryListener',
26 ], 27 ],
27 CopyProject::class => [CopyProjectListener::class], 28 CopyProject::class => [CopyProjectListener::class],
  29 + CopyImageFile::class => [CopyImageFileListener::class],
28 ]; 30 ];
29 31
30 /** 32 /**
@@ -56,4 +56,29 @@ class AmazonS3Service @@ -56,4 +56,29 @@ class AmazonS3Service
56 return false; 56 return false;
57 } 57 }
58 } 58 }
  59 +
  60 + /**
  61 + * @remark :同步图片文件到亚马逊
  62 + * @name :uploadImage
  63 + * @author :lyh
  64 + * @method :post
  65 + * @time :2024/1/23 9:20
  66 + */
  67 + public function SyncImageFiles($files)
  68 + {
  69 + $key = str_replace_url($files);
  70 + $body = $files;
  71 + try {
  72 + $result = $this->s3->putObject([
  73 + 'Bucket' => $this->bucket,
  74 + 'Key' => $key,
  75 + 'Body' => fopen($body, 'rb'),
  76 + ]);
  77 +
  78 + echo '文件成功上传到S3!';
  79 + } catch (AwsException $e) {
  80 + echo '上传文件到S3时发生错误:' . $e->getMessage();
  81 + return false;
  82 + }
  83 + }
59 } 84 }