Demo.php
8.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2023/2/7
* Time: 17:58
*/
namespace App\Console\Commands\Test;
use App\Helper\Common;
use App\Models\Blog\Blog;
use App\Models\Devops\ServerConfig;
use App\Models\Domain\DomainInfo;
use App\Models\File\File;
use App\Models\File\File as FileModel;
use App\Models\File\Image;
use App\Models\File\Image as ImageModel;
use App\Models\Manage\BelongingGroup;
use App\Models\Manage\Dept;
use App\Models\Manage\EntryPosition;
use App\Models\Manage\ManageHr;
use App\Models\Nav\BNav;
use App\Models\Nav\BNavGroup;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\DeployOptimize;
use App\Models\Project\MinorLanguages;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCom;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\Setting;
use App\Models\WebSetting\Translate;
use App\Models\WebSetting\WebSettingService;
use App\Services\AmazonS3Service;
use App\Services\ProjectServer;
use App\Services\SyncService;
use GuzzleHttp\Client;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class Demo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'demo';
/**
* The console command description.
*
* @var string
*/
protected $description = 'demo';
/**
* @remark :根据路由获取source+source_id
* @name :getRouteSource
* @author :lyh
* @method :post
* @time :2024/5/17 15:11
*/
public function getRouteSource($route){
$data = ['source'=>0,'source_id'=>0,'is_list'=>0,'is_custom'=>0];
if(strtolower($route) == 'all'){
return $this->success($data);
}
if($route == '/'){
$data['source'] = 1;
return $this->success($data);
}
$route = basename($route);
$routeModel = new RouteMap();
$routeInfo = $routeModel->read(['route'=>$route]);
return $this->resultData($routeInfo,$data);
}
/**
* @remark :返回数据
* @name :resultData
* @author :lyh
* @method :post
* @time :2024/5/20 11:54
*/
public function resultData($routeInfo,$data){
if($routeInfo['source'] == RouteMap::SOURCE_PAGE){
if($routeInfo['source_id']){
$data = ['source'=>9,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_PRODUCT){
if($routeInfo['source_id']){
$data = ['source'=>2,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_PRODUCT_CATE){
if($routeInfo['source_id']){
$data = ['source'=>2,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_BLOG){
if($routeInfo['source_id']){
$data = ['source'=>3,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_BLOG_CATE){
if($routeInfo['source_id']){
$data = ['source'=>3,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_NEWS){
if($routeInfo['source_id']){
$data = ['source'=>4,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_NEWS_CATE){
if($routeInfo['source_id']){
$data = ['source'=>4,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_MODULE){
if($routeInfo['source_id']){
$data = ['source'=>7,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>1];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_MODULE_CATE){
if($routeInfo['source_id']){
$data = ['source'=>7,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>1];
}
}
return $data;
}
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$translateModel = new Translate();
$translateList = $translateModel->list();
foreach ($translateList as $value){
$data = $this->getRouteSource($value['url']);
$rs = $this->model->edit($data,['id'=>$value['id']]);
}
DB::disconnect('custom_mysql');
}
DB::disconnect('custom_mysql');
}
/**
* Execute the job.
*
* @return void
*/
// public function handle()
// {
// $projectModel = new Project();
// $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
// $data = [];
// foreach ($list as $v){
// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
// ProjectServer::useProject($v['id']);
// DB::table('gl_web_template_com')->truncate();
// $templateComModel = new BTemplateCom();
// $templateComModel->truncate();
// $this->saveTemplateCom($v['id']);
// DB::disconnect('custom_mysql');
// }
// echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
// }
public function saveTemplateCom($project_id){
//获取当前项目选择的模版
$settingModel = new Setting();
$settingInfo = $settingModel->read(['project_id'=>$project_id]);
echo date('Y-m-d H:i:s') . '设置的模版:'.json_encode($settingInfo) . PHP_EOL;
if($settingInfo !== false){
$templateCommonModel = new BTemplateCommon();
$commonList = $templateCommonModel->list(['template_id'=>['in',[$settingInfo['template_id'],0]]]);
if(!empty($commonList)){
foreach ($commonList as $v){
$typeArr = [1, 2, 3];
foreach ($typeArr as $type){
if($type == 1){
$headData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>1,
'template_id'=>$v['template_id'],
'html'=>$v['head_html'],
'html_style'=>$v['head_css'],
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($headData);
}elseif ($type == 2){
$footerData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>2,
'template_id'=>$v['template_id'],
'html'=>$v['footer_html'],
'html_style'=>$v['footer_css'],
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($footerData);
}elseif ($type == 3){
$otherData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>3,
'template_id'=>$v['template_id'],
'html'=>$v['other'],
'html_style'=>null,
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($otherData);
}
}
}
}
}
return true;
}
}