|
@@ -7,6 +7,9 @@ |
|
@@ -7,6 +7,9 @@ |
|
7
|
*/
|
7
|
*/
|
|
8
|
namespace App\Services;
|
8
|
namespace App\Services;
|
|
9
|
|
9
|
|
|
|
|
10
|
+use App\Models\Project\Project;
|
|
|
|
11
|
+use App\Models\RouteMap\RouteMap;
|
|
|
|
12
|
+
|
|
10
|
class CreateHtmlService
|
13
|
class CreateHtmlService
|
|
11
|
{
|
14
|
{
|
|
12
|
public function __construct(){}
|
15
|
public function __construct(){}
|
|
@@ -15,13 +18,17 @@ class CreateHtmlService |
|
@@ -15,13 +18,17 @@ class CreateHtmlService |
|
15
|
* 返回最终需要的HTML
|
18
|
* 返回最终需要的HTML
|
|
16
|
* @return string
|
19
|
* @return string
|
|
17
|
*/
|
20
|
*/
|
|
18
|
- public function getHtml($project, $route, $lang = [], $page = 0)
|
21
|
+ public function getHtml($project_id, $route, $lang = [], $page = 0)
|
|
19
|
{
|
22
|
{
|
|
|
|
23
|
+ //获取项目详情
|
|
|
|
24
|
+ $projectInfo = $this->getProjectInfo($project_id);
|
|
|
|
25
|
+ if($projectInfo === false){
|
|
|
|
26
|
+ return ['code'=>400,'message'=>'当前项目不存在或者已被删除'];
|
|
|
|
27
|
+ }
|
|
20
|
// 获取页面信息
|
28
|
// 获取页面信息
|
|
21
|
$page_info = $this->getInfoByRoute($route);
|
29
|
$page_info = $this->getInfoByRoute($route);
|
|
22
|
-
|
|
|
|
23
|
// 根据项目和路由信息返回的结果确定当前页面使用5.0还是6.0的页面;
|
30
|
// 根据项目和路由信息返回的结果确定当前页面使用5.0还是6.0的页面;
|
|
24
|
- if ($project && $page_info) {
|
31
|
+ if ($projectInfo && $page_info) {
|
|
25
|
$html = $this->getHtmlV6($page_info['master_lang'], $lang = [], $page = 0);
|
32
|
$html = $this->getHtmlV6($page_info['master_lang'], $lang = [], $page = 0);
|
|
26
|
} else {
|
33
|
} else {
|
|
27
|
$html = $this->getHtmlV5();
|
34
|
$html = $this->getHtmlV5();
|
|
@@ -30,6 +37,19 @@ class CreateHtmlService |
|
@@ -30,6 +37,19 @@ class CreateHtmlService |
|
30
|
}
|
37
|
}
|
|
31
|
|
38
|
|
|
32
|
/**
|
39
|
/**
|
|
|
|
40
|
+ * @remark :获取项目详情
|
|
|
|
41
|
+ * @name :getProjectInfo
|
|
|
|
42
|
+ * @author :lyh
|
|
|
|
43
|
+ * @method :post
|
|
|
|
44
|
+ * @time :2024/3/11 9:20
|
|
|
|
45
|
+ */
|
|
|
|
46
|
+ public function getProjectInfo($project_id){
|
|
|
|
47
|
+ $projectModel = new Project();
|
|
|
|
48
|
+ $projectInfo = $projectModel->read(['id'=>$project_id,'delete_status'=>0],['id','is_upgrade']);
|
|
|
|
49
|
+ return $projectInfo;
|
|
|
|
50
|
+ }
|
|
|
|
51
|
+
|
|
|
|
52
|
+ /**
|
|
33
|
* 返回5.0页面最终HTML
|
53
|
* 返回5.0页面最终HTML
|
|
34
|
* @return string
|
54
|
* @return string
|
|
35
|
*/
|
55
|
*/
|
|
@@ -62,8 +82,17 @@ class CreateHtmlService |
|
@@ -62,8 +82,17 @@ class CreateHtmlService |
|
62
|
*/
|
82
|
*/
|
|
63
|
public function getInfoByRoute($route)
|
83
|
public function getInfoByRoute($route)
|
|
64
|
{
|
84
|
{
|
|
|
|
85
|
+ $routeMapModel = new RouteMap();
|
|
|
|
86
|
+ $routeInfo = $routeMapModel->read(['route'=>$route]);
|
|
|
|
87
|
+ if($routeInfo === false){
|
|
|
|
88
|
+ if($route == 'top-search' || $route == 'products' || $route == 'news' || $route == 'blog'){
|
|
|
|
89
|
+ $routeInfo = $route;
|
|
|
|
90
|
+ }else{
|
|
|
|
91
|
+ $routeInfo = [];
|
|
|
|
92
|
+ }
|
|
|
|
93
|
+ }
|
|
65
|
// TODO 获取详情需要通过路由查下路由信息, 以及数据信息, 要处理特殊几个路由: top-search、products、news、blog, 这几个如果存在就用查下的信息, 如果不存在要初始化信息
|
94
|
// TODO 获取详情需要通过路由查下路由信息, 以及数据信息, 要处理特殊几个路由: top-search、products、news、blog, 这几个如果存在就用查下的信息, 如果不存在要初始化信息
|
|
66
|
- return [];
|
95
|
+ return $routeInfo;
|
|
67
|
}
|
96
|
}
|
|
68
|
|
97
|
|
|
69
|
/**
|
98
|
/**
|
|
@@ -113,4 +142,4 @@ class CreateHtmlService |
|
@@ -113,4 +142,4 @@ class CreateHtmlService |
|
113
|
*/
|
142
|
*/
|
|
114
|
return $html;
|
143
|
return $html;
|
|
115
|
}
|
144
|
}
|
|
116
|
-} |
|
|
|
|
|
145
|
+} |