作者 lyh

gx

@@ -32,6 +32,7 @@ use App\Models\Template\BTemplate; @@ -32,6 +32,7 @@ use App\Models\Template\BTemplate;
32 use App\Models\Template\BTemplateCom; 32 use App\Models\Template\BTemplateCom;
33 use App\Models\Template\BTemplateCommon; 33 use App\Models\Template\BTemplateCommon;
34 use App\Models\Template\Setting; 34 use App\Models\Template\Setting;
  35 +use App\Models\WebSetting\Translate;
35 use App\Models\WebSetting\WebSettingService; 36 use App\Models\WebSetting\WebSettingService;
36 use App\Services\AmazonS3Service; 37 use App\Services\AmazonS3Service;
37 use App\Services\ProjectServer; 38 use App\Services\ProjectServer;
@@ -56,28 +57,125 @@ class Demo extends Command @@ -56,28 +57,125 @@ class Demo extends Command
56 * @var string 57 * @var string
57 */ 58 */
58 protected $description = 'demo'; 59 protected $description = 'demo';
  60 +
  61 +
59 /** 62 /**
60 - * Execute the job.  
61 - *  
62 - * @return void 63 + * @remark :根据路由获取source+source_id
  64 + * @name :getRouteSource
  65 + * @author :lyh
  66 + * @method :post
  67 + * @time :2024/5/17 15:11
  68 + */
  69 + public function getRouteSource($route){
  70 + $data = ['source'=>0,'source_id'=>0,'is_list'=>0,'is_custom'=>0];
  71 + if(strtolower($route) == 'all'){
  72 + return $this->success($data);
  73 + }
  74 + if($route == '/'){
  75 + $data['source'] = 1;
  76 + return $this->success($data);
  77 + }
  78 + $route = basename($route);
  79 + $routeModel = new RouteMap();
  80 + $routeInfo = $routeModel->read(['route'=>$route]);
  81 + return $this->resultData($routeInfo,$data);
  82 + }
  83 +
  84 + /**
  85 + * @remark :返回数据
  86 + * @name :resultData
  87 + * @author :lyh
  88 + * @method :post
  89 + * @time :2024/5/20 11:54
63 */ 90 */
64 - public function handle()  
65 - { 91 + public function resultData($routeInfo,$data){
  92 + if($routeInfo['source'] == RouteMap::SOURCE_PAGE){
  93 + if($routeInfo['source_id']){
  94 + $data = ['source'=>9,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
  95 + }
  96 + }
  97 + if($routeInfo['source'] == RouteMap::SOURCE_PRODUCT){
  98 + if($routeInfo['source_id']){
  99 + $data = ['source'=>2,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
  100 + }
  101 + }
  102 + if($routeInfo['source'] == RouteMap::SOURCE_PRODUCT_CATE){
  103 + if($routeInfo['source_id']){
  104 + $data = ['source'=>2,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
  105 + }
  106 + }
  107 + if($routeInfo['source'] == RouteMap::SOURCE_BLOG){
  108 + if($routeInfo['source_id']){
  109 + $data = ['source'=>3,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
  110 + }
  111 + }
  112 + if($routeInfo['source'] == RouteMap::SOURCE_BLOG_CATE){
  113 + if($routeInfo['source_id']){
  114 + $data = ['source'=>3,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
  115 + }
  116 + }
  117 + if($routeInfo['source'] == RouteMap::SOURCE_NEWS){
  118 + if($routeInfo['source_id']){
  119 + $data = ['source'=>4,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
  120 + }
  121 + }
  122 + if($routeInfo['source'] == RouteMap::SOURCE_NEWS_CATE){
  123 + if($routeInfo['source_id']){
  124 + $data = ['source'=>4,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
  125 + }
  126 + }
  127 + if($routeInfo['source'] == RouteMap::SOURCE_MODULE){
  128 + if($routeInfo['source_id']){
  129 + $data = ['source'=>7,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>1];
  130 + }
  131 + }
  132 + if($routeInfo['source'] == RouteMap::SOURCE_MODULE_CATE){
  133 + if($routeInfo['source_id']){
  134 + $data = ['source'=>7,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>1];
  135 + }
  136 + }
  137 + return $data;
  138 + }
  139 +
  140 + public function handle(){
66 $projectModel = new Project(); 141 $projectModel = new Project();
67 $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]); 142 $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
68 - $data = [];  
69 foreach ($list as $v){ 143 foreach ($list as $v){
70 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 144 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
71 ProjectServer::useProject($v['id']); 145 ProjectServer::useProject($v['id']);
72 - DB::table('gl_web_template_com')->truncate();  
73 - $templateComModel = new BTemplateCom();  
74 - $templateComModel->truncate();  
75 - $this->saveTemplateCom($v['id']); 146 + $translateModel = new Translate();
  147 + $translateList = $translateModel->list();
  148 + foreach ($translateList as $value){
  149 + $data = $this->getRouteSource($value['url']);
  150 + $rs = $this->model->edit($data,['id'=>$value['id']]);
  151 + }
76 DB::disconnect('custom_mysql'); 152 DB::disconnect('custom_mysql');
77 } 153 }
78 - echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 154 + DB::disconnect('custom_mysql');
79 } 155 }
80 156
  157 + /**
  158 + * Execute the job.
  159 + *
  160 + * @return void
  161 + */
  162 +// public function handle()
  163 +// {
  164 +// $projectModel = new Project();
  165 +// $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
  166 +// $data = [];
  167 +// foreach ($list as $v){
  168 +// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
  169 +// ProjectServer::useProject($v['id']);
  170 +// DB::table('gl_web_template_com')->truncate();
  171 +// $templateComModel = new BTemplateCom();
  172 +// $templateComModel->truncate();
  173 +// $this->saveTemplateCom($v['id']);
  174 +// DB::disconnect('custom_mysql');
  175 +// }
  176 +// echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
  177 +// }
  178 +
81 public function saveTemplateCom($project_id){ 179 public function saveTemplateCom($project_id){
82 //获取当前项目选择的模版 180 //获取当前项目选择的模版
83 $settingModel = new Setting(); 181 $settingModel = new Setting();
@@ -683,6 +683,7 @@ if (!function_exists('str_replace_url')) { @@ -683,6 +683,7 @@ 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 + $cosCdn3 = $cos['cdn1'];
686 $cosCdn2 = config('filesystems.disks.s3')['cdn']; 687 $cosCdn2 = config('filesystems.disks.s3')['cdn'];
687 if($url && ((strpos($url,$cosCdn) !== false) || (strpos($url,$cosCdn1) !== false) || (strpos($url,$cosCdn2) !== false))){ 688 if($url && ((strpos($url,$cosCdn) !== false) || (strpos($url,$cosCdn1) !== false) || (strpos($url,$cosCdn2) !== false))){
688 // 外部URL无需解析 689 // 外部URL无需解析
@@ -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,