作者 Your Name
@@ -12,31 +12,9 @@ use App\Models\File\File; @@ -12,31 +12,9 @@ use App\Models\File\File;
12 use App\Models\File\File as FileModel; 12 use App\Models\File\File as FileModel;
13 use App\Models\File\Image; 13 use App\Models\File\Image;
14 use App\Models\File\Image as ImageModel; 14 use App\Models\File\Image as ImageModel;
15 -use App\Models\Manage\BelongingGroup;  
16 -use App\Models\Manage\Dept;  
17 -use App\Models\Manage\EntryPosition;  
18 -use App\Models\Manage\ManageHr;  
19 -use App\Models\Nav\BNav;  
20 -use App\Models\Nav\BNavGroup;  
21 -use App\Models\Product\Keyword;  
22 -use App\Models\Product\Product;  
23 -use App\Models\Project\DeployOptimize;  
24 -use App\Models\Project\MinorLanguages;  
25 -use App\Models\Project\Project;  
26 -use App\Models\RouteMap\RouteMap;  
27 -use App\Models\Template\BCustomTemplate;  
28 -use App\Models\Template\BTemplate;  
29 -use App\Models\Template\BTemplateCom;  
30 -use App\Models\Template\BTemplateCommon;  
31 -use App\Models\Template\Setting;  
32 -use App\Models\WebSetting\WebSettingService;  
33 use App\Services\AmazonS3Service; 15 use App\Services\AmazonS3Service;
34 -use App\Services\ProjectServer;  
35 -use App\Services\SyncService;  
36 -use GuzzleHttp\Client;  
37 use Illuminate\Console\Command; 16 use Illuminate\Console\Command;
38 -use Illuminate\Support\Facades\DB;  
39 -use Illuminate\Support\Facades\Log; 17 +
40 18
41 class Demo extends Command 19 class Demo extends Command
42 { 20 {
@@ -54,6 +32,7 @@ class Demo extends Command @@ -54,6 +32,7 @@ class Demo extends Command
54 */ 32 */
55 protected $description = 'demo'; 33 protected $description = 'demo';
56 34
  35 +
57 /** 36 /**
58 * Execute the job. 37 * Execute the job.
59 * 38 *
@@ -61,77 +40,29 @@ class Demo extends Command @@ -61,77 +40,29 @@ class Demo extends Command
61 */ 40 */
62 public function handle() 41 public function handle()
63 { 42 {
64 - $projectModel = new Project();  
65 - $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);  
66 - $data = [];  
67 - foreach ($list as $v){  
68 - echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;  
69 - ProjectServer::useProject($v['id']);  
70 - DB::table('gl_web_template_com')->truncate();  
71 - $templateComModel = new BTemplateCom();  
72 - $templateComModel->truncate();  
73 - $this->saveTemplateCom($v['id']);  
74 - DB::disconnect('custom_mysql');  
75 - }  
76 - echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;  
77 - } 43 + $this->param['project_id'] = 181;
  44 + $imageModel = new ImageModel();
  45 +// //获取当前项目的所有图片
  46 +// $imageList = $imageModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','size']);
  47 +// if(!empty($imageList)){
  48 +// $amazonS3Service = new AmazonS3Service();
  49 +// foreach ($imageList as $k => $v){
  50 +// $amazonS3Service->syncImageFiles(getImageUrl($v['path']));
  51 +// $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);
  52 +// }
  53 +// }
78 54
79 - public function saveTemplateCom($project_id){  
80 - //获取当前项目选择的模版  
81 - $settingModel = new Setting();  
82 - $settingInfo = $settingModel->read(['project_id'=>$project_id]);  
83 - echo date('Y-m-d H:i:s') . '设置的模版:'.json_encode($settingInfo) . PHP_EOL;  
84 - if($settingInfo !== false){  
85 - $templateCommonModel = new BTemplateCommon();  
86 - $commonList = $templateCommonModel->list(['template_id'=>['in',[$settingInfo['template_id'],0]]]);  
87 - if(!empty($commonList)){  
88 - foreach ($commonList as $v){  
89 - $typeArr = [1, 2, 3];  
90 - foreach ($typeArr as $type){  
91 - if($type == 1){  
92 - $headData = [  
93 - 'project_id'=>$v['project_id'],  
94 - 'source'=>$v['type'] == 1 ? 99 : $v['type'],  
95 - 'common_type'=>1,  
96 - 'template_id'=>$v['template_id'],  
97 - 'html'=>$v['head_html'],  
98 - 'html_style'=>$v['head_css'],  
99 - 'is_custom'=>$v['is_custom'],  
100 - 'is_list'=>$v['is_list']  
101 - ];  
102 - $templateComModel = new BTemplateCom();  
103 - $templateComModel->add($headData);  
104 - }elseif ($type == 2){  
105 - $footerData = [  
106 - 'project_id'=>$v['project_id'],  
107 - 'source'=>$v['type'] == 1 ? 99 : $v['type'],  
108 - 'common_type'=>2,  
109 - 'template_id'=>$v['template_id'],  
110 - 'html'=>$v['footer_html'],  
111 - 'html_style'=>$v['footer_css'],  
112 - 'is_custom'=>$v['is_custom'],  
113 - 'is_list'=>$v['is_list']  
114 - ];  
115 - $templateComModel = new BTemplateCom();  
116 - $templateComModel->add($footerData);  
117 - }elseif ($type == 3){  
118 - $otherData = [  
119 - 'project_id'=>$v['project_id'],  
120 - 'source'=>$v['type'] == 1 ? 99 : $v['type'],  
121 - 'common_type'=>3,  
122 - 'template_id'=>$v['template_id'],  
123 - 'html'=>$v['other'],  
124 - 'html_style'=>null,  
125 - 'is_custom'=>$v['is_custom'],  
126 - 'is_list'=>$v['is_list']  
127 - ];  
128 - $templateComModel = new BTemplateCom();  
129 - $templateComModel->add($otherData);  
130 - }  
131 - }  
132 - } 55 + $fileModel = new FileModel();
  56 + $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','name']);
  57 + if(!empty($fileList)){
  58 + $amazonS3Service = new AmazonS3Service();
  59 + foreach ($fileList as $k => $v){
  60 + echo date('Y-m-d H:i:s') . '执行的数据id:' . $v['id'] . '名称:'.$v['name'] . PHP_EOL;
  61 + $amazonS3Service->syncImageFiles(getFileUrl($v['path']));
  62 + $fileModel->edit(['is_cos'=>0],['id'=>$v['id']]);
133 } 63 }
134 } 64 }
135 return true; 65 return true;
136 } 66 }
  67 +
137 } 68 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :HeaderFooter.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/21 9:42
  8 + */
  9 +
  10 +namespace App\Console\Commands\Test;
  11 +
  12 +use App\Models\Template\BTemplateCom;
  13 +use App\Models\Template\BTemplateCommon;
  14 +use App\Models\Template\Setting;
  15 +use Illuminate\Console\Command;
  16 +
  17 +/**
  18 + * @remark :头部底部分开 脚本数据
  19 + * @name :HeaderFooter
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2024/5/21 9:42
  23 + */
  24 +class HeaderFooter extends Command
  25 +{
  26 + /**
  27 + * The name and signature of the console command.
  28 + *
  29 + * @var string
  30 + */
  31 + protected $signature = 'common_header';
  32 +
  33 + /**
  34 + * The console command description.
  35 + *
  36 + * @var string
  37 + */
  38 + protected $description = 'common_header';
  39 + /**
  40 + * Execute the job.
  41 + *
  42 + * @return void
  43 + */
  44 + public function handle()
  45 + {
  46 + $projectModel = new Project();
  47 + $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
  48 + $data = [];
  49 + foreach ($list as $v){
  50 + echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
  51 + ProjectServer::useProject($v['id']);
  52 + DB::table('gl_web_template_com')->truncate();
  53 + $templateComModel = new BTemplateCom();
  54 + $templateComModel->truncate();
  55 + $this->saveTemplateCom($v['id']);
  56 + DB::disconnect('custom_mysql');
  57 + }
  58 + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
  59 + }
  60 +
  61 + public function saveTemplateCom($project_id){
  62 + //获取当前项目选择的模版
  63 + $settingModel = new Setting();
  64 + $settingInfo = $settingModel->read(['project_id'=>$project_id]);
  65 + echo date('Y-m-d H:i:s') . '设置的模版:'.json_encode($settingInfo) . PHP_EOL;
  66 + if($settingInfo !== false){
  67 + $templateCommonModel = new BTemplateCommon();
  68 + $commonList = $templateCommonModel->list(['template_id'=>['in',[$settingInfo['template_id'],0]]]);
  69 + if(!empty($commonList)){
  70 + foreach ($commonList as $v){
  71 + $typeArr = [1, 2, 3];
  72 + foreach ($typeArr as $type){
  73 + if($type == 1){
  74 + $headData = [
  75 + 'project_id'=>$v['project_id'],
  76 + 'source'=>$v['type'] == 1 ? 99 : $v['type'],
  77 + 'common_type'=>1,
  78 + 'template_id'=>$v['template_id'],
  79 + 'html'=>$v['head_html'],
  80 + 'html_style'=>$v['head_css'],
  81 + 'is_custom'=>$v['is_custom'],
  82 + 'is_list'=>$v['is_list']
  83 + ];
  84 + $templateComModel = new BTemplateCom();
  85 + $templateComModel->add($headData);
  86 + }elseif ($type == 2){
  87 + $footerData = [
  88 + 'project_id'=>$v['project_id'],
  89 + 'source'=>$v['type'] == 1 ? 99 : $v['type'],
  90 + 'common_type'=>2,
  91 + 'template_id'=>$v['template_id'],
  92 + 'html'=>$v['footer_html'],
  93 + 'html_style'=>$v['footer_css'],
  94 + 'is_custom'=>$v['is_custom'],
  95 + 'is_list'=>$v['is_list']
  96 + ];
  97 + $templateComModel = new BTemplateCom();
  98 + $templateComModel->add($footerData);
  99 + }elseif ($type == 3){
  100 + $otherData = [
  101 + 'project_id'=>$v['project_id'],
  102 + 'source'=>$v['type'] == 1 ? 99 : $v['type'],
  103 + 'common_type'=>3,
  104 + 'template_id'=>$v['template_id'],
  105 + 'html'=>$v['other'],
  106 + 'html_style'=>null,
  107 + 'is_custom'=>$v['is_custom'],
  108 + 'is_list'=>$v['is_list']
  109 + ];
  110 + $templateComModel = new BTemplateCom();
  111 + $templateComModel->add($otherData);
  112 + }
  113 + }
  114 + }
  115 + }
  116 + }
  117 + return true;
  118 + }
  119 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :Translate.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/21 9:32
  8 + */
  9 +
  10 +namespace App\Console\Commands\Test;
  11 +
  12 +use App\Models\Project\Project;
  13 +use App\Models\RouteMap\RouteMap;
  14 +use App\Models\Template\BTemplateCom;
  15 +use App\Models\Template\BTemplateCommon;
  16 +use App\Models\Template\Setting;
  17 +use App\Services\ProjectServer;
  18 +use Illuminate\Console\Command;
  19 +use Illuminate\Support\Facades\DB;
  20 +
  21 +class Translate extends Command
  22 +{
  23 + /**
  24 + * The name and signature of the console command.
  25 + *
  26 + * @var string
  27 + */
  28 + protected $signature = 'translate';
  29 +
  30 + /**
  31 + * The console command description.
  32 + *
  33 + * @var string
  34 + */
  35 + protected $description = 'translate';
  36 + public function handle(){
  37 + $projectModel = new Project();
  38 + $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
  39 + foreach ($list as $v){
  40 + echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
  41 + ProjectServer::useProject($v['id']);
  42 + $translateModel = new \App\Models\WebSetting\Translate();
  43 + $translateList = $translateModel->list();
  44 + foreach ($translateList as $value){
  45 + $data = $this->getRouteSource($value['url']);
  46 + $rs = $this->model->edit($data,['id'=>$value['id']]);
  47 + }
  48 + DB::disconnect('custom_mysql');
  49 + }
  50 + DB::disconnect('custom_mysql');
  51 + }
  52 +
  53 + /**
  54 + * @remark :根据路由获取source+source_id
  55 + * @name :getRouteSource
  56 + * @author :lyh
  57 + * @method :post
  58 + * @time :2024/5/17 15:11
  59 + */
  60 + public function getRouteSource($route){
  61 + $data = ['source'=>0,'source_id'=>0,'is_list'=>0,'is_custom'=>0];
  62 + if(strtolower($route) == 'all'){
  63 + return $this->success($data);
  64 + }
  65 + if($route == '/'){
  66 + $data['source'] = 1;
  67 + return $this->success($data);
  68 + }
  69 + $route = basename($route);
  70 + $routeModel = new RouteMap();
  71 + $routeInfo = $routeModel->read(['route'=>$route]);
  72 + return $this->resultData($routeInfo,$data);
  73 + }
  74 +
  75 + /**
  76 + * @remark :返回数据
  77 + * @name :resultData
  78 + * @author :lyh
  79 + * @method :post
  80 + * @time :2024/5/20 11:54
  81 + */
  82 + public function resultData($routeInfo,$data){
  83 + if($routeInfo['source'] == RouteMap::SOURCE_PAGE){
  84 + if($routeInfo['source_id']){
  85 + $data = ['source'=>9,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
  86 + }
  87 + }
  88 + if($routeInfo['source'] == RouteMap::SOURCE_PRODUCT){
  89 + if($routeInfo['source_id']){
  90 + $data = ['source'=>2,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
  91 + }
  92 + }
  93 + if($routeInfo['source'] == RouteMap::SOURCE_PRODUCT_CATE){
  94 + if($routeInfo['source_id']){
  95 + $data = ['source'=>2,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
  96 + }
  97 + }
  98 + if($routeInfo['source'] == RouteMap::SOURCE_BLOG){
  99 + if($routeInfo['source_id']){
  100 + $data = ['source'=>3,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
  101 + }
  102 + }
  103 + if($routeInfo['source'] == RouteMap::SOURCE_BLOG_CATE){
  104 + if($routeInfo['source_id']){
  105 + $data = ['source'=>3,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
  106 + }
  107 + }
  108 + if($routeInfo['source'] == RouteMap::SOURCE_NEWS){
  109 + if($routeInfo['source_id']){
  110 + $data = ['source'=>4,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
  111 + }
  112 + }
  113 + if($routeInfo['source'] == RouteMap::SOURCE_NEWS_CATE){
  114 + if($routeInfo['source_id']){
  115 + $data = ['source'=>4,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
  116 + }
  117 + }
  118 + if($routeInfo['source'] == RouteMap::SOURCE_MODULE){
  119 + if($routeInfo['source_id']){
  120 + $data = ['source'=>7,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>1];
  121 + }
  122 + }
  123 + if($routeInfo['source'] == RouteMap::SOURCE_MODULE_CATE){
  124 + if($routeInfo['source_id']){
  125 + $data = ['source'=>7,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>1];
  126 + }
  127 + }
  128 + return $data;
  129 + }
  130 +
  131 +}
@@ -683,8 +683,9 @@ if (!function_exists('str_replace_url')) { @@ -683,8 +683,9 @@ if (!function_exists('str_replace_url')) {
683 $cos = config('filesystems.disks.cos'); 683 $cos = config('filesystems.disks.cos');
684 $cosCdn = $cos['cdn']; 684 $cosCdn = $cos['cdn'];
685 $cosCdn1 = $cos['cdn1']; 685 $cosCdn1 = $cos['cdn1'];
686 - $cosCdn2 = config('filesystems.disks.s3')['cdn'];  
687 - if($url && ((strpos($url,$cosCdn) !== false) || (strpos($url,$cosCdn1) !== false) || (strpos($url,$cosCdn2) !== false))){ 686 + $cosCdn2 = $cos['cdn2'];
  687 + $cosCdn3 = config('filesystems.disks.s3')['cdn'];
  688 + if($url && ((strpos($url,$cosCdn) !== false) || (strpos($url,$cosCdn1) !== false) || (strpos($url,$cosCdn2) !== false) || (strpos($url,$cosCdn3) !== false))){
688 // 外部URL无需解析 689 // 外部URL无需解析
689 // 使用 parse_url 函数来解析 URL 690 // 使用 parse_url 函数来解析 URL
690 $urlParts = parse_url($url); 691 $urlParts = parse_url($url);
@@ -48,6 +48,7 @@ class AyrReleaseController extends BaseController @@ -48,6 +48,7 @@ class AyrReleaseController extends BaseController
48 $info = $ayrShareLogic->ayr_share_info($this->param['share_id']); 48 $info = $ayrShareLogic->ayr_share_info($this->param['share_id']);
49 $this->response('success',Code::SUCCESS,$info); 49 $this->response('success',Code::SUCCESS,$info);
50 } 50 }
  51 +
51 /** 52 /**
52 * @name :(发布社交)send_post 53 * @name :(发布社交)send_post
53 * @author :lyh 54 * @author :lyh
@@ -259,17 +259,17 @@ class TranslateLogic extends BaseLogic @@ -259,17 +259,17 @@ class TranslateLogic extends BaseLogic
259 // try { 259 // try {
260 $info = $this->model->read(['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]); 260 $info = $this->model->read(['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
261 if($info === false){ 261 if($info === false){
262 - $data = $this->getRouteSource($this->param['url']); 262 + $sourceInfo = $this->getRouteSource($this->param['url']);
263 $param = [ 263 $param = [
264 'type'=>$this->param['type'], 264 'type'=>$this->param['type'],
265 'project_id'=>$this->user['project_id'], 265 'project_id'=>$this->user['project_id'],
266 'url'=>str_replace_url($this->param['url']), 266 'url'=>str_replace_url($this->param['url']),
267 'language_id'=>$this->param['language_id'], 267 'language_id'=>$this->param['language_id'],
268 'alias'=>$this->param['alias'], 268 'alias'=>$this->param['alias'],
269 - 'source'=>$data['source'],  
270 - 'source_id'=>$data['source_id'],  
271 - 'is_list'=>$data['is_list'],  
272 - 'is_custom'=>$data['is_custom'] 269 + 'source'=>$sourceInfo['source'],
  270 + 'source_id'=>$sourceInfo['source_id'],
  271 + 'is_list'=>$sourceInfo['is_list'],
  272 + 'is_custom'=>$sourceInfo['is_custom']
273 ]; 273 ];
274 $param['data'] = json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); 274 $param['data'] = json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
275 $rs = $this->model->add($param); 275 $rs = $this->model->add($param);
@@ -68,6 +68,10 @@ class AmazonS3Service @@ -68,6 +68,10 @@ class AmazonS3Service
68 { 68 {
69 $file_content = curl_c($files,false); 69 $file_content = curl_c($files,false);
70 $key = str_replace_url($files); 70 $key = str_replace_url($files);
  71 + $parsedUrl = parse_url($key);
  72 + if(isset($parsedUrl['path'])){
  73 + $key = $parsedUrl['path'];
  74 + }
71 try { 75 try {
72 $result = $this->s3->putObject([ 76 $result = $this->s3->putObject([
73 'Bucket' => $this->bucket, 77 'Bucket' => $this->bucket,