|
...
|
...
|
@@ -7,6 +7,9 @@ |
|
|
|
*/
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
|
|
|
|
class CreateHtmlService
|
|
|
|
{
|
|
|
|
public function __construct(){}
|
|
...
|
...
|
@@ -15,13 +18,17 @@ class CreateHtmlService |
|
|
|
* 返回最终需要的HTML
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getHtml($project, $route, $lang = [], $page = 0)
|
|
|
|
public function getHtml($project_id, $route, $lang = [], $page = 0)
|
|
|
|
{
|
|
|
|
//获取项目详情
|
|
|
|
$projectInfo = $this->getProjectInfo($project_id);
|
|
|
|
if($projectInfo === false){
|
|
|
|
return ['code'=>400,'message'=>'当前项目不存在或者已被删除'];
|
|
|
|
}
|
|
|
|
// 获取页面信息
|
|
|
|
$page_info = $this->getInfoByRoute($route);
|
|
|
|
|
|
|
|
// 根据项目和路由信息返回的结果确定当前页面使用5.0还是6.0的页面;
|
|
|
|
if ($project && $page_info) {
|
|
|
|
if ($projectInfo && $page_info) {
|
|
|
|
$html = $this->getHtmlV6($page_info['master_lang'], $lang = [], $page = 0);
|
|
|
|
} else {
|
|
|
|
$html = $this->getHtmlV5();
|
|
...
|
...
|
@@ -30,6 +37,19 @@ class CreateHtmlService |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取项目详情
|
|
|
|
* @name :getProjectInfo
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/3/11 9:20
|
|
|
|
*/
|
|
|
|
public function getProjectInfo($project_id){
|
|
|
|
$projectModel = new Project();
|
|
|
|
$projectInfo = $projectModel->read(['id'=>$project_id,'delete_status'=>0],['id','is_upgrade']);
|
|
|
|
return $projectInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 返回5.0页面最终HTML
|
|
|
|
* @return string
|
|
|
|
*/
|
|
...
|
...
|
@@ -62,8 +82,17 @@ class CreateHtmlService |
|
|
|
*/
|
|
|
|
public function getInfoByRoute($route)
|
|
|
|
{
|
|
|
|
$routeMapModel = new RouteMap();
|
|
|
|
$routeInfo = $routeMapModel->read(['route'=>$route]);
|
|
|
|
if($routeInfo === false){
|
|
|
|
if($route == 'top-search' || $route == 'products' || $route == 'news' || $route == 'blog'){
|
|
|
|
$routeInfo = $route;
|
|
|
|
}else{
|
|
|
|
$routeInfo = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO 获取详情需要通过路由查下路由信息, 以及数据信息, 要处理特殊几个路由: top-search、products、news、blog, 这几个如果存在就用查下的信息, 如果不存在要初始化信息
|
|
|
|
return [];
|
|
|
|
return $routeInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -113,4 +142,4 @@ class CreateHtmlService |
|
|
|
*/
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
} |
|
|
\ No newline at end of file |
|
|
|
} |
...
|
...
|
|