作者 lyh

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6

@@ -456,11 +456,11 @@ if (!function_exists('getImageUrl')) { @@ -456,11 +456,11 @@ if (!function_exists('getImageUrl')) {
456 * @method :post 456 * @method :post
457 * @time :2023/7/20 16:46 457 * @time :2023/7/20 16:46
458 */ 458 */
459 - function getImageUrl($path,$location = 1){ 459 + function getImageUrl($path,$location = 0,$storage_type = 0){
460 if(is_array($path)){ 460 if(is_array($path)){
461 $url =[]; 461 $url =[];
462 foreach ($path as $v){ 462 foreach ($path as $v){
463 - $url[] = getImageUrl($v); 463 + $url[] = getImageUrl($v,$location,$storage_type);
464 } 464 }
465 }else{ 465 }else{
466 if(empty($path)){ 466 if(empty($path)){
@@ -472,9 +472,9 @@ if (!function_exists('getImageUrl')) { @@ -472,9 +472,9 @@ if (!function_exists('getImageUrl')) {
472 if(substr($path,0,2) == '//'){ 472 if(substr($path,0,2) == '//'){
473 return 'https:'.$path; 473 return 'https:'.$path;
474 } 474 }
475 - if($location == 1){ 475 + if($location == 0){
476 $cos = config('filesystems.disks.cos'); 476 $cos = config('filesystems.disks.cos');
477 - $cosCdn = $cos['cdn']; 477 + $cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
478 $url = $cosCdn.$path; 478 $url = $cosCdn.$path;
479 }else{ 479 }else{
480 $url = url($path); 480 $url = url($path);
@@ -483,6 +483,7 @@ if (!function_exists('getImageUrl')) { @@ -483,6 +483,7 @@ if (!function_exists('getImageUrl')) {
483 return $url; 483 return $url;
484 } 484 }
485 } 485 }
  486 +
486 if (!function_exists('getFileUrl')) { 487 if (!function_exists('getFileUrl')) {
487 /** 488 /**
488 * @remark :获取文件链接 489 * @remark :获取文件链接
@@ -491,11 +492,11 @@ if (!function_exists('getFileUrl')) { @@ -491,11 +492,11 @@ if (!function_exists('getFileUrl')) {
491 * @method :post 492 * @method :post
492 * @time :2023/7/20 16:46 493 * @time :2023/7/20 16:46
493 */ 494 */
494 - function getFileUrl($path,$location = 1){ 495 + function getFileUrl($path,$location = 0,$storage_type = 0){
495 if(is_array($path)){ 496 if(is_array($path)){
496 $url =[]; 497 $url =[];
497 foreach ($path as $v){ 498 foreach ($path as $v){
498 - $url[] = getFileUrl($v); 499 + $url[] = getFileUrl($v,$location,$storage_type);
499 } 500 }
500 }else{ 501 }else{
501 if(empty($path)){ 502 if(empty($path)){
@@ -507,9 +508,9 @@ if (!function_exists('getFileUrl')) { @@ -507,9 +508,9 @@ if (!function_exists('getFileUrl')) {
507 if(substr($path,0,2) == '//'){ 508 if(substr($path,0,2) == '//'){
508 return 'https:'.$path; 509 return 'https:'.$path;
509 } 510 }
510 - if($location == 1){ 511 + if($location == 0){
511 $cos = config('filesystems.disks.cos'); 512 $cos = config('filesystems.disks.cos');
512 - $cosCdn = $cos['cdn']; 513 + $cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
513 $url = $cosCdn.$path; 514 $url = $cosCdn.$path;
514 }else{ 515 }else{
515 $url = url($path); 516 $url = url($path);
@@ -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']); 41 + $v['image_link'] = getImageUrl($v['image'],$this->user['project_location'],$this->user['storage_type']);
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;
@@ -186,10 +186,8 @@ class BlogController extends BaseController @@ -186,10 +186,8 @@ class BlogController extends BaseController
186 'id.required' => 'ID不能为空' 186 'id.required' => 'ID不能为空'
187 ]); 187 ]);
188 $info = $blogLogic->blogInfo(); 188 $info = $blogLogic->blogInfo();
189 -  
190 $template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL); 189 $template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL);
191 $info['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL,$template_id, $info['id']); 190 $info['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL,$template_id, $info['id']);
192 -  
193 $this->response('success',Code::SUCCESS,$info); 191 $this->response('success',Code::SUCCESS,$info);
194 } 192 }
195 193
@@ -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']); 40 + $v['image_link'] = getImageUrl($v['image'],$this->user['project_location'],$this->user['storage_type']);
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 }
@@ -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']); 44 + $v['image_link'] = getImageUrl($v['image'],$this->user['project_location'],$this->user['storage_type']);
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;
@@ -175,10 +175,8 @@ class NewsController extends BaseController @@ -175,10 +175,8 @@ class NewsController extends BaseController
175 'id.required' => 'ID不能为空', 175 'id.required' => 'ID不能为空',
176 ]); 176 ]);
177 $info = $newsLogic->newsInfo(); 177 $info = $newsLogic->newsInfo();
178 -  
179 $template_id = $this->getTemplateId(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL);//获取模版id 178 $template_id = $this->getTemplateId(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL);//获取模版id
180 $info['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL,$template_id, $info['id']); 179 $info['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL,$template_id, $info['id']);
181 -  
182 $this->response('success',Code::SUCCESS,$info); 180 $this->response('success',Code::SUCCESS,$info);
183 } 181 }
184 182
@@ -41,7 +41,7 @@ class CategoryController extends BaseController @@ -41,7 +41,7 @@ class CategoryController extends BaseController
41 foreach ($list as $k =>$v){ 41 foreach ($list as $k =>$v){
42 $v['url'] = $this->user['domain'] . $v['route'].'/'; 42 $v['url'] = $this->user['domain'] . $v['route'].'/';
43 $v['product_num'] = Category::getProductNum($v['id']); 43 $v['product_num'] = Category::getProductNum($v['id']);
44 - $v['image_link'] = getImageUrl($v['image']); 44 + $v['image_link'] = getImageUrl($v['image'],$this->user['project_location'],$this->user['storage_type']);
45 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']); 45 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
46 $list[$k] = $v; 46 $list[$k] = $v;
47 } 47 }
@@ -56,11 +56,12 @@ class ProductController extends BaseController @@ -56,11 +56,12 @@ class ProductController extends BaseController
56 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id 56 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id
57 $userModel = new User(); 57 $userModel = new User();
58 foreach ($lists['list'] as $k=>$v){ 58 foreach ($lists['list'] as $k=>$v){
  59 + $v['url'] = $this->user['domain'].$v['route'].'/';
59 $v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data); 60 $v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data);
60 $v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data); 61 $v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
61 $v['created_uid_text'] = $userModel->getName($v['created_uid']); 62 $v['created_uid_text'] = $userModel->getName($v['created_uid']);
62 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id']); 63 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id']);
63 - $v['url'] = $this->user['domain'].$v['route'].'/'; 64 + $v = $this->getHandleFileImage($v);
64 $lists['list'][$k] = $v; 65 $lists['list'][$k] = $v;
65 } 66 }
66 } 67 }
@@ -68,7 +69,40 @@ class ProductController extends BaseController @@ -68,7 +69,40 @@ class ProductController extends BaseController
68 } 69 }
69 70
70 /** 71 /**
71 - * @remark :处理列表返回参数 72 + * @remark :获取时处理图片和文件
  73 + * @name :getHandleFileImage
  74 + * @author :lyh
  75 + * @method :post
  76 + * @time :2024/1/23 17:43
  77 + */
  78 + public function getHandleFileImage($v){
  79 + //ToDo::处理图片及文件
  80 + if(!empty($v['thumb']) && !empty($v['thumb']['url'])){
  81 + $v['thumb']['url'] = getImageUrl($v['thumb']['url'],$this->user['project_location'],$this->user['storage_type']);
  82 + }
  83 + if(!empty($v['gallery'])){
  84 + foreach ($v['gallery'] as $gallery_k => $gallery_v){
  85 + $gallery_v['url'] = getImageUrl($gallery_v['url'],$this->user['project_location'],$this->user['storage_type']);
  86 + $v['gallery'][$gallery_k] = $gallery_v;
  87 + }
  88 + }
  89 + if(!empty($v['icon'])){
  90 + foreach ($v['icon'] as $icon_k => $icon_v){
  91 + $icon_v = getImageUrl($icon_v,$this->user['project_location'],$this->user['storage_type']);
  92 + $v['icon'][$icon_k] = $icon_v;
  93 + }
  94 + }
  95 + if(!empty($v['video']) && !empty($v['video']['url'])){
  96 + $v['video']['url'] = getImageUrl($v['video']['url'],$this->user['project_location'],$this->user['storage_type']);
  97 + }
  98 + if(!empty($v['files']) && !empty($v['files']['url'])){
  99 + $v['files']['url'] = getImageUrl($v['files']['url'],$this->user['project_location'],$this->user['storage_type']);
  100 + }
  101 + return $this->success($v);
  102 + }
  103 +
  104 + /**
  105 + * @remark :搜索参数处理
72 * @name :handleReturnParam 106 * @name :handleReturnParam
73 * @author :lyh 107 * @author :lyh
74 * @method :post 108 * @method :post
@@ -243,6 +277,8 @@ class ProductController extends BaseController @@ -243,6 +277,8 @@ class ProductController extends BaseController
243 }else{ 277 }else{
244 $v['status_text'] = ''; 278 $v['status_text'] = '';
245 } 279 }
  280 + //ToDo::处理图片及文件
  281 + $v = $this->getHandleFileImage($v);
246 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL); 282 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);
247 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id'] ?? 0); 283 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id'] ?? 0);
248 $v['url'] = $this->user['domain'].$v['route']; 284 $v['url'] = $this->user['domain'].$v['route'];
@@ -251,6 +287,7 @@ class ProductController extends BaseController @@ -251,6 +287,7 @@ class ProductController extends BaseController
251 return $v; 287 return $v;
252 } 288 }
253 289
  290 +
254 /** 291 /**
255 * @remark :获取扩展字段详情 292 * @remark :获取扩展字段详情
256 * @name :getExtendInfo 293 * @name :getExtendInfo
@@ -293,7 +330,7 @@ class ProductController extends BaseController @@ -293,7 +330,7 @@ class ProductController extends BaseController
293 $arr = json_decode($info['values']); 330 $arr = json_decode($info['values']);
294 foreach ($arr as $k1=>$v1){ 331 foreach ($arr as $k1=>$v1){
295 $v1 = (array)$v1; 332 $v1 = (array)$v1;
296 - $v1['url'] = getImageUrl($v1['url']); 333 + $v1['url'] = getImageUrl($v1['url'],$this->user['project_location'],$this->user['storage_type']);
297 $arr[$k1] = $v1; 334 $arr[$k1] = $v1;
298 } 335 }
299 $v['values'] = $arr; 336 $v['values'] = $arr;
@@ -302,9 +339,9 @@ class ProductController extends BaseController @@ -302,9 +339,9 @@ class ProductController extends BaseController
302 foreach ($arr1 as $k1=>$v1){ 339 foreach ($arr1 as $k1=>$v1){
303 $v1 = (array)$v1; 340 $v1 = (array)$v1;
304 if(isset($v1['url'])){ 341 if(isset($v1['url'])){
305 - $v1['url'] = getFileUrl($v1['url']); 342 + $v1['url'] = getFileUrl($v1['url'],$this->user['project_location'],$this->user['storage_type']);
306 }else{ 343 }else{
307 - $v1 = getFileUrl($v1); 344 + $v1 = getFileUrl($v1,$this->user['project_location'],$this->user['storage_type']);
308 } 345 }
309 $arr1[$k1] = $v1; 346 $arr1[$k1] = $v1;
310 } 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']); 28 + $v['image'] = getImageUrl($v['image'],$this->user['project_location'],$this->user['storage_type']);
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 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']); 25 + $v['image_link'] = getImageUrl($v['image'],$this->user['project_location'],$this->user['storage_type']);
26 $lists['list'][$k] = $v; 26 $lists['list'][$k] = $v;
27 } 27 }
28 } 28 }
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\File; @@ -5,6 +5,7 @@ namespace App\Http\Controllers\File;
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Models\File\File; 6 use App\Models\File\File;
7 use App\Models\Project\Project; 7 use App\Models\Project\Project;
  8 +use App\Services\AmazonS3Service;
8 use App\Services\CosService; 9 use App\Services\CosService;
9 use Illuminate\Http\Exceptions\HttpResponseException; 10 use Illuminate\Http\Exceptions\HttpResponseException;
10 use Illuminate\Http\JsonResponse; 11 use Illuminate\Http\JsonResponse;
@@ -121,14 +122,13 @@ class FileController @@ -121,14 +122,13 @@ class FileController
121 $url = $this->config['root'].$this->path; 122 $url = $this->config['root'].$this->path;
122 $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension(); 123 $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
123 //同步数据到cos 124 //同步数据到cos
124 - if($this->upload_location == 1){ 125 + if($this->upload_location == 0){
125 $cosService = new CosService(); 126 $cosService = new CosService();
126 $cosService->uploadFile($files,$this->path,$fileName); 127 $cosService->uploadFile($files,$this->path,$fileName);
127 }else{ 128 }else{
128 - $res = $files->move($url,$fileName);  
129 - if ($res === false) {  
130 - return $this->response($files->getError(), Code::USER_ERROR);  
131 - } 129 + //TODO::上传亚马逊
  130 + $amazonS3Service = new AmazonS3Service();
  131 + $amazonS3Service->uploadFiles($files,$this->path,$fileName);
132 } 132 }
133 $this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name); 133 $this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
134 $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name)); 134 $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
@@ -165,7 +165,9 @@ class FileController @@ -165,7 +165,9 @@ class FileController
165 $cosService = new CosService(); 165 $cosService = new CosService();
166 $cosService->uploadFile($files, $this->path, $fileName); 166 $cosService->uploadFile($files, $this->path, $fileName);
167 } else { 167 } else {
168 - $res = $files->move($url, $fileName); 168 + //TODO::上传亚马逊
  169 + $amazonS3Service = new AmazonS3Service();
  170 + $res = $amazonS3Service->uploadFiles($files,$this->path,$fileName);
169 if ($res === false) { 171 if ($res === false) {
170 return [ 172 return [
171 'message' => $files->getError(), 173 'message' => $files->getError(),
@@ -196,7 +198,7 @@ class FileController @@ -196,7 +198,7 @@ class FileController
196 'hash' => $hash, 198 'hash' => $hash,
197 'type'=>$image_type, 199 'type'=>$image_type,
198 'refer'=>$this->param['refer'] ?? 1, 200 'refer'=>$this->param['refer'] ?? 1,
199 - 'is_cos'=>$is_cos, 201 + 'is_cos'=>($is_cos == 0) ? 1 : 0,
200 'mime'=>$mime, 202 'mime'=>$mime,
201 'project_id'=>$this->cache['project_id'] ?? 0, 203 'project_id'=>$this->cache['project_id'] ?? 0,
202 'name'=>$name, 204 'name'=>$name,
@@ -234,14 +236,13 @@ class FileController @@ -234,14 +236,13 @@ class FileController
234 $file_type = $file->getClientOriginalExtension(); 236 $file_type = $file->getClientOriginalExtension();
235 $fileName = uniqid().rand(10000,99999).'.'.$file_type; 237 $fileName = uniqid().rand(10000,99999).'.'.$file_type;
236 //同步数据到cos 238 //同步数据到cos
237 - if($this->upload_location == 1){ 239 + if($this->upload_location == 0){
238 $cosService = new CosService(); 240 $cosService = new CosService();
239 $cosService->uploadFile($files,$this->path,$fileName); 241 $cosService->uploadFile($files,$this->path,$fileName);
240 }else{ 242 }else{
241 - $res = $files->move($url,$fileName);  
242 - if ($res === false) {  
243 - return $this->response($files->getError(), Code::USER_ERROR);  
244 - } 243 + //TODO::上传亚马逊
  244 + $amazonS3Service = new AmazonS3Service();
  245 + $amazonS3Service->uploadFiles($files,$this->path,$fileName);
245 } 246 }
246 $size = $file->getSize(); 247 $size = $file->getSize();
247 $mime = $file->getMimeType(); 248 $mime = $file->getMimeType();
@@ -313,7 +314,7 @@ class FileController @@ -313,7 +314,7 @@ class FileController
313 $projectModel = new Project(); 314 $projectModel = new Project();
314 $project_info = $projectModel->read(['id' => $this->cache['project_id']], ['project_location']); 315 $project_info = $projectModel->read(['id' => $this->cache['project_id']], ['project_location']);
315 if ($project_info['project_location'] != 0) {//通项目时 上传到cos 316 if ($project_info['project_location'] != 0) {//通项目时 上传到cos
316 - $this->upload_location = 0;//1:上传到本地 317 + $this->upload_location = 1;//1:上传到本地
317 } 318 }
318 } 319 }
319 $this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m'); 320 $this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m');
@@ -335,7 +336,7 @@ class FileController @@ -335,7 +336,7 @@ class FileController
335 $fileModel = new File(); 336 $fileModel = new File();
336 $lists = $fileModel->list($this->map,'id',['id','hash','type','path','created_at','name']); 337 $lists = $fileModel->list($this->map,'id',['id','hash','type','path','created_at','name']);
337 foreach ($lists as $k => $v){ 338 foreach ($lists as $k => $v){
338 - $v['file_link'] = getFileUrl($v['path']); 339 + $v['file_link'] = getFileUrl($v['path'],$this->cache['project_location'] ?? 0,$this->cache['storage_type'] ?? 0);
339 $lists[$k] = $v; 340 $lists[$k] = $v;
340 } 341 }
341 $this->response('success',Code::SUCCESS,$lists); 342 $this->response('success',Code::SUCCESS,$lists);
@@ -351,7 +352,7 @@ class FileController @@ -351,7 +352,7 @@ class FileController
351 public function responseData($path, $name){ 352 public function responseData($path, $name){
352 $data = [ 353 $data = [
353 'file'=>$path, 354 'file'=>$path,
354 - 'file_link'=>getFileUrl($path,$this->upload_location), 355 + 'file_link'=>getFileUrl($path,$this->cache['project_location'] ?? 0,$this->cache['storage_type'] ?? 0),
355 'name'=>$name, 356 'name'=>$name,
356 'file_download'=>url('a/download_files?path='.$path) 357 'file_download'=>url('a/download_files?path='.$path)
357 ]; 358 ];
@@ -7,6 +7,7 @@ use App\Http\Controllers\Controller; @@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
7 use App\Http\Controllers\type; 7 use App\Http\Controllers\type;
8 use App\Models\File\Image as ImageModel; 8 use App\Models\File\Image as ImageModel;
9 use App\Models\Project\Project; 9 use App\Models\Project\Project;
  10 +use App\Services\AmazonS3Service;
10 use App\Services\CosService; 11 use App\Services\CosService;
11 use App\Services\TencentCosService; 12 use App\Services\TencentCosService;
12 use Illuminate\Http\Exceptions\HttpResponseException; 13 use Illuminate\Http\Exceptions\HttpResponseException;
@@ -36,7 +37,7 @@ class ImageController extends Controller @@ -36,7 +37,7 @@ class ImageController extends Controller
36 37
37 38
38 39
39 - public $upload_location = 1;//是否同步到cos 40 + public $upload_location = 0;//同步到cos
40 //上传图片类型 41 //上传图片类型
41 public $image_type = [ 42 public $image_type = [
42 1 => 'image_product', 43 1 => 'image_product',
@@ -200,11 +201,13 @@ class ImageController extends Controller @@ -200,11 +201,13 @@ class ImageController extends Controller
200 } 201 }
201 $fileName = uniqid().rand(10000,99999).'.'.$image_type; 202 $fileName = uniqid().rand(10000,99999).'.'.$image_type;
202 //上传到cos 203 //上传到cos
203 - if($this->upload_location == 1){ 204 + if($this->upload_location == 0){
204 $cosService = new CosService(); 205 $cosService = new CosService();
205 $cosService->uploadFile($files,$this->path,$fileName); 206 $cosService->uploadFile($files,$this->path,$fileName);
206 }else{ 207 }else{
207 - $files->move($url,$fileName); 208 + //TODO::上传亚马逊
  209 + $amazonS3Service = new AmazonS3Service();
  210 + $amazonS3Service->uploadFiles($files,$this->path,$fileName);
208 } 211 }
209 $this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name); 212 $this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name);
210 return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name)); 213 return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
@@ -225,7 +228,7 @@ class ImageController extends Controller @@ -225,7 +228,7 @@ class ImageController extends Controller
225 'hash' => $hash, 228 'hash' => $hash,
226 'type'=>$image_type, 229 'type'=>$image_type,
227 'refer'=>$this->param['refer'] ?? 0, 230 'refer'=>$this->param['refer'] ?? 0,
228 - 'is_cos'=>$is_cos, 231 + 'is_cos'=>($is_cos == 0) ? 1 : 0,
229 'mime'=>$mime, 232 'mime'=>$mime,
230 'project_id'=>$this->cache['project_id'] ?? 0, 233 'project_id'=>$this->cache['project_id'] ?? 0,
231 'name'=>$name, 234 'name'=>$name,
@@ -278,11 +281,13 @@ class ImageController extends Controller @@ -278,11 +281,13 @@ class ImageController extends Controller
278 $image_type = $file->getClientOriginalExtension(); 281 $image_type = $file->getClientOriginalExtension();
279 $fileName = uniqid().rand(10000,99999).'.'.$image_type; 282 $fileName = uniqid().rand(10000,99999).'.'.$image_type;
280 //同步数据到cos 283 //同步数据到cos
281 - if($this->upload_location == 1){ 284 + if($this->upload_location == 0){
282 $cosService = new CosService(); 285 $cosService = new CosService();
283 $cosService->uploadFile($file,$this->path,$fileName); 286 $cosService->uploadFile($file,$this->path,$fileName);
284 }else{ 287 }else{
285 - $file->move($url,$fileName); 288 + //TODO::上传亚马逊
  289 + $amazonS3Service = new AmazonS3Service();
  290 + $amazonS3Service->uploadFiles($files,$this->path,$fileName);
286 } 291 }
287 //批量存储 292 //批量存储
288 $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name); 293 $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
@@ -359,7 +364,7 @@ class ImageController extends Controller @@ -359,7 +364,7 @@ class ImageController extends Controller
359 $lists = $imageModel->lists($this->map,$this->page,$this->row); 364 $lists = $imageModel->lists($this->map,$this->page,$this->row);
360 if(!empty($lists) && !empty($lists['list'])){ 365 if(!empty($lists) && !empty($lists['list'])){
361 foreach ($lists['list'] as $k => $v){ 366 foreach ($lists['list'] as $k => $v){
362 - $v['image_link'] = getImageUrl($v['path']); 367 + $v['image_link'] = getImageUrl($v['path'],$this->cache['project_location'] ?? 0,$this->cache['storage_type'] ?? 0);
363 $lists['list'][$k] = $v; 368 $lists['list'][$k] = $v;
364 } 369 }
365 } 370 }
@@ -408,7 +413,7 @@ class ImageController extends Controller @@ -408,7 +413,7 @@ class ImageController extends Controller
408 $projectModel = new Project(); 413 $projectModel = new Project();
409 $project_info = $projectModel->read(['id'=>$this->cache['project_id']],['project_location']); 414 $project_info = $projectModel->read(['id'=>$this->cache['project_id']],['project_location']);
410 if ($project_info['project_location'] != 0) {//危险项目时 上传到本地 415 if ($project_info['project_location'] != 0) {//危险项目时 上传到本地
411 - $this->upload_location = 0;//上传到cos 416 + $this->upload_location = 1;//上传到本地
412 } 417 }
413 } 418 }
414 $this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m'); 419 $this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m');
@@ -425,7 +430,7 @@ class ImageController extends Controller @@ -425,7 +430,7 @@ class ImageController extends Controller
425 public function responseData($path = '', $name = ''){ 430 public function responseData($path = '', $name = ''){
426 $data = [ 431 $data = [
427 'image'=>$path, 432 'image'=>$path,
428 - 'image_link'=>getImageUrl($path), 433 + 'image_link'=>getImageUrl($path,$this->cache['project_location'] ?? 0,$this->cache['storage_type'] ?? 0),
429 'name'=>$name, 434 'name'=>$name,
430 'image_download'=>url('a/download_images?path='.$path) 435 'image_download'=>url('a/download_images?path='.$path)
431 ]; 436 ];
@@ -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']); 104 + $info['image_link'] = getImageUrl($info['image'],$this->user['project_location'],$this->user['storage_type']);
105 return $this->success($info); 105 return $this->success($info);
106 } 106 }
107 107
@@ -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']); 42 + $info['image'] = getImageUrl($info['image'],$this->user['project_location'],$this->user['storage_type']);
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']); 89 + $v1['url'] = getImageUrl($v1['url'],$this->user['project_location'],$this->user['storage_type']);
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); 96 + $v1 = getFileUrl($v1,$this->user['project_location'],$this->user['storage_type']);
97 $arr1[$k1] = $v1; 97 $arr1[$k1] = $v1;
98 } 98 }
99 $v['values'] = $arr1; 99 $v['values'] = $arr1;
@@ -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']); 150 + $info['image_link'] = getImageUrl($info['image'],$this->user['project_location'],$this->user['storage_type']);
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']); 35 + $v['image_link'] = getImageUrl($v['image'],$this->user['project_location'],$this->user['storage_type']);
36 } 36 }
37 if(!$map){ 37 if(!$map){
38 $data = Arr::listToTree($data); 38 $data = Arr::listToTree($data);
@@ -171,6 +171,8 @@ class UserLoginLogic @@ -171,6 +171,8 @@ class UserLoginLogic
171 $info['main_lang_id'] = $project['main_lang_id']; 171 $info['main_lang_id'] = $project['main_lang_id'];
172 $info['image_max'] = $project['image_max']; 172 $info['image_max'] = $project['image_max'];
173 $info['uptime'] = $project['uptime']; 173 $info['uptime'] = $project['uptime'];
  174 + $info['storage_type'] = $project['storage_type'];
  175 + $info['project_location'] = $project['project_location'];
174 $info['is_update_language'] = $project['is_update_language']; 176 $info['is_update_language'] = $project['is_update_language'];
175 $info['configuration'] = $project['deploy_build']['configuration']; 177 $info['configuration'] = $project['deploy_build']['configuration'];
176 $info['project_type'] = $project['type']; 178 $info['project_type'] = $project['type'];
@@ -213,6 +215,8 @@ class UserLoginLogic @@ -213,6 +215,8 @@ class UserLoginLogic
213 $info['is_update_language'] = $project['is_update_language']; 215 $info['is_update_language'] = $project['is_update_language'];
214 $info['configuration'] = $project['deploy_build']['configuration']; 216 $info['configuration'] = $project['deploy_build']['configuration'];
215 $info['project_type'] = $project['type']; 217 $info['project_type'] = $project['type'];
  218 + $info['storage_type'] = $project['storage_type'];
  219 + $info['project_location'] = $project['project_location'];
216 if($info['is_customized'] == 1){ 220 if($info['is_customized'] == 1){
217 $info['is_visualization'] = json_decode($project['is_visualization']); 221 $info['is_visualization'] = json_decode($project['is_visualization']);
218 } 222 }
@@ -102,51 +102,9 @@ class Product extends Base @@ -102,51 +102,9 @@ class Product extends Base
102 3=>'热销产品' 102 3=>'热销产品'
103 ]; 103 ];
104 104
105 -  
106 - /**  
107 - * 产品列表  
108 - * @param $map  
109 - * @param $page  
110 - * @param $row  
111 - * @param string $order  
112 - * @param string[] $fields  
113 - * @param string $sort  
114 - * @return array  
115 - * @author zbj  
116 - * @date 2023/10/17  
117 - */  
118 - public function product_lists($map, $page, $row, $order = 'id', $fields = ['*'], $sort = 'desc'): array  
119 - {  
120 - $category_id = $map['category_id'] ?? 0;  
121 - $query = $this->where(function ($query) use ($category_id) {  
122 - if ($category_id) {  
123 - $category_ids = Category::getChildIdsArr($category_id);  
124 - $query->whereIn('id', function ($subQuery) use ($category_ids) {  
125 - $subQuery->select('product_id')  
126 - ->from('gl_product_category_related')  
127 - ->whereIn('cate_id', $category_ids)  
128 - ->groupBy('product_id');  
129 - });  
130 - }  
131 - });  
132 - unset($map['category_id']);  
133 - $query = $this->formatQuery($map, $query);  
134 - $query = $this->sortOrder($query,$order,$sort);  
135 - $lists = $query->select($fields)->paginate($row, ['*'], 'page', $page);  
136 - if (empty($lists)) {  
137 - return [];  
138 - }  
139 - $lists = $lists->toArray();  
140 - return $lists;  
141 - }  
142 -  
143 -  
144 public function getThumbAttribute($value){ 105 public function getThumbAttribute($value){
145 if(!empty($value)){ 106 if(!empty($value)){
146 - $value = json_decode($value,true);  
147 - if(!empty($value['url'])){  
148 - $value['url'] = getImageUrl($value['url']);  
149 - } 107 + $value = Arr::s2a($value);
150 } 108 }
151 return $value; 109 return $value;
152 } 110 }
@@ -155,12 +113,6 @@ class Product extends Base @@ -155,12 +113,6 @@ class Product extends Base
155 public function getGalleryAttribute($value){ 113 public function getGalleryAttribute($value){
156 if(!empty($value)){ 114 if(!empty($value)){
157 $value = Arr::s2a($value); 115 $value = Arr::s2a($value);
158 - foreach ($value as $k => $v){  
159 - if(!empty($v['url'])){  
160 - $v['url'] = getImageUrl($v['url']);  
161 - }  
162 - $value[$k] = $v;  
163 - }  
164 } 116 }
165 return $value; 117 return $value;
166 } 118 }
@@ -175,9 +127,6 @@ class Product extends Base @@ -175,9 +127,6 @@ class Product extends Base
175 public function getFilesAttribute($value){ 127 public function getFilesAttribute($value){
176 if(!empty($value)){ 128 if(!empty($value)){
177 $value = Arr::s2a($value); 129 $value = Arr::s2a($value);
178 - if(!empty($value['url'])){  
179 - $value['url'] = getImageUrl($value['url']);  
180 - }  
181 } 130 }
182 return $value; 131 return $value;
183 } 132 }
@@ -192,10 +141,6 @@ class Product extends Base @@ -192,10 +141,6 @@ class Product extends Base
192 public function getVideoAttribute($value){ 141 public function getVideoAttribute($value){
193 if(!empty($value)){ 142 if(!empty($value)){
194 $value = Arr::s2a($value); 143 $value = Arr::s2a($value);
195 - $value = Arr::s2a($value);  
196 - if(!empty($value['url'])){  
197 - $value['url'] = getImageUrl($value['url']);  
198 - }  
199 } 144 }
200 return $value; 145 return $value;
201 } 146 }
@@ -210,10 +155,6 @@ class Product extends Base @@ -210,10 +155,6 @@ class Product extends Base
210 public function getIconAttribute($value){ 155 public function getIconAttribute($value){
211 if(!empty($value)){ 156 if(!empty($value)){
212 $value = Arr::s2a($value); 157 $value = Arr::s2a($value);
213 - foreach ($value as $k => $v){  
214 - $v = getImageUrl($v);  
215 - $value[$k] = $v;  
216 - }  
217 } 158 }
218 return $value; 159 return $value;
219 } 160 }
@@ -15,10 +15,10 @@ class AmazonS3Service @@ -15,10 +15,10 @@ class AmazonS3Service
15 { 15 {
16 // 替换为你自己的 AWS 访问密钥、区域和存储桶名称 16 // 替换为你自己的 AWS 访问密钥、区域和存储桶名称
17 protected $s3; 17 protected $s3;
18 - protected $accessKeyId = '';//key  
19 - protected $secretAccessKey = '';//密匙  
20 - protected $region = '';//地址  
21 - protected $bucket = '';//桶子 18 + protected $accessKeyId = 'AKIAU6YKND7SAWIKBXCZ';//key
  19 + protected $secretAccessKey = 'Hwd2abya/2Icu6NMDo4YrdTqCtir1BeTuUj5kEkB';//密匙
  20 + protected $region = 's3://arn:aws:s3:us-west-2:340934860772:accesspoint/globalso-v6';//地址
  21 + protected $bucket = 'arn:aws:s3:::globalso-v6';//桶子
22 22
23 public function __construct() 23 public function __construct()
24 { 24 {
@@ -40,13 +40,15 @@ class AmazonS3Service @@ -40,13 +40,15 @@ class AmazonS3Service
40 * @method :post 40 * @method :post
41 * @time :2024/1/23 9:20 41 * @time :2024/1/23 9:20
42 */ 42 */
43 - public function uploadFiles($localFilePath, $s3Key) 43 + public function uploadFiles(&$files, $s3Key,$filename ,$binary = false)
44 { 44 {
  45 + $key = $s3Key.'/'.$filename;
  46 + $Body = $binary ? $files : fopen($files->getRealPath(), 'r');
45 try { 47 try {
46 $result = $this->s3->putObject([ 48 $result = $this->s3->putObject([
47 'Bucket' => $this->bucket, 49 'Bucket' => $this->bucket,
48 - 'Key' => $s3Key,  
49 - 'SourceFile' => $localFilePath, 50 + 'Key' => $key,
  51 + 'SourceFile' => $Body,
50 'ACL' => 'public-read', // 设置图片为公共可读,可根据需求修改 52 'ACL' => 'public-read', // 设置图片为公共可读,可根据需求修改
51 ]); 53 ]);
52 return $result['ObjectURL']; 54 return $result['ObjectURL'];
@@ -78,6 +78,7 @@ return [ @@ -78,6 +78,7 @@ return [
78 ], 78 ],
79 'bucket' => env('COS_BUCKET'), 79 'bucket' => env('COS_BUCKET'),
80 'cdn' => env('COS_CDN'), 80 'cdn' => env('COS_CDN'),
  81 + 'cdn1' => env('COS_CDN1'),
81 'timeout' => 60, 82 'timeout' => 60,
82 'connect_timeout' => 60, 83 'connect_timeout' => 60,
83 ], 84 ],