|
@@ -12,6 +12,8 @@ namespace App\Services\Html; |
|
@@ -12,6 +12,8 @@ namespace App\Services\Html; |
|
12
|
use App\Models\CustomModule\CustomModule;
|
12
|
use App\Models\CustomModule\CustomModule;
|
|
13
|
use App\Models\CustomModule\CustomModuleCategory;
|
13
|
use App\Models\CustomModule\CustomModuleCategory;
|
|
14
|
use App\Models\CustomModule\CustomModuleContent;
|
14
|
use App\Models\CustomModule\CustomModuleContent;
|
|
|
|
15
|
+use App\Models\Project\PageSetting;
|
|
|
|
16
|
+use App\Models\Project\Project;
|
|
15
|
use App\Models\RouteMap\RouteMap;
|
17
|
use App\Models\RouteMap\RouteMap;
|
|
16
|
use App\Models\Template\BTemplate;
|
18
|
use App\Models\Template\BTemplate;
|
|
17
|
use App\Models\Template\BTemplateCommon;
|
19
|
use App\Models\Template\BTemplateCommon;
|
|
@@ -36,20 +38,14 @@ class GeneratePageService |
|
@@ -36,20 +38,14 @@ class GeneratePageService |
|
36
|
* @method :post
|
38
|
* @method :post
|
|
37
|
* @time :2024/2/19 16:57
|
39
|
* @time :2024/2/19 16:57
|
|
38
|
*/
|
40
|
*/
|
|
39
|
- public function generateHtml($project_id,$route){
|
|
|
|
40
|
- $this->project_id = $project_id;
|
|
|
|
41
|
- $this->route = $route;
|
41
|
+ public function generateHtml($projectInfo,$routeInfo){
|
|
|
|
42
|
+ $this->project_id = $projectInfo['id'];
|
|
|
|
43
|
+ $this->route = $routeInfo['route'];
|
|
42
|
ProjectServer::useProject($this->project_id);
|
44
|
ProjectServer::useProject($this->project_id);
|
|
43
|
- $routeMapModel = new RouteMap();
|
|
|
|
44
|
- $routeInfo = $routeMapModel->read(['route'=>$this->param['route']]);
|
|
|
|
45
|
- if($this->param['route'] != RouteMap::SOURCE_INDEX && $routeInfo['source'] == RouteMap::SOURCE_PAGE){
|
|
|
|
46
|
- //页面管理单独处理
|
|
|
|
47
|
- }else{
|
|
|
|
48
|
- $this->handleParam($routeInfo);
|
|
|
|
49
|
- return $this->getTemplateHtml();
|
|
|
|
50
|
- }
|
45
|
+ $this->handleParam($routeInfo);
|
|
|
|
46
|
+ $result = $this->getTemplateHtml($projectInfo);
|
|
51
|
DB::disconnect('custom_mysql');
|
47
|
DB::disconnect('custom_mysql');
|
|
52
|
- return true;
|
48
|
+ return $this->success($result);
|
|
53
|
}
|
49
|
}
|
|
54
|
|
50
|
|
|
55
|
/**
|
51
|
/**
|
|
@@ -125,14 +121,17 @@ class GeneratePageService |
|
@@ -125,14 +121,17 @@ class GeneratePageService |
|
125
|
* @author :lyh
|
121
|
* @author :lyh
|
|
126
|
* @method :post
|
122
|
* @method :post
|
|
127
|
*/
|
123
|
*/
|
|
128
|
- public function getTemplateHtml(){
|
124
|
+ public function getTemplateHtml($projectInfo){
|
|
129
|
$is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块
|
125
|
$is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块
|
|
130
|
$is_list = $this->param['is_list'] ?? 0;//是否为列表页
|
126
|
$is_list = $this->param['is_list'] ?? 0;//是否为列表页
|
|
131
|
- $template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id
|
127
|
+ $template_id = $this->getSettingTemplate($projectInfo,$this->param['source'],$is_list,$is_custom);//设置的模版id
|
|
|
|
128
|
+ if($template_id === false){
|
|
|
|
129
|
+ return false;
|
|
|
|
130
|
+ }
|
|
132
|
$templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
|
131
|
$templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
|
|
133
|
if($templateInfo === false){
|
132
|
if($templateInfo === false){
|
|
134
|
- if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
|
|
|
|
135
|
- $html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
|
133
|
+ if($projectInfo['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
|
|
|
|
134
|
+ $html = $this->customizedReturnHtml($projectInfo,$this->param['source'],$template_id,$is_custom,$is_list);
|
|
136
|
if($html !== false){
|
135
|
if($html !== false){
|
|
137
|
return $this->success($html);
|
136
|
return $this->success($html);
|
|
138
|
}
|
137
|
}
|
|
@@ -145,10 +144,10 @@ class GeneratePageService |
|
@@ -145,10 +144,10 @@ class GeneratePageService |
|
145
|
}
|
144
|
}
|
|
146
|
$mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
|
145
|
$mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
|
|
147
|
}
|
146
|
}
|
|
148
|
- $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部
|
147
|
+ $commonInfo = $this->getCommonHtml($projectInfo,$this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部
|
|
149
|
$html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
|
148
|
$html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
|
|
150
|
$html = $this->getHeadFooter($html);
|
149
|
$html = $this->getHeadFooter($html);
|
|
151
|
- $result = ['html'=>$html,'template_id'=>$template_id];
|
150
|
+ $result = ['html'=>$html];
|
|
152
|
return $this->success($result);
|
151
|
return $this->success($result);
|
|
153
|
}
|
152
|
}
|
|
154
|
|
153
|
|
|
@@ -181,7 +180,7 @@ class GeneratePageService |
|
@@ -181,7 +180,7 @@ class GeneratePageService |
|
181
|
public function webTemplateInfo($source,$source_id,$template_id,$is_custom,$is_list){
|
180
|
public function webTemplateInfo($source,$source_id,$template_id,$is_custom,$is_list){
|
|
182
|
$templateInfo = $this->model->read([
|
181
|
$templateInfo = $this->model->read([
|
|
183
|
'template_id'=>$template_id, 'source'=>$source,
|
182
|
'template_id'=>$template_id, 'source'=>$source,
|
|
184
|
- 'project_id'=>$this->user['project_id'], 'source_id'=>$source_id,
|
183
|
+ 'project_id'=>$this->project_id, 'source_id'=>$source_id,
|
|
185
|
'is_custom'=>$is_custom, 'is_list'=>$is_list
|
184
|
'is_custom'=>$is_custom, 'is_list'=>$is_list
|
|
186
|
]);
|
185
|
]);
|
|
187
|
return $this->success($templateInfo);
|
186
|
return $this->success($templateInfo);
|
|
@@ -194,29 +193,35 @@ class GeneratePageService |
|
@@ -194,29 +193,35 @@ class GeneratePageService |
|
194
|
* @method :post
|
193
|
* @method :post
|
|
195
|
* @time :2024/1/10 13:46
|
194
|
* @time :2024/1/10 13:46
|
|
196
|
*/
|
195
|
*/
|
|
197
|
- public function customizedReturnHtml($source,$template_id,$is_custom,$is_list){
|
196
|
+ public function customizedReturnHtml($projectInfo,$source,$template_id,$is_custom,$is_list){
|
|
198
|
//TODO::扩展模块定制单独处理
|
197
|
//TODO::扩展模块定制单独处理
|
|
199
|
if($is_custom == BTemplate::IS_CUSTOM){
|
198
|
if($is_custom == BTemplate::IS_CUSTOM){
|
|
200
|
$customModuleModel = new CustomModule();
|
199
|
$customModuleModel = new CustomModule();
|
|
201
|
$info = $customModuleModel->read(['id'=>$source]);
|
200
|
$info = $customModuleModel->read(['id'=>$source]);
|
|
202
|
if($info === false){
|
201
|
if($info === false){
|
|
203
|
- $this->fail('当前扩展模块不存在或已被删除');
|
202
|
+ return false;
|
|
204
|
}
|
203
|
}
|
|
205
|
//扩展模块定制
|
204
|
//扩展模块定制
|
|
206
|
if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){
|
205
|
if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){
|
|
207
|
$html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
|
206
|
$html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
|
|
208
|
- return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
207
|
+ if($html === false){
|
|
|
|
208
|
+ return false;
|
|
|
|
209
|
+ }
|
|
|
|
210
|
+ return $this->success(['html'=>$html]);
|
|
209
|
}
|
211
|
}
|
|
210
|
if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
|
212
|
if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
|
|
211
|
$html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
|
213
|
$html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
|
|
212
|
- return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
214
|
+ if($html === false){
|
|
|
|
215
|
+ return false;
|
|
|
|
216
|
+ }
|
|
|
|
217
|
+ return $this->success(['html'=>$html]);
|
|
213
|
}
|
218
|
}
|
|
214
|
return false;
|
219
|
return false;
|
|
215
|
}
|
220
|
}
|
|
216
|
//TODO::默认模块定制
|
221
|
//TODO::默认模块定制
|
|
217
|
- $html = $this->isCustomizedPage($source,$is_list,$is_custom);//获取定制页面的html
|
|
|
|
218
|
- if(!empty($html)){
|
|
|
|
219
|
- return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
222
|
+ $html = $this->isCustomizedPage($projectInfo,$source,$is_list,$is_custom);//获取定制页面的html
|
|
|
|
223
|
+ if($html !== false){
|
|
|
|
224
|
+ return $this->success(['html'=>$html]);
|
|
220
|
}
|
225
|
}
|
|
221
|
return false;
|
226
|
return false;
|
|
222
|
}
|
227
|
}
|
|
@@ -233,7 +238,7 @@ class GeneratePageService |
|
@@ -233,7 +238,7 @@ class GeneratePageService |
|
233
|
//TODO::获取初始代码
|
238
|
//TODO::获取初始代码
|
|
234
|
$customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
|
239
|
$customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
|
|
235
|
if($customHtmlInfo === false){
|
240
|
if($customHtmlInfo === false){
|
|
236
|
- $this->fail('定制页面,请先上传代码块');
|
241
|
+ return false;
|
|
237
|
}
|
242
|
}
|
|
238
|
$commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部
|
243
|
$commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部
|
|
239
|
if($commonInfo !== false){
|
244
|
if($commonInfo !== false){
|
|
@@ -303,17 +308,17 @@ class GeneratePageService |
|
@@ -303,17 +308,17 @@ class GeneratePageService |
|
303
|
* @method :post
|
308
|
* @method :post
|
|
304
|
* @time :2023/12/13 10:55
|
309
|
* @time :2023/12/13 10:55
|
|
305
|
*/
|
310
|
*/
|
|
306
|
- public function isCustomizedPage($source,$is_list,$is_custom)
|
311
|
+ public function isCustomizedPage($projectInfo,$source,$is_list,$is_custom)
|
|
307
|
{
|
312
|
{
|
|
308
|
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
|
313
|
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
|
|
309
|
//查看当前页面是否定制,是否开启可视化
|
314
|
//查看当前页面是否定制,是否开启可视化
|
|
310
|
- $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
315
|
+ $page_array = (array)$projectInfo['is_visualization']->page_array;//获取所有定制界面
|
|
311
|
if (in_array($type, $page_array)) {//是定制界面
|
316
|
if (in_array($type, $page_array)) {//是定制界面
|
|
312
|
//TODO::获取初始代码
|
317
|
//TODO::获取初始代码
|
|
313
|
$bTemplateMainModel = new BTemplateMain();
|
318
|
$bTemplateMainModel = new BTemplateMain();
|
|
314
|
$customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list]);
|
319
|
$customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list]);
|
|
315
|
if($customHtmlInfo === false){
|
320
|
if($customHtmlInfo === false){
|
|
316
|
- $this->fail('定制页面,请先上传代码块');
|
321
|
+ return false;
|
|
317
|
}
|
322
|
}
|
|
318
|
$commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
|
323
|
$commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
|
|
319
|
if($commonInfo !== false){
|
324
|
if($commonInfo !== false){
|
|
@@ -334,7 +339,7 @@ class GeneratePageService |
|
@@ -334,7 +339,7 @@ class GeneratePageService |
|
334
|
public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){
|
339
|
public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){
|
|
335
|
$data = [
|
340
|
$data = [
|
|
336
|
'template_id' => 0,
|
341
|
'template_id' => 0,
|
|
337
|
- 'project_id' => $this->user['project_id'],
|
342
|
+ 'project_id' => $this->project_id,
|
|
338
|
'type'=>$type,
|
343
|
'type'=>$type,
|
|
339
|
'is_custom'=>$is_custom,
|
344
|
'is_custom'=>$is_custom,
|
|
340
|
'is_list'=>$is_list
|
345
|
'is_list'=>$is_list
|
|
@@ -383,9 +388,9 @@ class GeneratePageService |
|
@@ -383,9 +388,9 @@ class GeneratePageService |
|
383
|
* @method :post
|
388
|
* @method :post
|
|
384
|
* @time :2023/12/13 10:48
|
389
|
* @time :2023/12/13 10:48
|
|
385
|
*/
|
390
|
*/
|
|
386
|
- public function getSettingTemplate($source,$is_list,$is_custom){
|
391
|
+ public function getSettingTemplate($projectInfo,$source,$is_list,$is_custom){
|
|
387
|
$template_id = 0;
|
392
|
$template_id = 0;
|
|
388
|
- if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
|
393
|
+ if($projectInfo['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
|
|
389
|
if($is_custom == BTemplate::IS_CUSTOM){
|
394
|
if($is_custom == BTemplate::IS_CUSTOM){
|
|
390
|
$customModuleModel = new CustomModule();
|
395
|
$customModuleModel = new CustomModule();
|
|
391
|
$info = $customModuleModel->read(['id'=>$source]);
|
396
|
$info = $customModuleModel->read(['id'=>$source]);
|
|
@@ -401,16 +406,16 @@ class GeneratePageService |
|
@@ -401,16 +406,16 @@ class GeneratePageService |
|
401
|
}else{
|
406
|
}else{
|
|
402
|
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
|
407
|
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
|
|
403
|
//查看当前页面是否定制,是否开启可视化
|
408
|
//查看当前页面是否定制,是否开启可视化
|
|
404
|
- $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
409
|
+ $page_array = (array)$projectInfo['is_visualization']->page_array;//获取所有定制界面
|
|
405
|
if (in_array($type, $page_array)) {//是定制界面
|
410
|
if (in_array($type, $page_array)) {//是定制界面
|
|
406
|
return $this->success($template_id);
|
411
|
return $this->success($template_id);
|
|
407
|
}
|
412
|
}
|
|
408
|
}
|
413
|
}
|
|
409
|
}
|
414
|
}
|
|
410
|
$bSettingModel = new Setting();
|
415
|
$bSettingModel = new Setting();
|
|
411
|
- $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
416
|
+ $info = $bSettingModel->read(['project_id'=>$this->project_id]);
|
|
412
|
if($info === false){
|
417
|
if($info === false){
|
|
413
|
- $this->fail('请先选择模版');
|
418
|
+ return false;
|
|
414
|
}
|
419
|
}
|
|
415
|
$template_id = $info['template_id'];
|
420
|
$template_id = $info['template_id'];
|
|
416
|
return $this->success($template_id);
|
421
|
return $this->success($template_id);
|
|
@@ -423,11 +428,11 @@ class GeneratePageService |
|
@@ -423,11 +428,11 @@ class GeneratePageService |
|
423
|
* @method :post
|
428
|
* @method :post
|
|
424
|
* @time :2023/10/21 16:55
|
429
|
* @time :2023/10/21 16:55
|
|
425
|
*/
|
430
|
*/
|
|
426
|
- public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){
|
|
|
|
427
|
- $type = $this->getType($source,$is_list,$is_custom);
|
431
|
+ public function getCommonHtml($ProjectInfo,$source,$is_list,$template_id,$is_custom = 0,){
|
|
|
|
432
|
+ $type = $this->getType($ProjectInfo,$source,$is_list,$is_custom);
|
|
428
|
$data = [
|
433
|
$data = [
|
|
429
|
'template_id' => $template_id,
|
434
|
'template_id' => $template_id,
|
|
430
|
- 'project_id' => $this->user['project_id'],
|
435
|
+ 'project_id' => $this->project_id,
|
|
431
|
'type'=>$type,
|
436
|
'type'=>$type,
|
|
432
|
'is_custom'=>0,
|
437
|
'is_custom'=>0,
|
|
433
|
];
|
438
|
];
|
|
@@ -440,4 +445,36 @@ class GeneratePageService |
|
@@ -440,4 +445,36 @@ class GeneratePageService |
|
440
|
return $this->success($commonInfo);
|
445
|
return $this->success($commonInfo);
|
|
441
|
}
|
446
|
}
|
|
442
|
|
447
|
|
|
|
|
448
|
+ /**
|
|
|
|
449
|
+ * @remark :(非定制)保存时获取获取设置的类型
|
|
|
|
450
|
+ * @name :getType
|
|
|
|
451
|
+ * @author :lyh
|
|
|
|
452
|
+ * @method :post
|
|
|
|
453
|
+ * @time :2023/10/21 17:29
|
|
|
|
454
|
+ */
|
|
|
|
455
|
+ public function getType($projectInfo,$source,$is_list,$is_custom = 0){
|
|
|
|
456
|
+ $type = BTemplate::SOURCE_HOME;//首页公共头部底部
|
|
|
|
457
|
+ $is_head = $projectInfo['deploy_build']['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
|
|
|
|
458
|
+ if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
|
|
|
|
459
|
+ return $this->success($type);
|
|
|
|
460
|
+ }
|
|
|
|
461
|
+ //查看页面是否设置自定义头部底部
|
|
|
|
462
|
+ if($is_head != BTemplate::IS_NO_HEADER) {
|
|
|
|
463
|
+ $pageSettingModel = new PageSetting();
|
|
|
|
464
|
+ $pageInfo = $pageSettingModel->read(['project_id' => $projectInfo['id']]);
|
|
|
|
465
|
+ if ($pageInfo === false) {
|
|
|
|
466
|
+ return $this->success($type);
|
|
|
|
467
|
+ }
|
|
|
|
468
|
+ if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
|
|
|
|
469
|
+ else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
|
|
|
|
470
|
+ if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
|
|
|
|
471
|
+ else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
|
|
|
|
472
|
+ if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
|
|
|
|
473
|
+ else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
|
|
|
|
474
|
+ if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
|
|
|
|
475
|
+ }
|
|
|
|
476
|
+ return $this->success($type);
|
|
|
|
477
|
+ }
|
|
|
|
478
|
+
|
|
|
|
479
|
+
|
|
443
|
} |
480
|
} |