正在显示
3 个修改的文件
包含
208 行增加
和
163 行删除
| @@ -59,100 +59,7 @@ class Demo extends Command | @@ -59,100 +59,7 @@ class Demo extends Command | ||
| 59 | protected $description = 'demo'; | 59 | protected $description = 'demo'; |
| 60 | 60 | ||
| 61 | 61 | ||
| 62 | - /** | ||
| 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 | ||
| 90 | - */ | ||
| 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 | 62 | ||
| 140 | - public function handle(){ | ||
| 141 | - $projectModel = new Project(); | ||
| 142 | - $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]); | ||
| 143 | - foreach ($list as $v){ | ||
| 144 | - echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | ||
| 145 | - ProjectServer::useProject($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 | - } | ||
| 152 | - DB::disconnect('custom_mysql'); | ||
| 153 | - } | ||
| 154 | - DB::disconnect('custom_mysql'); | ||
| 155 | - } | ||
| 156 | 63 | ||
| 157 | 64 | ||
| 158 | } | 65 | } |
app/Console/Commands/Test/HeaderFooter.php
0 → 100644
| 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 | +} |
| @@ -9,10 +9,14 @@ | @@ -9,10 +9,14 @@ | ||
| 9 | 9 | ||
| 10 | namespace App\Console\Commands\Test; | 10 | namespace App\Console\Commands\Test; |
| 11 | 11 | ||
| 12 | +use App\Models\Project\Project; | ||
| 13 | +use App\Models\RouteMap\RouteMap; | ||
| 12 | use App\Models\Template\BTemplateCom; | 14 | use App\Models\Template\BTemplateCom; |
| 13 | use App\Models\Template\BTemplateCommon; | 15 | use App\Models\Template\BTemplateCommon; |
| 14 | use App\Models\Template\Setting; | 16 | use App\Models\Template\Setting; |
| 17 | +use App\Services\ProjectServer; | ||
| 15 | use Illuminate\Console\Command; | 18 | use Illuminate\Console\Command; |
| 19 | +use Illuminate\Support\Facades\DB; | ||
| 16 | 20 | ||
| 17 | class Translate extends Command | 21 | class Translate extends Command |
| 18 | { | 22 | { |
| @@ -21,92 +25,107 @@ class Translate extends Command | @@ -21,92 +25,107 @@ class Translate extends Command | ||
| 21 | * | 25 | * |
| 22 | * @var string | 26 | * @var string |
| 23 | */ | 27 | */ |
| 24 | - protected $signature = 'common_header'; | 28 | + protected $signature = 'translate'; |
| 25 | 29 | ||
| 26 | /** | 30 | /** |
| 27 | * The console command description. | 31 | * The console command description. |
| 28 | * | 32 | * |
| 29 | * @var string | 33 | * @var string |
| 30 | */ | 34 | */ |
| 31 | - protected $description = 'common_header'; | ||
| 32 | - /** | ||
| 33 | - * Execute the job. | ||
| 34 | - * | ||
| 35 | - * @return void | ||
| 36 | - */ | ||
| 37 | - public function handle() | ||
| 38 | - { | 35 | + protected $description = 'translate'; |
| 36 | + public function handle(){ | ||
| 39 | $projectModel = new Project(); | 37 | $projectModel = new Project(); |
| 40 | $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]); | 38 | $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]); |
| 41 | - $data = []; | ||
| 42 | foreach ($list as $v){ | 39 | foreach ($list as $v){ |
| 43 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | 40 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; |
| 44 | ProjectServer::useProject($v['id']); | 41 | ProjectServer::useProject($v['id']); |
| 45 | - DB::table('gl_web_template_com')->truncate(); | ||
| 46 | - $templateComModel = new BTemplateCom(); | ||
| 47 | - $templateComModel->truncate(); | ||
| 48 | - $this->saveTemplateCom($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 | + } | ||
| 49 | DB::disconnect('custom_mysql'); | 48 | DB::disconnect('custom_mysql'); |
| 50 | } | 49 | } |
| 51 | - echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | 50 | + DB::disconnect('custom_mysql'); |
| 52 | } | 51 | } |
| 53 | 52 | ||
| 54 | - public function saveTemplateCom($project_id){ | ||
| 55 | - //获取当前项目选择的模版 | ||
| 56 | - $settingModel = new Setting(); | ||
| 57 | - $settingInfo = $settingModel->read(['project_id'=>$project_id]); | ||
| 58 | - echo date('Y-m-d H:i:s') . '设置的模版:'.json_encode($settingInfo) . PHP_EOL; | ||
| 59 | - if($settingInfo !== false){ | ||
| 60 | - $templateCommonModel = new BTemplateCommon(); | ||
| 61 | - $commonList = $templateCommonModel->list(['template_id'=>['in',[$settingInfo['template_id'],0]]]); | ||
| 62 | - if(!empty($commonList)){ | ||
| 63 | - foreach ($commonList as $v){ | ||
| 64 | - $typeArr = [1, 2, 3]; | ||
| 65 | - foreach ($typeArr as $type){ | ||
| 66 | - if($type == 1){ | ||
| 67 | - $headData = [ | ||
| 68 | - 'project_id'=>$v['project_id'], | ||
| 69 | - 'source'=>$v['type'] == 1 ? 99 : $v['type'], | ||
| 70 | - 'common_type'=>1, | ||
| 71 | - 'template_id'=>$v['template_id'], | ||
| 72 | - 'html'=>$v['head_html'], | ||
| 73 | - 'html_style'=>$v['head_css'], | ||
| 74 | - 'is_custom'=>$v['is_custom'], | ||
| 75 | - 'is_list'=>$v['is_list'] | ||
| 76 | - ]; | ||
| 77 | - $templateComModel = new BTemplateCom(); | ||
| 78 | - $templateComModel->add($headData); | ||
| 79 | - }elseif ($type == 2){ | ||
| 80 | - $footerData = [ | ||
| 81 | - 'project_id'=>$v['project_id'], | ||
| 82 | - 'source'=>$v['type'] == 1 ? 99 : $v['type'], | ||
| 83 | - 'common_type'=>2, | ||
| 84 | - 'template_id'=>$v['template_id'], | ||
| 85 | - 'html'=>$v['footer_html'], | ||
| 86 | - 'html_style'=>$v['footer_css'], | ||
| 87 | - 'is_custom'=>$v['is_custom'], | ||
| 88 | - 'is_list'=>$v['is_list'] | ||
| 89 | - ]; | ||
| 90 | - $templateComModel = new BTemplateCom(); | ||
| 91 | - $templateComModel->add($footerData); | ||
| 92 | - }elseif ($type == 3){ | ||
| 93 | - $otherData = [ | ||
| 94 | - 'project_id'=>$v['project_id'], | ||
| 95 | - 'source'=>$v['type'] == 1 ? 99 : $v['type'], | ||
| 96 | - 'common_type'=>3, | ||
| 97 | - 'template_id'=>$v['template_id'], | ||
| 98 | - 'html'=>$v['other'], | ||
| 99 | - 'html_style'=>null, | ||
| 100 | - 'is_custom'=>$v['is_custom'], | ||
| 101 | - 'is_list'=>$v['is_list'] | ||
| 102 | - ]; | ||
| 103 | - $templateComModel = new BTemplateCom(); | ||
| 104 | - $templateComModel->add($otherData); | ||
| 105 | - } | ||
| 106 | - } | ||
| 107 | - } | 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]; | ||
| 108 | } | 86 | } |
| 109 | } | 87 | } |
| 110 | - return true; | 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; | ||
| 111 | } | 129 | } |
| 130 | + | ||
| 112 | } | 131 | } |
-
请 注册 或 登录 后发表评论