作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -82,17 +82,6 @@ class InitProject extends Command
}
/**
* @remark :保存默认扩展模块
* @name :saveModule
* @author :lyh
* @method :post
* @time :2023/12/28 15:53
*/
public function saveModule(){
}
/**
* @param NoticeLog $log
*/
public function retry($log, $remark){
... ...
... ... @@ -54,11 +54,11 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>['in',[518,241]],'is_upgrade'=>0]);
$list = $projectModel->list(['id'=>['in',[183]],'is_upgrade'=>0]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->getProduct();
// $this->getProduct();
$this->setProductKeyword();
DB::disconnect('custom_mysql');
}
... ...
... ... @@ -182,7 +182,10 @@ class OptimizeController extends BaseController
});
}
if(isset($this->map['domain']) && !empty($this->map['domain'])){
$query = $query->where('gl_project_deploy_optimize.domain','like','%'.$this->map['domain'].'%');
$parsedUrl = parse_url($this->map['domain']);
$this->map['domain'] = $parsedUrl['host'] ?? $this->map['domain'];
$ids = DomainInfo::where('domain', 'like', '%'.$this->map['domain'].'%')->pluck('id')->toArray();
$query = $query->whereIn('gl_project_deploy_optimize.domain', $ids);
}
if(isset($this->map['test_domain']) && !empty($this->map['test_domain'])){
$query = $query->where('gl_project_deploy_build.test_domain','like','%'.$this->map['test_domain'].'%');
... ...
... ... @@ -179,6 +179,8 @@ class ProjectController extends BaseController
$query->where(function ($subQuery) {
// 搜索域名
if ($this->map['search_type'] == 'domain') {
$parsedUrl = parse_url($this->map['search']);
$this->map['search'] = $parsedUrl['host'] ?? $this->map['search'];
$ids = DomainInfo::where('domain', 'like', '%'.$this->map['search'].'%')->pluck('id')->toArray();
$subQuery->whereIn('gl_project_deploy_optimize.domain', $ids);
} else if($this->map['search_type'] == 'test_domain'){
... ... @@ -333,8 +335,8 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/17 16:42
*/
public function info(Request $request, ProjectLogic $logic){
$request->validate([
public function info(ProjectLogic $logic){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
... ... @@ -352,17 +354,17 @@ class ProjectController extends BaseController
*/
public function save(ProjectLogic $logic)
{
$this->request->validate([
'type'=>'required'
],[
'type.required' => '类型不能为空'
]);
$logic->projectSave();
$this->response('success');
}
/**
* 询盘通知设置
* @param ProjectRequest $request
* @param ProjectLogic $logic
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author zbj
* @date 2023/5/17
*/
... ... @@ -400,10 +402,6 @@ class ProjectController extends BaseController
/**
* 省市数据源
* @param ProjectLogic $logic
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author zbj
* @date 2023/6/27
*/
... ... @@ -414,10 +412,6 @@ class ProjectController extends BaseController
/**
* 渠道数据源
* @param ProjectLogic $logic
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author zbj
* @date 2023/6/27
*/
... ... @@ -750,6 +744,13 @@ class ProjectController extends BaseController
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :处理tdk
* @name :handleTdk
* @author :lyh
* @method :post
* @time :2023/12/29 11:16
*/
public function handleTdk($item){
$data = [
'gl_product'=>'产品',
... ...
... ... @@ -29,11 +29,9 @@ class ComController extends BaseController
public function get_menu(){
//根据当前登录用户角色返回用户菜单列表
$projectMenuModel = new ProjectMenuModel();
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(11111, true) . PHP_EOL, FILE_APPEND);
if($this->user['role_id'] != 0){
$this->map = $this->getNoAdminMenuCondition();
}else{
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($this->map, true) . PHP_EOL, FILE_APPEND);
$this->map = $this->getAdminMenuCondition();
}
$lists = $projectMenuModel->list($this->map,'sort');
... ...
... ... @@ -45,7 +45,6 @@ class FileManageController extends BaseController
$this->map['project_id'] = $this->user['project_id'];
$this->request['name'] && $this->map['name'] = ['like','%'.$this->request['name'].'%'];
$lists = $fileManage->lists($this->map, $this->page, $this->row);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($lists, true) . PHP_EOL, FILE_APPEND);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['download_url'] = url('b/file_manager_downLoad?path='.$v['path']);
... ...
... ... @@ -89,7 +89,6 @@ class NewsController extends BaseController
$str = [];
$str[] = $this->map['category_id'];
$this->getAllSub($this->map['category_id'],$str);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($str, true) . PHP_EOL, FILE_APPEND);
$query->where(function ($subQuery) use ($str) {
foreach ($str as $v) {
$subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]);
... ...
... ... @@ -111,9 +111,6 @@ class DomainInfoLogic extends BaseLogic
/**
* 删除域名
* @return array
* @throws \App\Exceptions\AsideGlobalException
* @throws \App\Exceptions\BsideGlobalException
*/
public function delDomain(){
$ids = $this->param['id'];
... ...
... ... @@ -73,20 +73,23 @@ class BTemplateLogic extends BaseLogic
'is_custom'=>$is_custom, 'is_list'=>$is_list
]);
if($templateInfo === false){
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
$html = $this->isCustomizedPage($this->param['source'],$is_list);//获取定制页面的html
return $this->success(['html'=>$html,'template_id'=>$template_id]);
if(!empty($html)){
return $this->success(['html'=>$html,'template_id'=>$template_id]);
}
}
$mainInfo = $this->getMAinHtml($this->param['source'],$is_custom,$is_list);//获取中间部分代码
}else{
if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码
$commonInfo = $this->getCommonHtml($this->param['source'],$is_list,0);//获取定制头部
$type = $this->getCustomizedType($this->param['source'],$is_list);
$commonInfo = $this->getCustomizedCommonHtml($type);//获取定制头部
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
}
$mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
}
$commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id);//获取定制头部
$commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取定制头部
$html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
$html = $this->getHeadFooter($html);
... ... @@ -128,8 +131,8 @@ class BTemplateLogic extends BaseLogic
* @time :2023/7/27 15:08
*/
public function getInitModule($type,$is_custom,$is_list){
if($is_custom == BTemplate::SOURCE_CUSTOM) {
$type = BTemplate::TYPE_CUSTOM;
if($is_custom == BTemplate::IS_CUSTOM) {
$type = BTemplate::SOURCE_CUSTOM;
}
$mainModel = new TemplateTypeMain();
$info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]);
... ... @@ -172,7 +175,7 @@ class BTemplateLogic extends BaseLogic
if($customHtmlInfo === false){
$this->fail('定制页面,请先上传代码块');
}
$commonInfo = $this->getCommonHtml($type,$is_list,0);//获取定制头部
$commonInfo = $this->getCustomizedCommonHtml($type);//获取定制头部
if($commonInfo !== false){
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
}
... ... @@ -182,33 +185,50 @@ class BTemplateLogic extends BaseLogic
}
/**
* @remark :根据source获取type类型
* @remark :定制项目获取头部底部
* @name :getCustomizedCommonHtml
* @author :lyh
* @method :post
* @time :2023/12/29 13:13
*/
public function getCustomizedCommonHtml($type){
$data = [
'template_id' => 0,
'project_id' => $this->user['project_id'],
'type'=>$type
];
$commonTemplateModel = new BTemplateCommon();
return $commonTemplateModel->read($data);
}
/**
* @remark :定制页面头部类型---根据source获取type类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/11/16 11:20
*/
public function getCustomizedType($source,$is_list){
$type = BTemplate::TYPE_ONE;
$type = BTemplate::TYPE_HOME;
if($source == BTemplate::SOURCE_PRODUCT){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_THREE;
$type = BTemplate::TYPE_PRODUCT_LIST;
}else{
$type = BTemplate::TYPE_TWO;
$type = BTemplate::TYPE_PRODUCT_DETAIL;
}
}
if($source == BTemplate::SOURCE_BLOG){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_FIVE;
$type = BTemplate::TYPE_BLOG_LIST;
}else{
$type = BTemplate::TYPE_FOUR;
$type = BTemplate::TYPE_BLOG_DETAIL;
}
}
if($source == BTemplate::SOURCE_NEWS){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_SEVEN;
$type = BTemplate::TYPE_NEWS_LIST;
}else{
$type = BTemplate::TYPE_SIX;
$type = BTemplate::TYPE_NEWS_DETAIL;
}
}
return $type;
... ... @@ -223,7 +243,7 @@ class BTemplateLogic extends BaseLogic
*/
public function getSettingTemplate($source,$is_list){
$template_id = 0;
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION) {//定制项目
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
... ... @@ -247,8 +267,8 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/10/21 16:55
*/
public function getCommonHtml($source,$is_list,$template_id){
$type = $this->getType($source,$is_list,$template_id);
public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){
$type = $this->getType($source,$is_list,$is_custom);
$data = [
'template_id' => $template_id,
'project_id' => $this->user['project_id'],
... ... @@ -306,7 +326,7 @@ class BTemplateLogic extends BaseLogic
$this->model->edit($data,$condition);
}
//更新头部信息
$this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id']);
$this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id'],$this->param['is_custom']);
$this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']);
//通知更新
$this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
... ... @@ -336,7 +356,7 @@ class BTemplateLogic extends BaseLogic
* @time :2023/12/15 10:59
*/
public function handleVisualizationParam($html,$source, $is_list,$data){
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//定制项目
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//定制项目
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
... ... @@ -364,8 +384,11 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/12/13 17:05
*/
public function saveCommonHtml($html,$source,$is_list,$template_id){
$type = $this->getType($source,$is_list,$template_id);//获取头部类型1-9(首页到自定义页面)
public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
$type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面)
if($template_id == 0){//定制页面默认为独立头部
$type = $this->getCustomizedType($source,$is_list);//定制默认独立头部
}
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
$handleInfo = $this->handleCommonParam($html);
... ... @@ -440,11 +463,11 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/10/21 17:29
*/
public function getType($source,$is_list,$template_id){
public function getType($source,$is_list,$is_custom = 0){
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
if($template_id == 0){//保存上传的代码块时,默认为独立头部
$is_head == BTemplate::IS_HEADER;
if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
return $this->success($type);
}
//查看页面是否设置自定义头部底部
if($is_head != BTemplate::IS_NO_HEADER) {
... ... @@ -453,17 +476,18 @@ class BTemplateLogic extends BaseLogic
if ($pageInfo === false) {
return $this->success($type);
}
if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list == 0) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_TWO;}}
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_THREE;}}}
if ($source == BTemplate::SOURCE_BLOG) {if ($is_list == 0) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_FOUR;}}
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_FIVE;}}}
if ($source == BTemplate::SOURCE_NEWS) {if ($is_list == 0) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_SIX;}}
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_SEVEN;}}}
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_EIGHT;}}
if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
}
return $this->success($type);
}
/**
* @remark :生成记录
* @name :setTemplateLog
... ... @@ -581,7 +605,7 @@ class BTemplateLogic extends BaseLogic
$param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$param['footer_css'] = characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s');
if(!isset($param['is_custom'])){
$param['is_custom'] = BTemplate::SOURCE_NO_CUSTOM;
$param['is_custom'] = BTemplate::IS_NO_CUSTOM;
}
$param['type'] = BTemplate::PAGE_HTML;//不显示整个HTML
return $this->success($param);
... ...
... ... @@ -285,25 +285,9 @@ class CustomTemplateLogic extends BaseLogic
}
//获取type类型
$commonInfo = $this->getCommonPage($info['template_id']);
$html = '';
if($commonInfo !== false){
$html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$preg_html.$commonInfo['footer_html'];
}else{
//兼容老数据,获取首页数据
$TemplateInfo = (new BTemplate())->read([
'template_id'=>$info['template_id'],
'source'=>1,
'project_id'=>$this->user['project_id'],
'source_id'=>0,
]);;
if($TemplateInfo !== false){
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s',$html_style , $TemplateInfo['html']);
//内容
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $preg_html, $html);
}
}
return $html;
$html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$preg_html.$commonInfo['footer_html'];
return $this->success($html);
}
/**
... ...
... ... @@ -10,6 +10,7 @@
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Project\PageSetting;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
... ... @@ -47,7 +48,7 @@ class InitHtmlLogic extends BaseLogic
$main_html = $mainInfo['main_html'];
$main_style = $mainInfo['main_css'];
}
$commonInfo = $this->getTypeCommonHtml($template_id,$this->param['type'],$is_custom,$is_list); //获取头部
$commonInfo = $this->getCommonHtml($this->param['type'],$is_list,$template_id,$is_custom); //获取头部
$html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
$html = $this->getHeadFooter($html);//组装数据
return $this->success($html);
... ... @@ -109,43 +110,94 @@ class InitHtmlLogic extends BaseLogic
];
$bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
}
$this->saveDetailCommonHtml($this->param['html'],$this->param['type'],$template_id,$is_custom,$is_list);
$this->saveCommonHtml($this->param['html'],$this->param['type'],$is_list,$template_id,$is_custom);
$route = RouteMap::getRoute('all',0,$this->user['project_id']);
$this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
return $this->success();
}
/**
* @remark :保存详情页模版头部底部
* @name :saveDetailCommonHtml
* @remark :保存公共头部底部
* @name :saveCommonHtml
* @author :lyh
* @method :post
* @time :2023/12/15 18:12
* @time :2023/12/13 17:05
*/
public function saveDetailCommonHtml($html,$type,$template_id,$is_custom,$is_list){
$publicData = $this->handleCommonParam($html);
public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
$type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面)
$templateCommonModel = new BTemplateCommon();
//查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部
$is_head = $this->user['configuration']['is_head'] ?? 0;
if($is_custom == BTemplate::SOURCE_CUSTOM){//todo::扩展模块无独立头部底部
$is_head = BTemplate::IS_NO_HEADER;
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
];
$templateCommonModel->add($data);
}else{
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
}
if($is_head == BTemplate::IS_HEADER) {
//有独立头部,更新独立头部
$commonType = $this->getHeaderType($type,$is_list);
$templateCommonInfo = $templateCommonModel->read(['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'type'=>$commonType]);
if($templateCommonInfo === false){
$publicData['type'] = $type;
$publicData['project_id'] = $this->user['project_id'];
$publicData['template_id'] = $template_id;
$templateCommonModel->add($publicData);
}else{
$templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]);
//更新所有界面的other
return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
}
/**
* @remark :根据类型获取公共头和底
* @name :getCommonPage
* @author :lyh
* @method :post
* @time :2023/10/21 16:55
*/
public function getCommonHtml($source,$is_list,$template_id,$is_custom){
$type = $this->getType($source,$is_list,$is_custom);
$data = [
'template_id' => $template_id,
'project_id' => $this->user['project_id'],
'type'=>$type
];
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read($data);
if($commonInfo === false){
$data['type'] = BTemplate::SOURCE_HOME;
$commonInfo = $commonTemplateModel->read($data);
}
return $this->success($commonInfo);
}
/**
* @remark :保存时获取获取设置的类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/10/21 17:29
*/
public function getType($source,$is_list,$is_custom = 0){
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
return $this->success($type);
}
//查看页面是否设置自定义头部底部
if($is_head != BTemplate::IS_NO_HEADER) {
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo === false) {
return $this->success($type);
}
}else{
//更新首页头部底部
$templateCommonModel->edit($publicData,['type'=>BTemplate::SOURCE_HOME,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
}
return $this->success();
return $this->success($type);
}
/**
... ... @@ -174,8 +226,8 @@ class InitHtmlLogic extends BaseLogic
* @time :2023/7/27 15:08
*/
public function getInitModule($type,$is_custom,$is_list){
if($is_custom == BTemplate::SOURCE_CUSTOM) {
$type = BTemplate::TYPE_CUSTOM;
if($is_custom == BTemplate::IS_CUSTOM) {
$type = BTemplate::SOURCE_CUSTOM;
}
$mainModel = new TemplateTypeMain();
$info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]);
... ... @@ -183,67 +235,6 @@ class InitHtmlLogic extends BaseLogic
}
/**
* @remark :根据type获取头部html
* @name :getHeaderFooter
* @author :lyh
* @method :post
* @time :2023/12/15 18:06
*/
public function getTypeCommonHtml($template_id,$type,$is_custom,$is_list){
//判断当前项目是否有设置独立头部的权限
$is_head = $this->user['configuration']['is_head'] ?? 0;
if($is_custom == BTemplate::SOURCE_CUSTOM){//todo::拓展模块默认取首页
$is_head = BTemplate::IS_NO_HEADER;
}
//获取首页公共部分
$templateCommonModel = new BTemplateCommon();
if($is_head == BTemplate::IS_HEADER) {
//有独立头部,获取独立头部
$commonType = $this->getHeaderType($type,$is_list);
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$commonType]);
if($commonInfo !== false){
return $this->success($commonInfo);
}
}
//首页头底
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>BTemplate::SOURCE_HOME]);
return $this->success($commonInfo);
}
/**
* @remark :独立头部获取头部底部类型
* @name :getHeaderType
* @author :lyh
* @method :post
* @time :2023/12/27 11:36
*/
public function getHeaderType($type,$is_list){
$resultType = BTemplate::SOURCE_HOME;
if($type == BTemplate::SOURCE_PRODUCT){
if($is_list == BTemplate::IS_LIST){
$resultType = BTemplate::TYPE_THREE;
}else{
$resultType = BTemplate::TYPE_TWO;
}
}
if($type == BTemplate::SOURCE_BLOG){
if($is_list == BTemplate::IS_LIST){
$resultType = BTemplate::TYPE_FIVE;
}else{
$resultType = BTemplate::TYPE_FOUR;
}
}
if($type == BTemplate::SOURCE_NEWS){
if($is_list == BTemplate::IS_LIST){
$resultType = BTemplate::TYPE_SEVEN;
}else{
$resultType = BTemplate::TYPE_SIX;
}
}
return $this->success($resultType);
}
/**
* @remark :获取模版id
* @name :getTemplateId
* @author :lyh
... ...
... ... @@ -142,6 +142,9 @@ class KeywordLogic extends BaseLogic
}
try {
foreach ($this->param['title'] as $k=>$v){
if(empty($v)){
continue;
}
$this->model = new Keyword();
$info = $this->model->read(['title'=>$v]);
if($info === false){
... ...
... ... @@ -480,7 +480,6 @@ class RankDataLogic extends BaseLogic
$model->lang = $lang;
$model->data = $data;
$model->updated_date = date('Y-m-d');
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($model, true) . PHP_EOL, FILE_APPEND);
$model->save();
}
}
... ...
... ... @@ -12,35 +12,49 @@ use App\Models\Base;
*/
class BTemplate extends Base
{
const SOURCE_CUSTOM = 1;//自定义模块
/**
* 模块类型
*/
const SOURCE_HOME = 1;//首页
const SOURCE_PRODUCT = 2;//产品
const SOURCE_BLOG = 3;//博客
const SOURCE_NEWS = 4;//新闻详情页
const SOURCE_KEYWORD = 5;//聚合页
const SOURCE_CUSTOM = 7;//自定义模块
/**
* 拼接数据还是返回整个html
*/
const ALL_HTML = 1;//无需拼接数据,获取整个html
const PAGE_HTML = 0;//默认保存方式为0,
const SOURCE_VISUALIZATION = 1;//定制项目
const SOURCE_NO_CUSTOM = 0;//默认模块
const STATUS = 0;
const TYPE_ONE = 1;//首页类型
const TYPE_TWO = 2;//产品详情
const TYPE_THREE = 3;//产品列表
const TYPE_FOUR = 4;//博客详情
const TYPE_FIVE = 5;//博客列表
const TYPE_SIX = 6;//新闻详情
const TYPE_SEVEN = 7;//新闻列表
const TYPE_EIGHT = 8;//自定义页面
const TYPE_CUSTOM = 7;//扩展详情
/**
* 独立头部类型
*/
const TYPE_HOME = 1;//首页类型
const TYPE_PRODUCT_DETAIL = 2;//产品详情
const TYPE_PRODUCT_LIST = 3;//产品列表
const TYPE_BLOG_DETAIL = 4;//博客详情
const TYPE_BLOG_LIST = 5;//博客列表
const TYPE_NEWS_DETAIL = 6;//新闻详情
const TYPE_NEWS_LIST = 7;//新闻列表
const TYPE_CUSTOM_PAGE = 8;//自定义页面
/**
* 其他相关定义
*/
const IS_LIST = 1;//列表页
const IS_HEADER = 1;//独立头部底部
const IS_NO_HEADER = 0;//非独立头部底部
const IS_CUSTOM = 1;//为扩展模块
const IS_NO_CUSTOM = 0;//为默认模块
const IS_VISUALIZATION = 1;//定制项目
const STATUS = 0;
/**
* @var string
*/
protected $table = 'gl_web_template';
//连接数据库
protected $connection = 'custom_mysql';
... ... @@ -110,10 +124,21 @@ class BTemplate extends Base
]
];
/**
* @remark :对用模块类型
* @name :typeMap
* @author :lyh
* @method :post
* @time :2023/12/29 10:57
*/
public function typeMap()
{
return [
self::SOURCE_HOME => 'xxxx',
'SOURCE_HOME'=>self::SOURCE_HOME,
'SOURCE_PRODUCT'=>self::SOURCE_PRODUCT,
'SOURCE_BLOG'=>self::SOURCE_BLOG,
'SOURCE_NEWS'=>self::SOURCE_NEWS,
'SOURCE_KEYWORD'=>self::SOURCE_KEYWORD,
];
}
}
... ...
... ... @@ -8,6 +8,7 @@
namespace App\Services;
use App\Models\CustomModule\CustomModule;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
... ... @@ -102,8 +103,43 @@ class ProjectServer extends BaseService
*/
public static function saveInitParam($project_id){
$created_at = date('Y-m-d H:i:s');
self::initGroup($project_id,$created_at);
//初始化单页
self::init404Page($project_id);
//初始化模块数据
self::initModule($project_id);
DB::disconnect('custom_mysql');
return true;
}
//菜单
/**
* @remark :初始化模块
* @name :initModule
* @author :lyh
* @method :post
* @time :2023/12/29 9:34
*/
public function initModule($project_id){
$moduleModel = new CustomModule();
$info = $moduleModel->read(['route'=>'video']);
if($info === false){
$data = [
'name'=>'视频模块',
'project_id'=>$project_id,
'route'=>'video',
];
$moduleModel->add($data);
}
return true;
}
/**
* @remark :菜单
* @name :initGroup
* @author :lyh
* @method :post
* @time :2023/12/29 9:30
*/
public static function initGroup($project_id,$created_at){
$info = DB::connection('custom_mysql')->table('gl_web_nav')->first();
if(empty($info)) {
$data = [
... ... @@ -116,7 +152,6 @@ class ProjectServer extends BaseService
];
DB::connection('custom_mysql')->table('gl_web_nav')->insert($data);
}
//菜单组
$info = DB::connection('custom_mysql')->table('gl_web_nav_group')->first();
if(empty($info)) {
... ... @@ -126,11 +161,20 @@ class ProjectServer extends BaseService
];
DB::connection('custom_mysql')->table('gl_web_nav_group')->insert($data);
}
return true;
}
//初始化单页
/**
* @remark :初始化404页面
* @name :init404Page
* @author :lyh
* @method :post
* @time :2023/12/29 9:32
*/
public function init404Page($project_id){
$info = DB::connection('custom_mysql')->table('gl_web_custom_template')->first();
if(empty($info)) {
$data = ['project_id' => $project_id, 'name' => BCustomTemplate::NOT_FOUND_PAGE_URL, 'status' => 1, 'url' => BCustomTemplate::NOT_FOUND_PAGE_URL, 'html' => '<main>
$main_404_html = '<main>
<section data-section="section" data-screen="screen-large" class="section-404-wrap-block section-block-error404"
id="sectionIdyxqu938">
<div class="layout" data-unable="demo01-error404">
... ... @@ -156,7 +200,14 @@ class ProjectServer extends BaseService
<script>
</script>
</section>
</main>', 'html_style' => '<style id="globalsojs-styles"></style>','title' => '404-Page not found', 'description' => 'Sorry. The page has either moved or cannot be found.', 'created_at' => $created_at, 'updated_at' => $created_at];
</main>';
$data = [
'project_id' => $project_id,
'name' => BCustomTemplate::NOT_FOUND_PAGE_URL,
'status' => 1,
'url' => BCustomTemplate::NOT_FOUND_PAGE_URL,
'html' => $main_404_html,
'html_style' => '<style id="globalsojs-styles"></style>','title' => '404-Page not found', 'description' => 'Sorry. The page has either moved or cannot be found.', 'created_at' => $created_at, 'updated_at' => $created_at];
$id = DB::connection('custom_mysql')->table('gl_web_custom_template')->insertGetId($data);
//路由
$info = DB::connection('custom_mysql')->table('gl_route_map')->first();
... ... @@ -165,8 +216,5 @@ class ProjectServer extends BaseService
DB::connection('custom_mysql')->table('gl_route_map')->insert($data);
}
}
DB::disconnect('custom_mysql');
return true;
}
}
... ...